Autoregressive model explained

In statistics, econometrics, and signal processing, an autoregressive (AR) model is a representation of a type of random process; as such, it can be used to describe certain time-varying processes in nature, economics, behavior, etc. The autoregressive model specifies that the output variable depends linearly on its own previous values and on a stochastic term (an imperfectly predictable term); thus the model is in the form of a stochastic difference equation (or recurrence relation) which should not be confused with a differential equation. Together with the moving-average (MA) model, it is a special case and key component of the more general autoregressive–moving-average (ARMA) and autoregressive integrated moving average (ARIMA) models of time series, which have a more complicated stochastic structure; it is also a special case of the vector autoregressive model (VAR), which consists of a system of more than one interlocking stochastic difference equation in more than one evolving random variable.

Contrary to the moving-average (MA) model, the autoregressive model is not always stationary as it may contain a unit root.

Large language models are called autoregressive, but they are not a classical autoregressive model in this sense because they are not linear.

Definition

The notation

AR(p)

indicates an autoregressive model of order p. The AR(p) model is defined as

Xt=

p
\sum
i=1

\varphiiXt-i+\varepsilont

where

\varphi1,\ldots,\varphip

are the parameters of the model, and

\varepsilont

is white noise.[1] [2] This can be equivalently written using the backshift operator B as

Xt=

p
\sum
i=1

\varphiiBiXt+\varepsilont

so that, moving the summation term to the left side and using polynomial notation, we have

\phi[B]Xt=\varepsilont

An autoregressive model can thus be viewed as the output of an all-pole infinite impulse response filter whose input is white noise.

Some parameter constraints are necessary for the model to remain weak-sense stationary. For example, processes in the AR(1) model with

|\varphi1|\geq1

are not stationary. More generally, for an AR(p) model to be weak-sense stationary, the roots of the polynomial

\Phi(z):=style1-

p
\sum
i=1

\varphiizi

must lie outside the unit circle, i.e., each (complex) root

zi

must satisfy

|zi|>1

(see pages 89,92 [3]).

Intertemporal effect of shocks

In an AR process, a one-time shock affects values of the evolving variable infinitely far into the future. For example, consider the AR(1) model

Xt=\varphi1Xt-1+\varepsilont

. A non-zero value for

\varepsilont

at say time t=1 affects

X1

by the amount

\varepsilon1

. Then by the AR equation for

X2

in terms of

X1

, this affects

X2

by the amount

\varphi1\varepsilon1

. Then by the AR equation for

X3

in terms of

X2

, this affects

X3

by the amount
2
\varphi
1

\varepsilon1

. Continuing this process shows that the effect of

\varepsilon1

never ends, although if the process is stationary then the effect diminishes toward zero in the limit.

Because each shock affects X values infinitely far into the future from when they occur, any given value Xt is affected by shocks occurring infinitely far into the past. This can also be seen by rewriting the autoregression

\phi(B)Xt=\varepsilont

(where the constant term has been suppressed by assuming that the variable has been measured as deviations from its mean) as

Xt=

1
\phi(B)

\varepsilont.

When the polynomial division on the right side is carried out, the polynomial in the backshift operator applied to

\varepsilont

has an infinite order—that is, an infinite number of lagged values of

\varepsilont

appear on the right side of the equation.

Characteristic polynomial

The autocorrelation function of an AR(p) process can be expressed as

\rho(\tau)=

p
\sum
k=1

ak

-|\tau|
y
k

,

where

yk

are the roots of the polynomial

\phi(B)=1-

p
\sum
k=1

\varphikBk

where B is the backshift operator, where

\phi()

is the function defining the autoregression, and where

\varphik

are the coefficients in the autoregression. The formula is valid only if all the roots have multiplicity 1.

The autocorrelation function of an AR(p) process is a sum of decaying exponentials.

Graphs of AR(p) processes

The simplest AR process is AR(0), which has no dependence between the terms. Only the error/innovation/noise term contributes to the output of the process, so in the figure, AR(0) corresponds to white noise.

For an AR(1) process with a positive

\varphi

, only the previous term in the process and the noise term contribute to the output. If

\varphi

is close to 0, then the process still looks like white noise, but as

\varphi

approaches 1, the output gets a larger contribution from the previous term relative to the noise. This results in a "smoothing" or integration of the output, similar to a low pass filter.

For an AR(2) process, the previous two terms and the noise term contribute to the output. If both

\varphi1

and

\varphi2

