データの準備
TERM <- "1972::2024-02"
merge(g20=diff(cli_g20)[TERM],usa=diff(cli_usa)[TERM],g7=diff(cli_g7)[TERM])-> w
merge(w,nfci=as.vector(diff(to.monthly(NFCI)[,4])[TERM]),spx=as.vector(monthlyReturn(GSPC)[TERM])) -> w
w<-last(w,120)
# r <- (lm(w$spx ~ poly(w$nfci,3,raw=T) + w$g20))
r <- (lm(spx ~ poly(nfci,3,raw=T) + g20,data.frame(w)))
p1 <- as.vector(last(diff(NFCI,4)))
p2<- as.vector(last(diff(cli_g20)))+as.vector(last(diff(diff(cli_g20))))
predict(r,newdata=data.frame(nfci=p1,g20=p2),interval='prediction',level=0.95)
cbind(w,predict=as.vector(predict(r))) -> w
r
summary(r)
# matplot(index(w),w[,5:6],type="h",lwd=2)
matplot(index(w),w[,5:6],type="h",lwd=c(3,2),lty=c(1,3))
abline(v=seq(as.Date("2013-12-15"),Sys.Date(),by='years'),lty=2)
2023/12時点での回帰分析
当該月データの推計