Created
September 20, 2011 18:31
-
-
Save zachmayer/1229899 to your computer and use it in GitHub Desktop.
Recessions III
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Load current know recessions | |
library(xts) | |
ModRec <- read.csv("http://dl.dropbox.com/u/7428423/Modified%20NBER%20Recession%20Data.csv") | |
ModRec$DATE <- as.Date(ModRec$DATE) | |
ModRec <- xts(ModRec[,-1],order.by=ModRec[,1]) | |
#Load actual recessions | |
library(quantmod) | |
getSymbols('USREC',src='FRED') | |
#Check that actual recession values from the 2 datasets match | |
Check <- as.data.frame(cbind(ModRec,USREC)) | |
all.equal(Check[,'VALUE'],Check[,'USREC']) | |
#Compare naive forecast to actuals | |
library(caret) | |
ModRec <- ModRec["1997-07-01::",] #Start from same period as Hussman's model | |
naiveforecast <- Lag(ModRec[,'MODIFIED.VALUE'],1) | |
actual <- ModRec[,'VALUE'] | |
compare <- na.omit(merge(naiveforecast,actual)) | |
confusionMatrix(compare[,1],compare[,2],positive = '1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment