4 ms·
I don't know how hard did you look, but taking for example the two stocks that you mentioned (MSFT and PG) and the ex-dividend dates since 2007 it's easy to see
by kgwgk 10y ago
I don't know how hard did you look, but taking for example the two stocks that you mentioned (MSFT and PG) and the ex-dividend dates since 2007 it's easy to see that there is an effect. The mean return for those dates is -0.5% for MSFT (vs. +0.05% for the market) and -1.0% for PG (vs. +0.1% for the market). Doing a regression of stock returns on market returns you will find that the result is statistically significant (p<0.001). R code follows:
library(quantmod)
getSymbols(c("MSFT","PG","SPY"))
msft.ex=index(quantmod::getDividends("MSFT")["2007::"])
pg.ex=index(quantmod::getDividends("PG")["2007::"])
msft.rets=as.data.frame(merge(dailyReturn(MSFT$MSFT.Close)[msft.ex],dailyReturn(SPY$SPY.Close)[msft.ex]))
colnames(msft.rets)=c("MSFT","SPY")
msft.fit=lm(MSFT~SPY,msft.rets)
summary(msft.fit)
confint(msft.fit)
pg.rets=as.data.frame(merge(dailyReturn(PG$PG.Close)[pg.ex],dailyReturn(SPY$SPY.Close)[pg.ex]))
colnames(pg.rets)=c("PG","SPY")
pg.fit=lm(PG~SPY,pg.rets)
summary(pg.fit)
confint(pg.fit)
par(mfrow=c(1,2))
plot(msft.rets$SPY,msft.rets$MSFT,xlim=c(-0.08,0.08),ylim=c(-0.08,0.08))
abline(msft.fit,col="red")
grid()
plot(pg.rets$SPY,pg.rets$PG,xlim=c(-0.08,0.08),ylim=c(-0.08,0.08))
abline(pg.fit,col="red")
grid()
- mywittyname 10y agoI stand corrected, thank you.
- kgwgk 10y agoYou are welcome. It was an interesting exercise.
- mywittyname 10y agoDo you happen to have any good resources for learning R? I've always put it on the back burner but it looks like it has some amazing libraries for extracting data and now I'm keen to look into it more.
- kgwgk 10y agoI guess it depends on your background and field of interest. Maybe this helps: http://r4ds.had.co.nz http://r4ds.had.co.nz But note it's a blind recommendation, I didn't know about this particular book before. I found a long list of books here: http://blog.revolutionanalytics.com/2015/11/r-recommended-reading.html http://blog.revolutionanalytics.com/2015/11/r-recommended-re...