Search code examples
rtime-seriesforecasting

R forecast - How to plot only subset?


I'm fitting a model with the R forecast package like this:

    fit <- auto.arima(df) 
    plot(forecast(fit,h=200))

Which prints the original data frame plus the forecast. This becomes a problem when df is quite big, as it's hard to visualise what the forecast looks like. I would like to be able to select only the last X points from the whole series (original + forecast).


Solution

  • You can include X observations of the original series in your plot with:

    plot(forecast(fit, h=200), include = X)
    

    You can see additional documentation with:

    ?plot.forecast