My current code is this:
Model <- head(rollapplyr(z, width = 131, function(x)
fitted(lm(y ~x1+ x2, data = as.data.frame(x))), by.column = FALSE)[,131],3429)
I would like to do this:
fit1 <- lm(y ~x1+ x2)
Model <- head(rollapplyr(z, width = 131, function(x) fitted(fit1),
data = as.data.frame(x))), by.column = FALSE)[,131],3429)
Basically, I'm just trying to sub in fit1
for the regression equation, but I keep getting an error. Any help would be much appreciated.