# Calculating Stock Beta

The Beta of an asset is a measure of the sensitivity of its returns relative to a market benchmark (usually a market index). How sensitive/insensitive is the returns of an asset to the overall market returns (usually a market index like S&P 500 index). What happens when the market jumps, do the returns of the asset jump accordingly?

CAPM attempts to prices securities by examining the relationship that exists between expected returns and risk. The model implies that investors always combine two types of assets or securities; a risky free asset and a risky asset in the form of a market portfolio of various assets. CAPM further posits that investors expect to be rewarded for holding these risky assets according to the risk inherited for holding on to such assets. After all, such kind of risk cannot be diversified (market related usually referred to as systematic risk) and as a result, investors need to be compensated for taking on such “undiversifiable” risks. It is intuitive when you think about. Let’s look this example:

An investor can buy risk free asset like treasury bills of a stable central bank. If such an investor opts to buy some investment package from company ABC instead of this risk free assets, then such an investor ought to be compensated for this decision. According to CAPM, company ABC does this by offering the returns of the treasury bill plus an incentive usually referred to as market premium/excess market returns (*Excess Market Return = Market Return - Risk Free Rate*) for the given level of risk (Beta) the investors take.

*CAPM = Risk Free Rate + beta × Excess Market Return*

To calculate the beta of a security, the covariance between the return of the security and the return of market must be known, as well as the variance of the market returns.

*Covariance* measures how two stocks move together. A positive covariance means the stocks tend to move together when their prices go up or down. A negative covariance means the stocks move opposite of each other.

With \(x\) is the independent variable, \(y\) is the dependent variable, \(n\) is the number of data points in the sample, \(\bar{x}\) is the mean of the independent variable x, \(\bar{y}\) is the mean of the dependent variable \(y\).

*Variance*, on the other hand, refers to how far a stock moves relative to its mean. For example, variance is used in measuring the volatility of an individual stock’s price over time. Covariance is used to measure the correlation in price moves of two different stocks. The variance (\(\sigma^2\)), is defined as the sum of the squared distances of each term in the distribution from the mean (\(\mu\)), divided by the number of terms in the distribution (\(N\)):

**Interpretation of a Beta result**

A stock with a beta of:

- 0 indicates no correlation with the chosen benchmark (e.g. NASDAQ index )
- 1 indicates a stock has the same volatility as the market
- >1 indicates a stock that’s more volatile than its benchmark
- <1 is less volatile than the benchmark
- 1.5 is 50% more volatile than the benchmark

**Calculating Beta Using Linear Regression**

Good! Now that we have a clean set of monthly returns on Facebook and S&P 500. Let’s go ahead and make the Ordinary Least Square (OLS) Regression with Statsmodel.

**Calculating Beta Using Formula**