are positive, the output will resemble a low pass filter, with the high frequency part of the noise decreased. If

\varphi1

is positive while

\varphi2

is negative, then the process favors changes in sign between terms of the process. The output oscillates. This can be likened to edge detection or detection of change in direction.

Example: An AR(1) process

An AR(1) process is given by:X_t = \varphi X_+\varepsilon_t\,where

\varepsilont

is a white noise process with zero mean and constant variance
2
\sigma
\varepsilon
.(Note: The subscript on

\varphi1

has been dropped.) The process is weak-sense stationary if

|\varphi|<1

since it is obtained as the output of a stable filter whose input is white noise. (If

\varphi=1

then the variance of

Xt

depends on time lag t, so that the variance of the series diverges to infinity as t goes to infinity, and is therefore not weak sense stationary.) Assuming

|\varphi|<1

, the mean

\operatorname{E}(Xt)

is identical for all values of t by the very definition of weak sense stationarity. If the mean is denoted by

\mu

, it follows from\operatorname (X_t)=\varphi\operatorname (X_)+\operatorname(\varepsilon_t),that \mu=\varphi\mu+0,and hence

\mu=0.

The variance is

rm{var}(Xt)=\operatorname{E}(X

2)-\mu
t
2=
2
\sigma
\varepsilon
1-\varphi2

,

where

\sigma\varepsilon

is the standard deviation of

\varepsilont

. This can be shown by noting that

rm{var}(Xt)=

2rm{var}(X
\varphi
t-1

)+

2,
\sigma
\varepsilon
and then by noticing that the quantity above is a stable fixed point of this relation.

The autocovariance is given by

Bn=\operatorname{E}(Xt+n

2=
2
\sigma
\varepsilon
1-\varphi2
X
t)-\mu

\varphi|n|.

It can be seen that the autocovariance function decays with a decay time (also called time constant) of

\tau=1-\varphi

.[4]

The spectral density function is the Fourier transform of the autocovariance function. In discrete terms this will be the discrete-time Fourier transform:

\Phi(\omega)= 1
\sqrt{2\pi
}\,\sum_^\infty B_n e^=\frac\,\left(\frac\right).

This expression is periodic due to the discrete nature of the

Xj

, which is manifested as the cosine term in the denominator. If we assume that the sampling time (

\Deltat=1

) is much smaller than the decay time (

\tau

), then we can use a continuum approximation to

Bn

:

B(t)

2
\sigma
\varepsilon
1-\varphi2

\varphi|t|

which yields a Lorentzian profile for the spectral density:

\Phi(\omega)= 1
\sqrt{2\pi
}\,\frac\,\frac

where

\gamma=1/\tau

is the angular frequency associated with the decay time

\tau

.

An alternative expression for

Xt

can be derived by first substituting

\varphiXt-2+\varepsilont-1

for

Xt-1

in the defining equation. Continuing this process N times yields
NX
X
t-N
N-1
+\sum
k=0
k\varepsilon
\varphi
t-k

.

For N approaching infinity,

\varphiN

will approach zero and:

Xt=\sum

infty\varphi
k=0
k\varepsilon
t-k

.

It is seen that

Xt

is white noise convolved with the

\varphik

kernel plus the constant mean. If the white noise

\varepsilont

is a Gaussian process then

Xt

is also a Gaussian process. In other cases, the central limit theorem indicates that

Xt

will be approximately normally distributed when

\varphi

is close to one.

For

\varepsilont=0

, the process

Xt=\varphiXt-1

will be a geometric progression (exponential growth or decay). In this case, the solution can be found analytically:

Xt=a\varphit

whereby

a

is an unknown constant (initial condition).

Explicit mean/difference form of AR(1) process

The AR(1) model is the discrete-time analogy of the continuous Ornstein-Uhlenbeck process. It is therefore sometimes useful to understand the properties of the AR(1) model cast in an equivalent form. In this form, the AR(1) model, with process parameter

\theta\inR

, is given by

Xt+1=Xt+(1-\theta)(\mu-Xt)+\varepsilont+1

, where

|\theta|<1

,

\mu:=E(X)

is the model mean, and

\{\epsilont\}

is a white-noise process with zero mean and constant variance

\sigma

.

By rewriting this as

Xt+1=\thetaXt+(1-\theta)\mu+\varepsilont+1

and then deriving (by induction)

Xt+n=\thetanXt+(1-\thetan)\mu+

n
\Sigma
i=1

\left(\thetan\epsilont\right)

