Loading tsb runtime…

← back to tsb playground

ARIMA

ARIMA(p, d, q) time-series model — estimation, forecasting, and prediction intervals. Mirrors statsmodels.tsa.arima.model.ARIMA.

1 — Fit an AR(1) model

new ARIMAModel({ p, d, q }) constructs the model; .fit(y) estimates the parameters using the Hannan-Rissanen two-step method and returns coefficients, sigma², AIC, and BIC.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

2 — Multi-step forecast with prediction intervals

model.forecast(steps) returns point forecasts and 95 % prediction intervals computed via ψ-weight recursion.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

3 — ARMA(1,1) model

Combine AR and MA terms. ARMA(1,1): x_t = φ x_{t−1} + θ ε_{t−1} + ε_t.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

4 — ARIMA(1,1,0): integrated series

Set d=1 for I(1) series (random walk, stock prices, etc.). The model differences the series before fitting.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

5 — fitArima convenience function

fitArima(y, opts) is a one-liner shorthand for constructing and fitting an ARIMA model.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent