In an attempt to branch out and see what other people do in terms of work, I’ve been creating a model for the Student Investment Club to simultaneously forecast GDP, CPI, and Unemployment. While such a prediction is clearly overly ambitious for a casual effort, I made an attempt at it using some basic methodologies. The dependent variables that I used in this case were guided by the preferences of the group, rather than by any particular theoretical model. As such, I have very little faith in the model to be a powerful predictor on a fundamental level, but I do expect it to be correlated with the actual values.

Attached is my presentation (5-10 minutes) about my preliminary forecasts and findings. It is meant to be delivered to a nontechnical audience and is meant to be a partial (but not complete) disclosure of the problems with my approach. Below is a version of the model I am using to make such a forecast, with some admittedly sparse commentary.

library(tseries)

library(quantmod)

library(systemfit)

# Old work functions as a great key

# gdp<-getSymbols(‘GDPC1′,src=’FRED’)

# indp<-getSymbols(‘INDPRO’, src=’FRED’)

# ism<-getSymbols(‘NAPM’, src=’FRED’)

# cap<-getSymbols(‘TCU’,src=’FRED’)

# wage<-getSymbols(‘AHETPI’,src=’FRED’) #Productivity? Proxy:wages

# ppi<-getSymbols(‘PPIACO’,src=’FRED’)

# unemploy<-U1RATENSA

# libor<-USDONTD156N

#

# cpi<-getSymbols(‘CPIAUCSL’,src=’FRED’)

# nom_pers_inc<-getSymbols(‘PINCOME’,src=’FRED’) #this might need to be real

# senti<-getSymbols(‘UMCSENT’,src=’FRED’)

# #demand<-getSymbols(‘DEMOTHCONS’,src=’FRED’)#Consumer demand? Proxy: request for more loans

# #cpi<-getSymbols(‘TCU’,src=’FRED’) #Total sales? Proxy: Change in buisness inventories

#Get the data

out<-NULL

b_names<-c(“GDPC1″,”INDPRO”,”NAPM”,”TCU”,”AHETPI”,”PPIACO”,”CPIAUCSL”,”PINCOME”,”UMCSENT”,”FEDFUNDS”,”U1RATENSA”)

getSymbols(b_names,src=’FRED’)

b<-list(GDPC1,INDPRO,NAPM,TCU,AHETPI,PPIACO,CPIAUCSL,PINCOME,UMCSENT,FEDFUNDS,U1RATENSA)

FEDFUNDS<-na.exclude(FEDFUNDS)

out<-lapply(b, aggregate, by=as.yearqtr, mean)

# Scale it appropriately.

series<-lapply(out,window,start=as.yearqtr(“2000 Q1″), end=as.yearqtr(“2013 Q1″))#trims to a consistant window.

series<-lapply(series,cbind)

series<-data.frame(series)

names(series)<-b_names

series<-log(series) #log the series

series<-as.ts(series) #need time series for this following operator:

series<-diff.ts(series[,c(“GDPC1″,”INDPRO”,”TCU”,”AHETPI”,”PPIACO”,”CPIAUCSL”,”PINCOME”,”UMCSENT”,”FEDFUNDS”,”U1RATENSA”)]) #first difference

lagGDP<-series[,”GDPC1″]

lagCPI<-series[,”CPIAUCSL”]

lagUNEMP<-series[,”U1RATENSA”]

series<-data.frame(series) #back to df

series$NAPM<-matrix(NAPM[(dim(NAPM)[1]+2-dim(series)[1]):dim(NAPM)[1]]) #Some may be stationary!

series$lvl_UMCSENT<-matrix(UMCSENT[(dim(UMCSENT)[1]+2-dim(series)[1]):dim(UMCSENT)[1]])

series$lvl_TCU<-matrix(TCU[(dim(TCU)[1]+2-dim(series)[1]):dim(TCU)[1]])

series$lvl_NAPM<-matrix(NAPM[(dim(NAPM)[1]+2-dim(series)[1]):dim(NAPM)[1]])

series$lvl_FEDFUNDS<-matrix(FEDFUNDS[(dim(FEDFUNDS)[1]+2-dim(series)[1]):dim(FEDFUNDS)[1]])