, one can show that

\operatorname{E}(Xt+n|Xt)=\mu\left[1-\thetan\right]+

n
X
t\theta
and

\operatorname{Var}(Xt+n|Xt)=\sigma2

1-\theta2n
1-\theta2
.

Choosing the maximum lag

See main article: Partial autocorrelation function.

The partial autocorrelation of an AR(p) process equals zero at lags larger than p, so the appropriate maximum lag p is the one after which the partial autocorrelations are all zero.

Calculation of the AR parameters

There are many ways to estimate the coefficients, such as the ordinary least squares procedure or method of moments (through Yule–Walker equations).

The AR(p) model is given by the equation

Xt=

p
\sum
i=1

\varphiiXt-i+\varepsilont.

It is based on parameters

\varphii

where i = 1, ..., p. There is a direct correspondence between these parameters and the covariance function of the process, and this correspondence can be inverted to determine the parameters from the autocorrelation function (which is itself obtained from the covariances). This is done using the Yule–Walker equations.

Yule–Walker equations

The Yule–Walker equations, named for Udny Yule and Gilbert Walker,[5] [6] are the following set of equations.[7]

\gammam=

p
\sum
k=1

\varphik\gammam-k+

2\delta
\sigma
m,0

,

where, yielding equations. Here

\gammam

is the autocovariance function of Xt,

\sigma\varepsilon

is the standard deviation of the input noise process, and

\deltam,0

is the Kronecker delta function.

Because the last part of an individual equation is non-zero only if, the set of equations can be solved by representing the equations for in matrix form, thus getting the equation

\begin{bmatrix} \gamma1\\ \gamma2\\ \gamma3\\ \vdots\\ \gammap\\ \end{bmatrix} = \begin{bmatrix} \gamma0&\gamma-1&\gamma-2&\\ \gamma1&\gamma0&\gamma-1&\\ \gamma2&\gamma1&\gamma0&\\ \vdots&\vdots&\vdots&\ddots\\ \gammap-1&\gammap-2&\gammap-3&\\ \end{bmatrix} \begin{bmatrix} \varphi1\\ \varphi2\\ \varphi3\\ \vdots\\ \varphip\\ \end{bmatrix}

which can be solved for all

\{\varphim;m=1,2,...,p\}.

The remaining equation for m = 0 is

\gamma0=

p
\sum
k=1

\varphik\gamma-k+

2
\sigma
\varepsilon

,

which, once

\{\varphim;m=1,2,...,p\}

are known, can be solved for
2
\sigma
\varepsilon

.

An alternative formulation is in terms of the autocorrelation function. The AR parameters are determined by the first p+1 elements

\rho(\tau)

of the autocorrelation function. The full autocorrelation function can then be derived by recursively calculating[8]

\rho(\tau)=

p
\sum
k=1

\varphik\rho(k-\tau)

Examples for some Low-order AR(p) processes

\gamma1=\varphi1\gamma0

\rho1=\gamma1/\gamma0=\varphi1

\gamma1=\varphi1\gamma0+\varphi2\gamma-1

\gamma2=\varphi1\gamma1+\varphi2\gamma0

\gamma-k=\gammak

\rho1=\gamma1/\gamma0=

\varphi1
1-\varphi2

\rho2=\gamma2/\gamma0=

2
\varphi-
2
\varphi
2
+\varphi2
1
1-\varphi2

Estimation of AR parameters

The above equations (the Yule–Walker equations) provide several routes to estimating the parameters of an AR(p) model, by replacing the theoretical covariances with estimated values.[9] Some of these variants can be described as follows:

Xt=

p
\sum
i=1

\varphiiXt+i+

*
\varepsilon
t

.

Here predicted values of Xt would be based on the p future values of the same series. This way of estimating the AR parameters is due to John Parker Burg, and is called the Burg method: Burg and later authors called these particular estimates "maximum entropy estimates", but the reasoning behind this applies to the use of any set of estimated AR parameters. Compared to the estimation scheme using only the forward prediction equations, different estimates of the autocovariances are produced, and the estimates have different stability properties. Burg estimates are particularly associated with maximum entropy spectral estimation.

Other possible approaches to estimation include maximum likelihood estimation. Two distinct variants of maximum likelihood are available: in one (broadly equivalent to the forward prediction least squares scheme) the likelihood function considered is that corresponding to the conditional distribution of later values in the series given the initial p values in the series; in the second, the likelihood function considered is that corresponding to the unconditional joint distribution of all the values in the observed series. Substantial differences in the results of these approaches can occur if the observed series is short, or if the process is close to non-stationarity.

