My Shiller Model

I had a quick look at my trusted Shiller Model which actually went to cash mid October this year. It continues to suggest holding onto cash. I attach the r code I used to build it, and I can apologize in advance for my sloppy coding, but it does most of the job. I plan on cleaning the code up in the near future.

Rplot05 Rplot04

# I am pulling the data from Quandl and the MULTPL dataset. 
multpl<- read.csv('', colClasses=c('Date'='Date'))
snp<- read.csv('', colClasses=c('Date'='Date'))
date<- snp$Date
values<- snp[,2]
snp.obj<- as.xts(values, = as.Date(date, "%d/%m/%Y"))
snprets<- ROC(snp.obj, type = "discrete", n = 1)
date<- multpl$Date
values<- multpl[,2]
PE.obj<- as.xts(values, = as.Date(date, "%d/%m/%Y"))
Shiller<- merge(snp.obj,PE.obj, snprets)
Shiller.sub = Shiller['1900-01-01::']
colnames(Shiller.sub) = c('S&P500','Shiller PE','S&P500 returns')
mean<- rollapply(PE.obj,48,mean)
sdsig<- rollapply(PE.obj,48,sd) + mean
over<- Lag(ifelse(PE.obj> sdsig,1,0))
pe_ret <- snprets * over
PEtimer<- cbind(pe_ret,snprets) 
colnames(PEtimer) = c('PE-Timer','Buy&Hold')
grid.newpage(recording = FALSE)
grid.newpage(recording = FALSE)
grid.table(table.AnnualizedReturns(PEtimer, Rf=0))
table.AnnualizedReturns(PEtimer, Rf= 0)
charts.PerformanceSummary(PEtimer, Rf = 0, main="Shiller PE Timer",geometric=FALSE)

Created by Pretty R at

One thought on “My Shiller Model

  1. Pingback: Operating Earnings Extrapolation & The Butterfly Effect | Sefirot Capital

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s