Lesson 8 of 15
ARIMA Forecast
ARIMA(p,d,q) Forecast
ARIMA (AutoRegressive Integrated Moving Average) extends ARMA to handle non-stationary series by differencing d times before applying ARMA.
The workflow:
- Difference the series
dtimes → get a stationary differenced series - Forecast the differenced series using AR(p) (for simplicity, assuming zero noise and no MA term in future steps)
- Undifference the forecasts back to the original scale
Forecasting Steps
Given series xs, parameters p, d, q, AR coefficients phi, and steps ahead n_ahead:
- Compute
dxs = difference(xs, d) - For each future step, forecast next differenced value:
ŷ_diff = Σ φⱼ · dxs[-(j+1)] - Append forecast to
dxs(iterating forward) - Undifference:
last = xs[-1], thenlast += fdfor each forecasted difference
Task
Implement arima_forecast(xs, p, d, q, phi, theta, n_ahead) that returns a list of n_ahead forecasted values.
Python runtime loading...
Loading...
Click "Run" to execute your code.