Spectrum

The power spectral density (PSD) of an AR(p) process with noise variance

Var(Zt)=

2
\sigma
Z
is[8]

S(f)=

2
\sigma
Z
|
p
1-\sum
k=1
\varphike-i|2

.

AR(0)

For white noise (AR(0))

S(f)=

2.
\sigma
Z

AR(1)

For AR(1)

S(f)=

2
\sigma
Z
|1-\varphi1e-2|2

=

2
\sigma
Z
1+
2
\varphi
1
-2\varphi1\cos2\pif

\varphi1>0

there is a single spectral peak at f=0, often referred to as red noise. As

\varphi1

becomes nearer 1, there is stronger power at low frequencies, i.e. larger time lags. This is then a low-pass filter, when applied to full spectrum light, everything except for the red light will be filtered.

\varphi1<0

there is a minimum at f=0, often referred to as blue noise. This similarly acts as a high-pass filter, everything except for blue light will be filtered.

AR(2)

The behavior of an AR(2) process is determined entirely by the roots of it characteristic equation, which is expressed in terms of the lag operator as:

1-\varphi1B-\varphi2B2=0,

or equivalently by the poles of its transfer function, which is defined in the Z domain by:

Hz=(1-\varphi1z-1-\varphi2z-2)-1.

It follows that the poles are values of z satisfying:

1-\varphi1z-1-\varphi2z-2=0

,

which yields:

z1,z2=

1
2\varphi2

\left(\varphi1\pm

2
\sqrt{\varphi
1

+4\varphi2}\right)

.

z1

and

z2

are the reciprocals of the characteristic roots, as well as the eigenvalues of the temporal update matrix:

\begin{bmatrix}\varphi1&\varphi2\ 1&0\end{bmatrix}

AR(2) processes can be split into three groups depending on the characteristics of their roots/poles:

2
\varphi
1

+4\varphi2<0

, the process has a pair of complex-conjugate poles, creating a mid-frequency peak at:

f*=

1
2\pi

\cos-1\left(

\varphi1
2\sqrt{-\varphi2
}\right),

with bandwidth about the peak inversely proportional to the moduli of the poles:

|z1|=|z2|=\sqrt{-\varphi2}.

The terms involving square roots are all real in the case of complex poles since they exist only when

\varphi2<0

.

Otherwise the process has real roots, and:

\varphi1>0

it acts as a low-pass filter on the white noise with a spectral peak at

f=0

\varphi1<0

it acts as a high-pass filter on the white noise with a spectral peak at

f=1/2

.The process is non-stationary when the poles are on or outside the unit circle, or equivalently when the characteristic roots are on or inside the unit circle.The process is stable when the poles are strictly within the unit circle (roots strictly outside the unit circle), or equivalently when the coefficients are in the triangle

-1\le\varphi2\le1-|\varphi1|

.

The full PSD function can be expressed in real form as:

S(f)=

2
\sigma
Z
1+
2
\varphi
1
+
2
\varphi
2
-2\varphi1(1-\varphi2)\cos(2\pif)-2\varphi2\cos(4\pif)

Implementations in statistics packages

implementation in statsmodels.[16]

Impulse response

The impulse response of a system is the change in an evolving variable in response to a change in the value of a shock term k periods earlier, as a function of k. Since the AR model is a special case of the vector autoregressive model, the computation of the impulse response in vector autoregression#impulse response applies here.

n-step-ahead forecasting

Once the parameters of the autoregression

Xt=

p
\sum
i=1

\varphiiXt-i+\varepsilont

have been estimated, the autoregression can be used to forecast an arbitrary number of periods into the future. First use t to refer to the first period for which data is not yet available; substitute the known preceding values Xt-i for i=1, ..., p into the autoregressive equation while setting the error term

\varepsilont

equal to zero (because we forecast Xt to equal its expected value, and the expected value of the unobserved error term is zero). The output of the autoregressive equation is the forecast for the first unobserved period. Next, use t to refer to the next period for which data is not yet available; again the autoregressive equation is used to make the forecast, with one difference: the value of X one period prior to the one now being forecast is not known, so its expected value—the predicted value arising from the previous forecasting step—is used instead. Then for future periods the same procedure is used, each time using one more forecast value on the right side of the predictive equation until, after p predictions, all p right-side values are predicted values from preceding steps.

