Rolling window forecast

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. In particular, it's hard to reproduce an issue without representative data.

Forecasting Principles and Practice has a brief discussion of moving average forecasts (not the same a moving average smoothing).

The h argument to forecast can take a range ahead based on the fit of the data. It would seem, therefore, in order to generate n period-ahead forecasts, it would be necessary first to generate n fits.

I'd prefer to do this by mapping, rather than looping, using purrr:map I'd first write a function to generate the fits by successively subsetting data.xts, taking as its argument seq(1445:nrow(data.xts) and then another function to do the fit, taking as its argument the successive fits.

The resulting object from the first function, say fits would be fed to the second function, say aheads with

purrr:map(fit,heads)