I have been wanting to do this analysis for some time, and I always seem to be interrupted. I want to stress that I still need to validate my findings but they kind of gel with my intuition. [I have included my R code below]
GDP | S&P | S&P -1 | S&P -2 | |
GDP correlation | 100% | 2.67% | 17.43% | 24.04% |
Adj. R Square | -0.30% | 2.65% | 5.41% |
Ok so what do we have here. Every time we get a GDP release, ignore the revisions and all the noise around the announcement for this exercise, people straight away extrapolate its effect on the stock market, i.e. a high GDP growth rate will correlate with a high quarterly performance . In our study we simply want to know what the correlation coefficient is of the S&P500 and the quarterly GDP growth figure. As you can see it is very low there is a 2.67% correlation (one of my questions to investigate is the GDP data is annualized quarterly data, whereas the S&P500 is simply quarterly so this could be a factor. The adjusted R2 is totally insignificant.
What is noticeable and quite significant is if you lag the performance of the S&P500 by 1 and 2 quarters you get a statistically significant relationship. So a 2 quarter lag is even better than 1, which in my mind makes sense, that the benefits to the market filter through slowly. These are rough workings and will require more input from me.
Postscript: just been thinking about it in the steamshower. GDP numbers are released roughly a quarter after the fact so the observation that the same quarters have no correlation actually makes sense. Something else to add is that I am going to do the study on raw quarterly data as well to see if this increases the correlation and R2 I think it will
library(quantmod) library(Quandl) #Getting data from Quandl GDP<- Quandl("FRED/GDP", trim_start="1947-01-01", trim_end="2014-07-01", transformation="rdiff", authcode="kvYEqCqKCTyL4anWz5Zv", type = "xts") SP500<- Quandl("YAHOO/INDEX_GSPC", trim_start="1950-01-03", trim_end="2014-11-21", authcode="kvYEqCqKCTyL4anWz5Zv", type = "xts") #need to make SP500 data quartetly using the quantmod function. SP.q<- quarterlyReturn(SP500[,6], subset=NULL, type='arithmetic', leading=FALSE) #cleaning up and aligning the data frame, I know this is fuzzy logic I am a novice coder df1<- merge(GDP,SP.q) df2<- merge(lag(df1[,1], k=1),df1) m<- merge(df2[,1],df2[,3]) mt<- na.omit(m) mb<- lag(mt[,2],k=1) mc<- lag(mt[,2],k=2) mt<- cbind(mt,mb,mc) mt<- na.omit(mt) colnames(mt) <- c("GDP", "S&P", "S&P -1", "S&P -2") head(mt) #regression analysis regression<- lm(mt[,1] ~ mt[,2]) #lagging S&P500 by 1 quarter regression1<- lm(mt[,1] ~ mt[,3]) #lagging S&P500 by 2 quarter regression2<- lm(mt[,1] ~ mt[,4]) #statistical analysis cor(mt)*100 summary(regression)$adj.r.squared *100 summary(regression1)$adj.r.squared *100 summary(regression2)$adj.r.squared *100 #plotting regressions plot(regression) plot(regression1) plot(regression2)
Created by Pretty R at inside-R.org