There are four sources of uncertainty regarding predictions obtained in this manner: (1) uncertainty as to whether the autoregressive model is the correct model; (2) uncertainty about the accuracy of the forecasted values that are used as lagged values in the right side of the autoregressive equation; (3) uncertainty about the true values of the autoregressive coefficients; and (4) uncertainty about the value of the error term

\varepsilont

for the period being predicted. Each of the last three can be quantified and combined to give a confidence interval for the n-step-ahead predictions; the confidence interval will become wider as n increases because of the use of an increasing number of estimated values for the right-side variables.

See also

References

External links

Notes and References

  1. Book: Box, George E. P. . Time series analysis : forecasting and control . 1994 . Prentice Hall . Gwilym M. Jenkins, Gregory C. Reinsel . 0-13-060774-6 . 3rd . Englewood Cliffs, N.J. . 54 . en . 28888762.
  2. Book: Shumway, Robert H. . Time series analysis and its applications . 2000 . Springer . David S. Stoffer . 0-387-98950-1 . New York . 90–91 . en . 42392178 . 2022-09-03 . 2023-04-16 . https://web.archive.org/web/20230416160928/https://www.worldcat.org/title/42392178 . live .
  3. Book: Shumway . Robert H. . Stoffer . David . Time series analysis and its applications : with R examples . 2010 . Springer . 978-1441978646 . 3rd.
  4. Lai, Dihui; and Lu, Bingfeng; "Understanding Autoregressive Model for Time Series as a Deterministic Dynamic System", in Predictive Analytics and Futurism, June 2017, number 15, June 2017, pages 7-9
  5. Yule, G. Udny (1927) "On a Method of Investigating Periodicities in Disturbed Series, with Special Reference to Wolfer's Sunspot Numbers", Philosophical Transactions of the Royal Society of London, Ser. A, Vol. 226, 267–298.
  6. Walker, Gilbert (1931) "On Periodicity in Series of Related Terms", Proceedings of the Royal Society of London, Ser. A, Vol. 131, 518–532.
  7. Book: Theodoridis, Sergios . Machine Learning: A Bayesian and Optimization Perspective . Academic Press, 2015 . Chapter 1. Probability and Stochastic Processes . 9–51 . 978-0-12-801522-3 . 2015-04-10 .
  8. Book: Von Storch , Hans . Cambridge University Press. 0-521-01230-9. Francis W. . Zwiers. Statistical analysis in climate research. 2001. 10.1017/CBO9780511612336.
  9. Web site: The Yule Walker Equations for the AR Coefficients . Eshel . Gidon . stat.wharton.upenn.edu . 2019-01-27 . 2018-07-13 . https://web.archive.org/web/20180713135223/http://www-stat.wharton.upenn.edu/~steele/Courses/956/Resource/YWSourceFiles/YW-Eshel.pdf . live .
  10. http://finzi.psych.upenn.edu/R/library/stats/html/ar.html "Fit Autoregressive Models to Time Series"
  11. Web site: Econometrics Toolbox . www.mathworks.com . 2022-02-16 . 2023-04-16 . https://web.archive.org/web/20230416160907/https://www.mathworks.com/products/econometrics.html . live .
  12. Web site: System Identification Toolbox . www.mathworks.com . 2022-02-16 . 2022-02-16 . https://web.archive.org/web/20220216063519/https://www.mathworks.com/products/sysid.html . live .
  13. Web site: Autoregressive Model - MATLAB & Simulink . www.mathworks.com . 2022-02-16 . 2022-02-16 . https://web.archive.org/web/20220216063648/https://www.mathworks.com/help/econ/autoregressive-model.html . live .
  14. Web site: The Time Series Analysis (TSA) toolbox for Octave and Matlab® . pub.ist.ac.at . 2012-04-03 . 2012-05-11 . https://web.archive.org/web/20120511144225/http://pub.ist.ac.at/~schloegl/matlab/tsa/ . live .
  15. Web site: christophmark/bayesloop . December 7, 2021 . GitHub . September 4, 2018 . September 28, 2020 . https://web.archive.org/web/20200928085417/https://github.com/christophmark/bayesloop . live .
  16. Web site: statsmodels.tsa.ar_model.AutoReg — statsmodels 0.12.2 documentation . www.statsmodels.org . 2021-04-29 . 2021-02-28 . https://web.archive.org/web/20210228123354/https://www.statsmodels.org/stable/generated/statsmodels.tsa.ar_model.AutoReg.html . live .