I tried to repeat the predictability of regression (trying to get predictions one step ahead) by introducing rolling regression and calculating and fixing the difference between the estimate and the last available day, for each day in the past, in the column.
I tried applying Christoph_J's answer in rolling regression returns multiple objects
There is no syntax error in the code. However, I am not sure if there is a semantic error. Is the value in row i of the predicted column a preliminary prediction of the value of row i of the OpCl column?
library(zoo) library(dynlm) library(quantmod) sp <- getSymbols("^GSPC", auto.assign=FALSE) sp$GSPC.Adjusted <- NULL colnames(sp) <- gsub("^GSPC\\.","",colnames(sp)) sp$Number<-NA sp$Number<-1:nrow(sp) sp$OpCl <- OpCl(sp) sp$ClHi <- HiCl(sp) sp$LoCl <- LoCl(sp) sp$LoHi <- LoHi(sp)
source share