Wikipedia / Autoregressive model
Wikipedia / Autoregressive model
In statistics, an autoregressive (AR) model is a modelled representation of a type of random process. It can be used to describe time-varying processes from many natural and artificial sources. The model specifies output variables that are dependent linearly on their own previous values on a stochastic basis. 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.
Another important extension is the time-varying autoregressive (TVAR) model, where the autoregressive coefficients are allowed to change over time to model evolving or non-stationary processes. TVAR models are widely applied in cases where the underlying dynamics of the system are not constant, such as in sensors time series modelling, climate science, economics and finance (as econometrics), signal processing, telecommunications, radar systems, and biological signals.
Unlike the moving-average (MA) model, the autoregressive model is not always stationary; non-stationarity can arise either due to the presence of a unit root or due to time-varying model parameters, as in time-varying autoregressive models.
Large language models are called autoregressive, but they are not a classical autoregressive model in this sense because they are not linear.
Definition
indicates an autoregressive model of order p. The AR(p) model is defined as
are the parameters is white noise. This can be equivalently written using the backshift operator B as
so that, moving the summation term to the left side and using polynomial notation, we have
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 are not stationary. More generally, for an AR(p must lie outside the unit circle (see pages 89,92 ).
Intertemporal effect of shocks
at say time t 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
(where the constant term has been suppressed by assuming that the variable has been measured as deviations from its mean) as
When the polynomial division appear on the right side of the equation.
Characteristic polynomial
The autocorrelation function of an AR(p) process can be expressed as
are the roots of the polynomial
where B is the backshift operator 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.
Each real root contributes a component to the autocorrelation function that decays exponentially.
Similarly, each pair of complex conjugate roots contributes an exponentially damped oscillation.
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.
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.
is negative, then the process favors changes in sign between terms of the process. The output oscillates. This can be linked to edge detection or detection of change in direction.
Example: An AR(1) process
has been dropped.) The process is weak-sense stationary depends on time lag t, so that the variance of the series diverges to infinity as t is identical for all values of tand hence
The variance is
. This can be shown by noting that
and then by noticing that the quantity above is a stable fixed point of this relation.
The autocovariance is given by
It can be seen that the autocovariance function decays with a decay time (also called time constant.
The spectral density function is the Fourier transform of the autocovariance function. In discrete terms this will be the discrete-time Fourier transform:
:
which yields a Lorentzian profile for the spectral density:
.
in the defining equation. Continuing this process N times yields
For N will approach zero and:
is a Gaussian process is also a Gaussian process. In other cases, the central limit theorem is close to one.
will be a geometric progression (exponential 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, is given by
.
, one can show that
and
Choosing the maximum lag
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
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, are the following set of equations.
where , yielding is the autocovariance function of Xt 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
The remaining equation for m = 0 is
An alternative formulation is in terms of the autocorrelation function. The AR parameters are determined by the first p of the autocorrelation function. The full autocorrelation function can then be derived by recursively calculating
Examples for some Low-order AR(p) processes
p=1
p=2
The Yule–Walker equations for an AR(2) process are
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. Some of these variants can be described as follows:
Estimation of autocovariances or autocorrelations. Here each of these terms is estimated separately, using conventional estimates. There are different ways of doing this and the choice between these affects the properties of the estimation scheme. For example, negative estimates of the variance can be produced by some choices.
Formulation as a least squares regression problem in which an ordinary least squares prediction problem is constructed, basing prediction of values of Xt on the p previous values of the same series. This can be thought of as a forward-prediction scheme. The normal equations for this problem can be seen to correspond to an approximation of the matrix form of the Yule–Walker equations in which each appearance of an autocovariance of the same lag is replaced by a slightly different estimate.
Formulation as an extended form of ordinary least squares prediction problem. Here two sets of prediction equations are combined into a single estimation scheme and a single set of normal equations. One set is the set of forward-prediction equations and the other is a corresponding set of backward prediction equations, relating to the backward representation of the AR model:
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 is
AR(0)
For white noise (AR(0))
AR(1)
For AR(1)
, often referred to as red noise 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.
, 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:
or equivalently by the poles of its transfer function, which is defined in the Z domain by:
It follows that the poles are values of z satisfying:
which yields:
are the reciprocals of the characteristic roots, as well as the eigenvalues of the temporal update matrix:
AR(2) processes can be split into three groups depending on the characteristics of their roots/poles:
, the process has a pair of complex-conjugate poles, creating a mid-frequency peak at:
with bandwidth about the peak inversely proportional to the moduli of the poles:
.
Otherwise the process has real roots, and:
.
.
The full PSD function can be expressed in real form as:
Implementations in statistics packages
R – the stats package includes ar function; the astsa package includes sarima function to fit various models including AR.
MATLAB – the Econometrics Toolbox and System Identification Toolbox include AR models.
MATLAB and Octave – the TSA toolbox contains several estimation functions for uni-variate, multivariate, and adaptive AR models.
PyMC3 – the Bayesian statistics and probabilistic programming framework supports AR modes with p lags.
bayesloop – supports parameter inference and model selection for the AR-1 process with time-varying parameters.
Python – statsmodels.org hosts an AR model.
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
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 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.
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
PagedAttention / vAttention — attention algorithms for efficient serving of large language models
Notes
References
External links
AutoRegression Analysis (AR) by Paul Bourke
by Mark Thoma