In this article, I want to show you how to calculate the beta of a stock by using its covariance with the market index. There are several different ways that you can calculate beta but I want to focus on the formula that calculates beta using covariance here in this article, so we’re going to take the covariance of the performance of the stocks and we’ll call that **Ri**. Let’s say that that’s the return for Microsoft or some other company, and then we’ve got the return of the market which is **Rm**. We’ll have some market index it could be the return of the **S&P 500** so we’re going to take the covariance of those returns and then we’re going to divide that by the variance of the **returns of the market portfolio** again.

I want to work an example and show you how we would go about doing this. Let’s say that we’ve got a fictional company here called **Bubsy**, say it’s a publicly-traded company and we have Our **monthly** stock returns for the past **six months**. Usually, when you calculate the beta you might have like three years of monthly returns. So you have a lot more data points in this, but let’s just say that we’ve got six months of data here. So they had an **11%** return in January, **17%** in February, and so forth. So we’ve got six observations and then we have some observations of the monthly return for a market index. So they are **8%**,** 10%** and so forth. So for six months, we have returned for Bubsy and then we have returns of the market index.

So for each of these, we can calculate the average return. So if we just add up the returns here for **Bubsy** and divide that them by **6**, because we have **six observations**, we get an average return of **7.83%**. And then the market index, the average return over that period is **5.67%**. We’ve got our **monthly returns** and now we’ve calculated the **mean return** for each of them so we got the mean return for Bubsy and the mean return for the market index. Now, if you had this in Microsoft Excel, you could go and use the formula** (=covariance.s)**, and you can actually just calculate using these data points to covariance and then the variance of the returns very easily. But I want to actually show you how to calculate it all by hand. So you don’t have to do the formula. Let’s say we’ve got the monthly return data and we’ve got the average return data. We can calculate the deviation, the **difference between the mean** for each of these. so we can go to **Bubsy** and say **11% -7.83,** is equal to **3.2%**, and then I actually just have a down to one decimal point here. I probably should have brought out to two, but we’ve got **3.2%**.

## Calculation of Covariance

We take each value of Bubsy, then we subtract the mean. We take **17% – 7.83%**, gives us **9.2%**. So in each case, we’re taking each value of Bubsy and we’re subtracting the mean from it to get deviations from the mean. This **Ri **that’s just the return of Bubsy then **Ri bar** will just be the mean return of Bubsy of some point. We’ll you do the same thing for the market. And so we got **Rm**, that’s just the market indexes **8% **and then we subtract **5.67%**, That’s the mean return so that would give us **2.3%**. So we subtract that so we get this is the deviation from the mean of each observation and we say, “How much did this differ from the mean? And then we record that value.”

Now, we take these deviations from the mean, we multiply them by each other. Okay. So we say **(3.2%** x **2.3%)**, and then I just convert that to add to a proportion, or to an actual number instead of a percentage. It was this **0.0007**. Then we take the product of the 2nd one month here, which gives a **0.004** and so forth. All we’re doing is multiplying each row that gives us the product of the deviations.

And then once we do that, we can add all the deviations together. We can sum them and we’ll get **0.0547** and then we multiply it by **1/n**, where **n **is the number of observations, which is **6**. So **1** divided by** 6 minus 1 **which is the same as **1 divided by 5**.** **It’ll give us **0.2**, So we’ll basically take **0.2** and multiply it by that **0.0547,** and that gives us the **covariance**. When we think about the returns of Bubsy, the returns of the market index there is a covariance of this which is 0.0109333.

## Calculation of Variance of Market Index

Now, remember it was covariance divided by the variance will give us the beta, so we have to calculate the variance, and to get that, what we need, are the **squared deviation**. Now, remember, we’re just doing the variance of the market index. So we’re going to take the squared deviations from the mean. So we do the squared deviations of the market and then we sum it up. Here’s our sum.

This is if we add all this **squared deviation** together and we get **0.29533333 **and then we divide that by **n minus 1**. In each case, you say “Why do I have **n minus 1?**” and this is because we’re doing a sample of the returns this is not the true population of the sample so that’s why we’re subtracting** 1 **instead of just dividing by** n**. So, we take **0.29533333** and divide by **n minus 1** where** n** **is 6,** again because there are six months or six observations. So we have **6 minus 1**. So we’ve **0.29533333** divided by **5** and that’s going to give us the variance. So the variance of the market index of returns is **0.0059067**.

## Calculation of Beta

Now we have the covariance of Bubsy and the market. So, their returns that covariance, and then we have the variance of the market index. So we take covariance, and we divide it by that variance, and that’s going to give us our beta. So, we had our formula, the covariance of the two returns together, divided by the variance of the market index. So, we plag the numbers in the formula from what we calculated. Then that’s going to give us a beta of **1.851**. So you think about it like this if the market index were to go up by **1%** we would expect that Bubsy stock would go up by 1.851.