Skip to content

Instantly share code, notes, and snippets.

@zachmayer
Created August 22, 2011 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachmayer/1162717 to your computer and use it in GitHub Desktop.
Save zachmayer/1162717 to your computer and use it in GitHub Desktop.
Recession forecasting II- Hussman's Accuracy
#Actual Recessions
getSymbols('USREC',src='FRED')
USREC <- USREC["1997-07-01::",] #Start from same period
#Compare recession now to warning last month
library(caret)
OneMonth <- Lag(P.Rec)
compare <- na.omit(merge(OneMonth,USREC))
confusionMatrix(compare[,1],compare[,2],positive = '1')
#Compare recession now to warning in last 6 months
SixMonth <- sign(apply.daily(Lag(P.Rec,1:6), sum))
compare <- na.omit(merge(SixMonth,USREC))
confusionMatrix(compare[,1],compare[,2],positive = '1')
#Compare recession now to Recession last month
library(caret)
OneMonth <- Lag(USREC)
compare <- na.omit(merge(OneMonth,USREC))
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