Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Autoregressive (AR) Models | Mathematical Foundations of ARIMA
Time Series Forecasting with ARIMA

bookAutoregressive (AR) Models

Autoregressive (AR) models form the foundation of many time series forecasting techniques by capturing how past values in a sequence influence its future values. The key intuition is that observations in a time series are often correlated with their own previous values—meaning the past can help predict the future. In an AR model, you use a linear combination of previous observations, known as lagged variables, to estimate the current value. The simplest form, an AR(1)AR(1) model, predicts the current value based solely on the immediately preceding value. More generally, an AR(p)AR(p) model uses the previous p values.

Mathematically, an AR(p)AR(p) model is represented as:

Xt=c+ϕ1Xt1+ϕ2Xt2++ϕpXtp+ϵtX_t = c + \phi_1 X_{t-1} + \phi_2 X_{t-2} + \cdots + \phi_p X_{t-p} + \epsilon_t

where:

  • XtX_t is the value at time tt;
  • cc is a constant;
  • ϕ1,...,ϕp\phi₁, ..., \phiₚ are the model coefficients;
  • εtε_t is white noise (random error at time tt).

This approach allows you to model the persistence and memory within a time series, which is especially useful in fields like finance, economics, and signal processing.

Note
Definition

Lag refers to how many time steps back you look in the series. For instance, a lag of 1 means using the value from one time point before the current one.

Note
Definition

Order in AR models, denoted as pp in AR(p)AR(p), specifies how many lagged values are included. An AR(1)AR(1) model uses one lag, AR(2)AR(2) uses two, and so on.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt # Set random seed for reproducibility np.random.seed(42) # Parameters for AR(1): X_t = 0.7 * X_{t-1} + noise phi = 0.7 n = 100 noise = np.random.normal(0, 1, n) X = np.zeros(n) # Simulate AR(1) process for t in range(1, n): X[t] = phi * X[t-1] + noise[t] # Plot the simulated series plt.figure(figsize=(10, 4)) plt.plot(X, label="Simulated AR(1) Process") plt.xlabel("Time") plt.ylabel("Value") plt.title("Simulation of an AR(1) Time Series") plt.legend() plt.tight_layout() plt.show()
copy
question mark

What does the "order" (p) in an AR(p) model represent?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 1

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Can you explain what the AR(1) process is doing in this code?

How would I modify this code for an AR(2) model?

What does the plot of the simulated AR(1) process tell us?

Awesome!

Completion rate improved to 6.67

bookAutoregressive (AR) Models

Sveip for å vise menyen

Autoregressive (AR) models form the foundation of many time series forecasting techniques by capturing how past values in a sequence influence its future values. The key intuition is that observations in a time series are often correlated with their own previous values—meaning the past can help predict the future. In an AR model, you use a linear combination of previous observations, known as lagged variables, to estimate the current value. The simplest form, an AR(1)AR(1) model, predicts the current value based solely on the immediately preceding value. More generally, an AR(p)AR(p) model uses the previous p values.

Mathematically, an AR(p)AR(p) model is represented as:

Xt=c+ϕ1Xt1+ϕ2Xt2++ϕpXtp+ϵtX_t = c + \phi_1 X_{t-1} + \phi_2 X_{t-2} + \cdots + \phi_p X_{t-p} + \epsilon_t

where:

  • XtX_t is the value at time tt;
  • cc is a constant;
  • ϕ1,...,ϕp\phi₁, ..., \phiₚ are the model coefficients;
  • εtε_t is white noise (random error at time tt).

This approach allows you to model the persistence and memory within a time series, which is especially useful in fields like finance, economics, and signal processing.

Note
Definition

Lag refers to how many time steps back you look in the series. For instance, a lag of 1 means using the value from one time point before the current one.

Note
Definition

Order in AR models, denoted as pp in AR(p)AR(p), specifies how many lagged values are included. An AR(1)AR(1) model uses one lag, AR(2)AR(2) uses two, and so on.

12345678910111213141516171819202122232425
import numpy as np import matplotlib.pyplot as plt # Set random seed for reproducibility np.random.seed(42) # Parameters for AR(1): X_t = 0.7 * X_{t-1} + noise phi = 0.7 n = 100 noise = np.random.normal(0, 1, n) X = np.zeros(n) # Simulate AR(1) process for t in range(1, n): X[t] = phi * X[t-1] + noise[t] # Plot the simulated series plt.figure(figsize=(10, 4)) plt.plot(X, label="Simulated AR(1) Process") plt.xlabel("Time") plt.ylabel("Value") plt.title("Simulation of an AR(1) Time Series") plt.legend() plt.tight_layout() plt.show()
copy
question mark

What does the "order" (p) in an AR(p) model represent?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 1
some-alt