series$t.index<-zooreg(series, start=as.yearqtr(“2000 Q1″),end=as.yearqtr(“2013 Q1″), frequency = 4) #need a time trend

series$quarter<-as.vector(seq(from=1,to=4, by=1))

# series$PINCOME_2<-(series$PINCOME)^2 #are these acceptable?

# series$GDPC_2<-(series$GDPC1)^2

series_hold<-data.frame(series)

# documentation http://cran.r-project.org/web/packages/systemfit/vignettes/systemfit.pdf

series$Lead_GDPC1<-lag(zoo(lagGDP),k=+2, na.pad=TRUE)

series$Lead_CPIAUCSL<-lag(zoo(lagCPI),k=+2, na.pad=TRUE)

series$Lead_U1RATENSA<-lag(zoo(lagUNEMP),k=+2, na.pad=TRUE) #impact takes at least 2 quarters. This is needed because we are missing CPI numbers for last quarter. Sentiment is delayed 6 months as propietary information. If it is set to +2, the estimates are to see what it would be like if we had the current info (pay for it).

eq1<- Lead_GDPC1 ~ INDPRO + lvl_NAPM + lvl_UMCSENT + GDPC1 + TCU + CPIAUCSL + FEDFUNDS + U1RATENSA + factor(quarter)

eq2<- Lead_CPIAUCSL ~ INDPRO + lvl_NAPM + lvl_UMCSENT + GDPC1 + TCU + CPIAUCSL + FEDFUNDS + U1RATENSA + factor(quarter)

eq3<- Lead_U1RATENSA ~ INDPRO + lvl_NAPM + lvl_UMCSENT + GDPC1 + TCU + CPIAUCSL + FEDFUNDS + U1RATENSA + factor(quarter)

eqsystem<-list(GDP=eq1,CPI=eq2,UNEMP=eq3)

# series<-data.frame(series)

fit<-systemfit(eqsystem, method=”SUR”, data=series)

pred<-predict(fit,series, se.pred=TRUE)

pred_ci<-predict(fit, series, interval=”confidence”, level=0.95) #note events are not normal.

plot(series$GDPC1, type=”l”, col=”darkgreen”, ylab=”% Change in GDP”, xlab=”Quarters (since 2000)”, main=”GDP forecast”) #the dimseries -40 gets me 10years.

points(pred[1], type=”l”, col=”blue”, lty=5)

points(pred_ci[,c(3)],type=”l”, col=”red”, lty=2)

points(pred_ci[,c(2)],type=”l”, col=”red”, lty=2)

legend(x=”bottomleft”,c(“Green= Actual GDP”,”Red= 95% CI”,”Blue=Forecast”), cex=0.90)

plot(series$CPIAUCSL, type=”l”, col=”darkgreen”, ylab=”% Change in CPI”, xlab=”Quarters (since 2000)”,main=”CPI forecast”)

points(pred[3], type=”l”, col=”blue”, lty=5)

points(pred_ci[,5],type=”l”, col=”red”, lty=2)

points(pred_ci[,6],type=”l”, col=”red”, lty=2)

legend(x=”bottomleft”,c(“Green= Actual GDP”,”Red= 95% CI”,”Blue=Forecast”), cex=0.90)

plot(series$U1RATENSA, type=”l”, col=”darkgreen”, ylab=”% Change in UNEMP”, xlab=”Quarters (since 2000)”, main=”UNEMP forecast”)

points(pred[5], type=”l”, col=”blue”, lty=5)

points(pred_ci[,8],type=”l”, col=”red”, lty=2)

points(pred_ci[,9],type=”l”, col=”red”, lty=2)

legend(x=”bottomleft”,c(“Green= Actual GDP”,”Red= 95% CI”,”Blue=Forecast”), cex=0.90)

summary(fit)

tail(pred)

pred<-rbind(0,rbind(0,pred))

pred_ci<-rbind(0,rbind(0,pred_ci))

tail(series[c(“CPIAUCSL”,”GDPC1″,”U1RATENSA”)])