Help with basic forecasting

Hi everyone,

I'm getting to grips with R and I've done a few tutorials and followed a number of how to guides, and now I'm getting started with my own data.

This has been my process so far. Installed forcast, and then:

library(forecast)
y <- ts(c(1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,3,4,5,4,3,2,1), start=2021)
autoplot(y, xlab = "Month", ylab = "Chart Title")

(I've removed the numbers I'm using, so the above is an example)

And I've tried a number of ways, but all the guides use dummy data and I can't get it to plot forecast models. Even similar BSTS, I'm struggling with ggplot2 aspects.

If anyone could help me with what I need to do next, I'd be very grategul

Please clarify where in the process you are having difficulties. "I can't get it to plot forecast models" suggests that you ARE able to estimate time series models and use them to generate forecasts, but just cannot plot the forecasts with ggplot2. However, the code you provide to illustrate your process simply creates a time series and plots it with the autoplot() function from the forecast package.

BTW, your code creates an example time series with annual data from 2021 to 2043. Did you mean for this to be monthly (as suggested by your axis label) from January 2021 to November 2022? If so, it should be

y <- ts(c(1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,3,4,5,4,3,2,1), start = c(2021, 1), frequency = 12)

Because you are using the forecast package created by Rob Hyndman, I suggest you look at Forecasting: Principles and Practice (2nd edition), which he co-authored.

You should also be aware that while the forecast package is still supported, new features are not being added. He and his team have created a new set of packages for forecasting, which they call the tidyverts (tidyverse for time series). The tidyverts is covered in the third edition of the book. I switched my forecasting class to the tidyverts in 2019.

The fpp3 package and accompanying free text will get you everything needed to go from beginner to intermediate level skills in a well organized process. For one thing, there’s an autoplot() for simple plots.