Explanation 1
The live starter code is self-contained and uses only runner-compatible functions.
Loading
Lesson 12 of 22
Follow an auditable specify–estimate–diagnose–forecast–evaluate loop.
Motivation
ARIMA is useful only when preprocessing, candidate comparison, residual diagnostics, and out-of-sample scoring use information available at the forecast origin.
Why this matters
Follow an auditable specify–estimate–diagnose–forecast–evaluate loop.
Packages and data
Base stats; forecast 9.0.2 and fable 0.5.0 are optional extensions.
Explanation 1
The live starter code is self-contained and uses only runner-compatible functions.
Explanation 2
Book-only outputs are labelled when the separate source dataset or advanced package was not supplied.
Explanation 3
R code, paths, function names, and formulas remain left-to-right in every locale.
Terminology
Transforms levels to changes to address stochastic trend.
Avoid unnecessary differencing
One-step error after conditioning on the past.
Residuals approximate innovations
Later observations reserved from fitting.
Preserve time order
Notation and formulas
phi(B)(1-B)^d yt = c + theta(B) error_t
ARIMA combines differencing with autoregressive and moving-average dependence.
Worked example
Scenario
Does a compact ARIMA forecast improve on the training endpoint for a simulated series?
R check
set.seed(1212)
y <- cumsum(arima.sim(list(ar=.45), n=96))
train <- head(y,-12); test <- tail(y,12)
fit <- arima(train, order=c(1,1,1), method='ML')
fc <- predict(fit,n.ahead=12)
print(sqrt(mean((test-fc$pred)^2)))
print(Box.test(residuals(fit),lag=12,type='Ljung-Box',fitdf=2))A small p-value signals residual dependence in that book specification rather than a result to hide. Limitation: One holdout origin is uncertain; rolling origins and naive benchmarks provide stronger evidence.
Visual
Intervals widen with horizon in a typical model-based forecast.
R connection
Run the self-contained starter code in the protected STATLAB R runner. The code prints an auditable result and avoids network or unrestricted file access.
Live R Lab
Run a self-contained example, verify its output, and explain one limitation for arima estimation, diagnostics, and forecasting.
Ready to run
Common mistake
A 95% prediction interval is conditional on the model, not a 95% guarantee.
STATLAB Tip
Always include a transparent naive benchmark.
Guided practice
Scenario
Compare ARIMA(0,1,1) and ARIMA(2,1,0) using AIC, residual ACF, and holdout error.
Compare your result with the definition, units, and model assumptions—not only with a target number.
Exercises
Complete these without looking at the selected solutions. More than one defensible program may exist.
Explanation 1
Calculate MAE.
Explanation 2
Construct 80% intervals.
Explanation 3
Design a rolling-origin table.
Selected solutions
These are compact solution routes. Confirm dimensions, units, and any changed modelling choices.
Explanation 1
mean(abs(test-fc$pred))
Explanation 2
fc$pred + c(-1,1)*qnorm(.90)*fc$se for each horizon
Explanation 3
Store origin, horizon, actual, forecast, and error without future leakage.
Chapter summary
Follow an auditable specify–estimate–diagnose–forecast–evaluate loop.
Explanation 1
ARIMA combines differencing and lag dependence.
Explanation 2
Information criteria only compare candidates.
Explanation 3
Forecast uncertainty is model-conditional.
Explanation 4
Time-ordered evaluation is essential.
Terminology
fit model
Use in ARIMA Estimation, Diagnostics, and Forecasting.
compare fit
Use in ARIMA Estimation, Diagnostics, and Forecasting.
forecast
Use in ARIMA Estimation, Diagnostics, and Forecasting.
diagnose residuals
Use in ARIMA Estimation, Diagnostics, and Forecasting.
References and provenance
Safavi (2026), Chapter 12. Student notes: Mohammad Safavi, Ph.D., STATLAB Academy, Version 1.0.
Resource
The authoritative 125-page English PDF accompanies this native lesson.
DownloadReflection
Name the assumption, evidence you would seek, and how the recommendation might change.
Exit check
Reach 70% to complete the chapter. Explanations appear after submission.
Checkpoint
Question 1 of 2. Answered 0/2. Passing score: 70%.