# Trying to replicate the Beta of Yahoo in R but am getting an answer that is way off

Yahoo calculates the Beta by using 3 years of monthly returns and using the S&P 500 as a market proxy but I cannot seem to replicate this or even get close using R. I downloaded the data from Yahoo from 12/01/2014 to 12/01/2017 for NKE and GSPC and take the adjusted closing price (either that or just closing price they both should at least be fairly close to the beta if the calculation is done correctly). Then I do the following

>nikeAC = nike$Adj.Close >spAC = sp$Adj.Close
> niker = rep(0,36)
>
> for (i in 1:36){
+     niker[i] = (nikeAC[i+1]-nikeAC[i])/nikeAC[i]
+ }
>
> spr = rep(0,36)
>
> for (i in 1:36){
+     spr[i] = (spAC[i+1]-spAC[i])/spAC[i]
+ }
> cov(spr,niker)/var(spr)

and get an output of -1.21 when the Beta is supposed to be around .54. I would also like to add that they don't use an adjusted Beta so I should be getting something close to .54 as I've checked other sites and they seem to be within the .54 -.64 range generally.

• Are you using the last 36 days or the last 36 months? – noob2 Dec 21 '17 at 7:21
• Last 36 months, under the Historical Data tab you can have Yahoo display the "Monthly" data – Dmitriy Dec 21 '17 at 7:56
• Is that indexing correct? You are asking for spAC[37]. – dm63 Dec 21 '17 at 9:29
• Hmm... I did the calculation by hand with Excel, . I got Covar=-0.00103, Var= 0.000852 and $\beta$=-1.213 like you did. The prices of NKE look a little wierd, did it really go to 109 in 8/1/2015 and then 59.66 in 9/1/2015 ? Without that datapoint it would be more reasonable. – noob2 Dec 21 '17 at 9:46