While calculating the cost of equity, it is important for an analyst to calculate the beta of the company’s stock.
Beta of a publicly traded company can be calculated using the Market Model Regression (Slope).
In this method, we regress the company’s stock returns (ri) against the market’s returns (rm). The beta (β) is represented by the slope of the regression line.
Where,
ri is the stock’s return
α represents the intercept
β is the stock’s beta
rm is the market returns

See this article – How to Calculate Stock Beta Using Excel
Some of the issues while calculating beta are discussed below:
Using the above methods, we can easily estimate the beta of a publicly traded company, as all the information such as historical returns is publicly available. The problem arises when an analyst is required to estimate the beta of a non-public company or a project, for which there is no historical stock return data. The analyst may have to use a proxy of the beta by using some combination of the information available about the company/project and a comparable public limited company. A commonly used method is the pure-play method, in which an analyst observes the beta of a comparable public company, and adjusts it for the difference in financial leverage.