Question

I would like to calculate the beta of stocks to the S&P. In one sheet I have data about a stock called VNM and in another about an S&P 500 index, the SPY. I am trying to calculate the beta according to this formula:

Beta = COVAR(VNM,SPY)/VAR(SPY)

The code I think should work is

=COVAR(VNM!$H$2:INDEX(VNM!$H$2:$H$1000000,MATCH(9E+99+307,VNM!$H$2:VNM!$H$1000000)),SPY!$H$2:INDEX(SPY!$H$2:$H$1000000,MATCH(9E+99+307,SPY!$H$2:SPY!$H$1000000)))/VAR(SPY!$H$2:INDEX(SPY!$H$2:$H$1000000,MATCH(9.99E+307,SPY!$H$2:SPY!$H$1000000)))

However, this gives me an error in Excel. Does anyone have an idea?

Was it helpful?

Solution

All you need to do to calculate the Beta of the data below is put this into the cell you want the result in:

=COVARIANCE.S(B2:B19,C2:C19)/VAR.S(C2:C19)

This is with Excel 2013 which gives you a choice between Sample or Population Covariance and Variance. I've done it with Sample here.

(This is just for a few days for an example, so the resulting Beta of 0.204 will be pretty inaccurate):

EDIT: (Just realised the dates are messed up because I didn't format Column A correctly, but the method described is still fine as a model).

+----+--------------+-------+--------+
|    |      A       |   B   |   C    |
+----+--------------+-------+--------+
|  1 | DATE         | VNM   | SPY    |
|  2 | Feb 10, 2014 | 21.7  | 180.01 |
|  3 | Feb 11, 2014 | 22.05 | 181.98 |
|  4 | Feb 12, 2014 | 22.42 | 182.07 |
|  5 | Feb 13, 2014 | 22.85 | 183.01 |
|  6 | Feb 14, 2014 | 22.24 | 184.02 |
|  7 | Feb 18, 2014 | 22.55 | 184.24 |
|  8 | Feb 19, 2014 | 22.45 | 183.02 |
|  9 | Feb 3, 2014  | 20.9  | 174.17 |
| 10 | Feb 4, 2014  | 21.11 | 175.38 |
| 11 | Feb 5, 2014  | 21.22 | 175.17 |
| 12 | Feb 6, 2014  | 20.76 | 177.48 |
| 13 | Feb 7, 2014  | 20.75 | 179.68 |
| 14 | Jan 24, 2014 | 20.35 | 178.89 |
| 15 | Jan 27, 2014 | 20.53 | 178.01 |
| 16 | Jan 28, 2014 | 20.91 | 179.07 |
| 17 | Jan 29, 2014 | 20.76 | 177.35 |
| 18 | Jan 30, 2014 | 21.31 | 179.23 |
| 19 | Jan 31, 2014 | 21.07 | 178.18 |
+----+--------------+-------+--------+

OTHER TIPS

I can’t comment on your choice of functions but with them there seems nothing wrong with your syntax, though a slightly shorter version seems adequate, here split into its components:

=COVAR(VNM!$H$2:INDEX(VNM!$H$2:$H$1000000,MATCH(1E+100,VNM!$H$2:$H$1000000)),
       SPY!$H$2:INDEX(SPY!$H$2:$H$1000000,MATCH(1E+100,SPY!$H$2:$H$1000000))
      )
/
   VAR(SPY!$H$2:INDEX(SPY!$H$2:$H$1000000,MATCH(1E+100,SPY!$H$2:$H$1000000)))

The error seem likely either #DIV/0! if either of the arrays is empty (mischoice of column reference perhaps?) or #N/A, which can be caused by different number of data points in the two series. Since the formula determines the series as from Row2 to the last occupied cell in ColumnH in each case I suggest checking that the bottom of each list is in the same row number for each, perhaps with Home > Editing – Find & Select, Go To Special…, Last Cell (depending upon what else is in each sheet however).

|  0 | DATE         | VNM   | SPY    |          
|  1 | Feb 19, 2014 | 22.45 | 183.02 |          
|  2 | Feb 18, 2014 | 22.55 | 184.24 |          
|  3 | Feb 14, 2014 | 22.24 | 184.02 |          
|  4 | Feb 13, 2014 | 22.85 | 183.01 |          
|  5 | Feb 12, 2014 | 22.42 | 182.07 |          
|  6 | Feb 11, 2014 | 22.05 | 181.98 |          
|  7 | Feb 10, 2014 | 21.7  | 180.01 |          
| 08 | Feb 7, 2014  | 20.75 | 179.68 |          
| 09 | Feb 6, 2014  | 20.76 | 177.48 |          
| 10 | Feb 5, 2014  | 21.22 | 175.17 |          
| 11 | Feb 4, 2014  | 21.11 | 175.38 |          
| 12 | Feb 3, 2014  | 20.9  | 174.17 |          
| 13 | Jan 31, 2014 | 21.07 | 178.18 |          
| 14 | Jan 30, 2014 | 21.31 | 179.23 |          
| 15 | Jan 29, 2014 | 20.76 | 177.35 |          
| 16 | Jan 28, 2014 | 20.91 | 179.07 |          
| 17 | Jan 27, 2014 | 20.53 | 178.01 |          
| 18 | Jan 24, 2014 | 20.35 | 178.89 |          


VNM     SPY    RETURN SPY   RETURN VNM
               (X-axis)     (Y-axis)
22.45   183.02  -0.00662    -0.00443
22.55   184.24  0.001196    0.013939
22.24   184.02  0.005519    -0.0267
22.85   183.01  0.005163    0.019179
22.42   182.07  0.000495    0.01678
22.05   181.98  0.010944    0.016129
21.7    180.01  0.001837    0.045783
20.75   179.68  0.012396    -0.00048
20.76   177.48  0.013187    -0.02168
21.22   175.17  -0.0012     0.005211
21.11   175.38  0.006947    0.010048
20.9    174.17  -0.02251    -0.00807
21.07   178.18  -0.00586    -0.01126
21.31   179.23  0.010601    0.026493
20.76   177.35  -0.00961    -0.00717
20.91   179.07  0.005955    0.018509
20.53   178.01  -0.00492    0.008845
20.35   178.89  #DIV/0!     #DIV/0

Beta = =slope(y's axis data, x's axis data) ...Use function from Excel =slope(

 = 0.4088
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top