Time Series Forecasting for Retail Sales
Build an R analysis that forecasts future retail sales from past monthly sales. You'll use a real public dataset (for example US retail sales from FRED), look at its trend and seasonal patterns, then fit two classic forecasting models, ARIMA and exponential smoothing (ETS), and check which one predicts better by testing both on the last year of data they haven't seen. The final result is a report with charts of the forecasts and their uncertainty ranges, and a clear recommendation. You'll learn time series in R: ts objects, decomposition, stationarity tests with tseries, fitting models with the forecast package, train/test splits for time series, and accuracy measures like RMSE and MAPE.
- Estimate
- ~11.5h
- Steps
- 7
- Completed by
- 0
- Proposed by
- codeseed.app
forecast · tseries · ggplot2
Project roadmap
- 01
Load the data as a time series
~1.5hDownload a monthly retail sales series with at least 8 years of data, for example FRED series RSXFSN, as CSV into data/. Read it, check that no months are missing, fill small gaps with na.interp if needed, and convert it to a ts object with frequency = 12 and the correct start year and month. Done when: plotting the ts object with autoplot shows the full series with correct dates on the x axis.
- 02
Explore trend and seasonality
~2hDecompose the series with stl into trend, seasonal and remainder, and plot the result. Make a seasonal plot (ggseasonplot) to compare months across years. Run an ADF test with tseries::adf.test on the series and on its differences, and write down in the script what they say about stationarity. Done when: the decomposition and seasonal plots are saved, and the test results are explained in comments.
- 03
Split into training and test sets
~1hKeep the last 12 months as the test set with window() and use everything before it for training. Explain in a comment why time series can't be split randomly like other data. Done when: the train and test objects exist, and the test set is exactly the last 12 months.
- 04
Fit ARIMA and ETS models
~2hFit auto.arima and ets on the training data only. Print each chosen model and check the residuals with checkresiduals: they should look like random noise, with no pattern left. Write down the model each function chose and whether the residuals look acceptable. Done when: both models are fitted and their residual checks are saved.
- 05
Compare forecast accuracy
~1.5hForecast 12 months ahead with both models and compare them with the test set using accuracy(), focusing on RMSE and MAPE. Also include a seasonal naive forecast (snaive) as a baseline, since a good model should beat it. Put the three results in one table. Done when: the comparison table shows all three methods, and the best one is identified.
- 06
Plot the forecasts
~1.5hPlot the training data, the actual test values and each model's forecast with its 80% and 95% prediction intervals, using autoplot and autolayer from the forecast package with ggplot2. Save the charts to output/. Done when: the charts clearly show how each forecast compares with what actually happened.
- 07
Forecast the future and write the report
~2hRefit the best model on the full series and forecast the next 12 months beyond the data. Put the whole analysis into an R Markdown or Quarto report: data source, exploration, model comparison, final forecast with intervals, and a short recommendation with limitations. Done when: rendering the report from a fresh R session produces the complete HTML report.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack