Lesson 7 of 15
ARMA(p,q) Model
ARMA(p,q) Model
The ARMA(p,q) model combines AR and MA components:
y[t] = φ₁·y[t-1] + ... + φp·y[t-p] + ε[t] + θ₁·ε[t-1] + ... + θq·ε[t-q]
It is one of the most widely used models in time series analysis. ARMA models require stationarity — for non-stationary series, we use ARIMA (which adds differencing).
Simulation
To simulate ARMA(p,q), initialize with xs_init values and pad past errors with zeros. At each step:
- AR part: weighted sum of last
py-values - MA part: current error plus weighted sum of last
qerrors - New value = AR part + MA part
One-step Forecast
For forecasting, the future error is 0 (expectation):
ŷ[t+1] = φ₁·y[t] + ... + φp·y[t-p+1] + θ₁·ε[t] + ... + θq·ε[t-q+1]
Task
Implement:
arma_simulate(xs_init, phi, theta, errors, n)arma_forecast(xs, errors, phi, theta)
Python runtime loading...
Loading...
Click "Run" to execute your code.