I want to compute a series of out of sample forecasts. I need to run a quantile regression that uses the first 20 quarters of data and produces a forecast, stores the last observation from the series, which is the forecast and then re-runs the quantile regression using 21 quarters of data to produce a new forecast for the next quarter, then 22 quarters of data and so on.
I tried using a loop to expand the 'window' for ts data but I can't get the loop to work.
I then tried using xts data but I'm having the same problem
quarters1 <- c(0,3,2,1,0,3,2,1)
years1 <- c(2,1,1,1,1,0,0,0)
dates1 <- cbind(years1, quarters1)
for (i in 1:nrow(dates1)) {
window(flows, start(flows), (end(flows) - dates1[i,1:2]))
window(rhsflows, start(rhsflows), (end(rhsflows) - dates1[i,1:2]))
window(bbb, start(bbb), (end(bbb) - dates1[i,1:2]))
window(yield, start(yield), (end(yield) - dates1[i,1:2]))
window(usd, start(usd), (end(usd) - dates1[i,1:2]))
window(gdp, start(gdp), (end(gdp) - dates1[i,1:2]))
vg_qt <- dynrq(flows ~ L(rhsflows, nlag) + bbb + yield + usd + gdp, tau = tau_vec, method = "br")
dyhat_qt <- predict(vg_qt)
colnames(dyhat_qt) <- tau_vec
dyhat_qt <- ts(data = dyhat_qt, start = forecastflowsbegin, frequency = ts_freq)
dyhat_qt1 <- tail(dyhat_qt,1)
dyhat_qt_oos <- rbind(dyhat_qt_oos, c(dyhat_qt1))
}
I expect the rows of dyhat_qt_oos to be different but they are all the same