Last active
December 16, 2015 18:26
-
-
Save jpicerno1/f8307d0c14cc39d25c53 to your computer and use it in GitHub Desktop.
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
# R code re: CapitalSpecator.com post on designing a simple probit model: | |
# "A (Partial) Solution For Narrative Risk: Probit Modeling" | |
# http://www.capitalspectator.com/a-partial-solution-for-narrative-risk-probit-modeling/ | |
# 15 Dec 2015 | |
# By James Picerno | |
# http://www.capitalspectator.com/ | |
# (c) 2015 by Beta Publishing LLC | |
# load packages | |
library(TTR) | |
library(quantmod) | |
library(TTR) | |
library(zoo) | |
library(tseries) | |
# download data | |
sp500 <-get.hist.quote(instrument="^GSPC", | |
start="1950-12-31", | |
quote="AdjClose") | |
vix <-get.hist.quote(instrument="^VIX",quote="Close") | |
# generate rolling 1yr S&P returns | |
sp.252 <-na.omit(ROC(sp500,252,"discrete")) | |
# merge S&P and VIX data | |
vix.sp252 <-as.xts(na.omit(cbind(vix,sp.252))) | |
colnames(vix.sp252) <-c("vix","sp.252") | |
# generate signal data | |
sp.sig <-ifelse(vix.sp252[,2] <0,1,0) | |
# add VIX to signal data file | |
sp.sig$sp252 <-vix.sp252[,1] | |
colnames(sp.sig) <-c("sp.sig","vix") | |
# generate probit model | |
probit.model <-glm(sp.sig~vix,family=binomial(link="probit"),data=sp.sig) | |
probit.model.f <-predict(probit.model ,type="response") | |
# END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment