<s>
In	O
statistics	O
,	O
econometrics	O
and	O
signal	O
processing	O
,	O
an	O
autoregressive	B-Algorithm
(	O
AR	O
)	O
model	O
is	O
a	O
representation	O
of	O
a	O
type	O
of	O
random	O
process	O
;	O
as	O
such	O
,	O
it	O
is	O
used	O
to	O
describe	O
certain	O
time-varying	O
processes	O
in	O
nature	O
,	O
economics	O
,	O
behavior	O
,	O
etc	O
.	O
</s>
<s>
The	O
autoregressive	B-Algorithm
model	I-Algorithm
specifies	O
that	O
the	O
output	O
variable	O
depends	O
linearly	O
on	O
its	O
own	O
previous	O
values	O
and	O
on	O
a	O
stochastic	B-Algorithm
term	I-Algorithm
(	O
an	O
imperfectly	O
predictable	O
term	O
)	O
;	O
thus	O
the	O
model	O
is	O
in	O
the	O
form	O
of	O
a	O
stochastic	B-Algorithm
difference	I-Algorithm
equation	I-Algorithm
(	O
or	O
recurrence	O
relation	O
which	O
should	O
not	O
be	O
confused	O
with	O
differential	O
equation	O
)	O
.	O
</s>
<s>
Together	O
with	O
the	O
moving-average	O
(	O
MA	O
)	O
model	O
,	O
it	O
is	O
a	O
special	O
case	O
and	O
key	O
component	O
of	O
the	O
more	O
general	O
autoregressive	B-Algorithm
–	O
moving-average	O
(	O
ARMA	O
)	O
and	O
autoregressive	B-Algorithm
integrated	O
moving	O
average	O
(	O
ARIMA	O
)	O
models	O
of	O
time	O
series	O
,	O
which	O
have	O
a	O
more	O
complicated	O
stochastic	O
structure	O
;	O
it	O
is	O
also	O
a	O
special	O
case	O
of	O
the	O
vector	O
autoregressive	B-Algorithm
model	I-Algorithm
(	O
VAR	O
)	O
,	O
which	O
consists	O
of	O
a	O
system	O
of	O
more	O
than	O
one	O
interlocking	O
stochastic	B-Algorithm
difference	I-Algorithm
equation	I-Algorithm
in	O
more	O
than	O
one	O
evolving	O
random	O
variable	O
.	O
</s>
<s>
Contrary	O
to	O
the	O
moving-average	O
(	O
MA	O
)	O
model	O
,	O
the	O
autoregressive	B-Algorithm
model	I-Algorithm
is	O
not	O
always	O
stationary	B-Algorithm
as	O
it	O
may	O
contain	O
a	O
unit	O
root	O
.	O
</s>
<s>
An	O
autoregressive	B-Algorithm
model	I-Algorithm
can	O
thus	O
be	O
viewed	O
as	O
the	O
output	O
of	O
an	O
all-pole	O
infinite	O
impulse	O
response	O
filter	O
whose	O
input	O
is	O
white	O
noise	O
.	O
</s>
<s>
Some	O
parameter	O
constraints	O
are	O
necessary	O
for	O
the	O
model	O
to	O
remain	O
weak-sense	O
stationary	B-Algorithm
.	O
</s>
<s>
For	O
example	O
,	O
processes	O
in	O
the	O
AR(1 )	O
model	O
with	O
are	O
not	O
stationary	B-Algorithm
.	O
</s>
<s>
More	O
generally	O
,	O
for	O
an	O
AR(p )	O
model	O
to	O
be	O
weak-sense	O
stationary	B-Algorithm
,	O
the	O
roots	O
of	O
the	O
polynomial	O
must	O
lie	O
outside	O
the	O
unit	O
circle	O
,	O
i.e.	O
,	O
each	O
(	O
complex	O
)	O
root	O
must	O
satisfy	O
(	O
see	O
pages	O
89	O
,	O
92	O
)	O
.	O
</s>
<s>
In	O
an	O
AR	B-Algorithm
process	I-Algorithm
,	O
a	O
one-time	O
shock	O
affects	O
values	O
of	O
the	O
evolving	O
variable	O
infinitely	O
far	O
into	O
the	O
future	O
.	O
</s>
<s>
Continuing	O
this	O
process	O
shows	O
that	O
the	O
effect	O
of	O
never	O
ends	O
,	O
although	O
if	O
the	O
process	O
is	O
stationary	B-Algorithm
then	O
the	O
effect	O
diminishes	O
toward	O
zero	O
in	O
the	O
limit	O
.	O
</s>
<s>
where	O
B	O
is	O
the	O
backshift	O
operator	O
,	O
where	O
is	O
the	O
function	O
defining	O
the	O
autoregression	B-Algorithm
,	O
and	O
where	O
are	O
the	O
coefficients	O
in	O
the	O
autoregression	B-Algorithm
.	O
</s>
<s>
The	O
simplest	O
AR	B-Algorithm
process	I-Algorithm
is	O
AR(0 )	O
,	O
which	O
has	O
no	O
dependence	O
between	O
the	O
terms	O
.	O
</s>
<s>
This	O
results	O
in	O
a	O
"	O
smoothing	O
"	O
or	O
integration	O
of	O
the	O
output	O
,	O
similar	O
to	O
a	O
low	B-Algorithm
pass	I-Algorithm
filter	I-Algorithm
.	O
</s>
<s>
If	O
both	O
and	O
are	O
positive	O
,	O
the	O
output	O
will	O
resemble	O
a	O
low	B-Algorithm
pass	I-Algorithm
filter	I-Algorithm
,	O
with	O
the	O
high	O
frequency	O
part	O
of	O
the	O
noise	O
decreased	O
.	O
</s>
<s>
The	O
process	O
is	O
weak-sense	O
stationary	B-Algorithm
if	O
since	O
it	O
is	O
obtained	O
as	O
the	O
output	O
of	O
a	O
stable	O
filter	O
whose	O
input	O
is	O
white	O
noise	O
.	O
</s>
<s>
(	O
If	O
then	O
the	O
variance	O
of	O
depends	O
on	O
time	O
lag	O
t	O
,	O
so	O
that	O
the	O
variance	O
of	O
the	O
series	O
diverges	O
to	O
infinity	O
as	O
t	O
goes	O
to	O
infinity	O
,	O
and	O
is	O
therefore	O
not	O
weak	O
sense	O
stationary	B-Algorithm
.	O
)	O
</s>
<s>
Assuming	O
,	O
the	O
mean	O
is	O
identical	O
for	O
all	O
values	O
of	O
t	O
by	O
the	O
very	O
definition	O
of	O
weak	O
sense	O
stationarity	B-Algorithm
.	O
</s>
<s>
The	O
spectral	B-Algorithm
density	I-Algorithm
function	I-Algorithm
is	O
the	O
Fourier	B-Algorithm
transform	I-Algorithm
of	O
the	O
autocovariance	O
function	O
.	O
</s>
<s>
In	O
discrete	O
terms	O
this	O
will	O
be	O
the	O
discrete-time	O
Fourier	B-Algorithm
transform	I-Algorithm
:	O
</s>
<s>
which	O
yields	O
a	O
Lorentzian	O
profile	O
for	O
the	O
spectral	B-Algorithm
density	I-Algorithm
:	O
</s>
<s>
If	O
the	O
white	O
noise	O
is	O
a	O
Gaussian	B-General_Concept
process	I-General_Concept
then	O
is	O
also	O
a	O
Gaussian	B-General_Concept
process	I-General_Concept
.	O
</s>
<s>
In	O
this	O
case	O
,	O
the	O
solution	O
can	O
be	O
found	O
analytically	O
:	O
whereby	O
is	O
an	O
unknown	O
constant	O
(	O
initial	B-Algorithm
condition	I-Algorithm
)	O
.	O
</s>
<s>
There	O
are	O
many	O
ways	O
to	O
estimate	O
the	O
coefficients	O
,	O
such	O
as	O
the	O
ordinary	B-General_Concept
least	I-General_Concept
squares	I-General_Concept
procedure	O
or	O
method	O
of	O
moments	O
(	O
through	O
Yule	O
–	O
Walker	O
equations	O
)	O
.	O
</s>
<s>
Formulation	O
as	O
a	O
least	B-Algorithm
squares	I-Algorithm
regression	I-Algorithm
problem	O
in	O
which	O
an	O
ordinary	B-General_Concept
least	I-General_Concept
squares	I-General_Concept
prediction	O
problem	O
is	O
constructed	O
,	O
basing	O
prediction	O
of	O
values	O
of	O
Xt	O
on	O
the	O
p	O
previous	O
values	O
of	O
the	O
same	O
series	O
.	O
</s>
<s>
The	O
normal	B-Algorithm
equations	I-Algorithm
for	O
this	O
problem	O
can	O
be	O
seen	O
to	O
correspond	O
to	O
an	O
approximation	O
of	O
the	O
matrix	O
form	O
of	O
the	O
Yule	O
–	O
Walker	O
equations	O
in	O
which	O
each	O
appearance	O
of	O
an	O
autocovariance	O
of	O
the	O
same	O
lag	O
is	O
replaced	O
by	O
a	O
slightly	O
different	O
estimate	O
.	O
</s>
<s>
Formulation	O
as	O
an	O
extended	O
form	O
of	O
ordinary	B-General_Concept
least	I-General_Concept
squares	I-General_Concept
prediction	O
problem	O
.	O
</s>
<s>
Here	O
two	O
sets	O
of	O
prediction	O
equations	O
are	O
combined	O
into	O
a	O
single	O
estimation	O
scheme	O
and	O
a	O
single	O
set	O
of	O
normal	B-Algorithm
equations	I-Algorithm
.	O
</s>
<s>
One	O
set	O
is	O
the	O
set	O
of	O
forward-prediction	O
equations	O
and	O
the	O
other	O
is	O
a	O
corresponding	O
set	O
of	O
backward	O
prediction	O
equations	O
,	O
relating	O
to	O
the	O
backward	O
representation	O
of	O
the	O
AR	B-Algorithm
model	I-Algorithm
:	O
</s>
<s>
Substantial	O
differences	O
in	O
the	O
results	O
of	O
these	O
approaches	O
can	O
occur	O
if	O
the	O
observed	O
series	O
is	O
short	O
,	O
or	O
if	O
the	O
process	O
is	O
close	O
to	O
non-stationarity	O
.	O
</s>
<s>
This	O
is	O
then	O
a	O
low-pass	B-Algorithm
filter	I-Algorithm
,	O
when	O
applied	O
to	O
full	O
spectrum	O
light	O
,	O
everything	O
except	O
for	O
the	O
red	O
light	O
will	O
be	O
filtered	O
.	O
</s>
<s>
The	O
process	O
is	O
non-stationary	B-Algorithm
when	O
the	O
roots	O
are	O
outside	O
the	O
unit	O
circle	O
.	O
</s>
<s>
R	B-Language
,	O
the	O
stats	O
package	O
includes	O
an	O
ar	O
function	O
.	O
</s>
<s>
Matlab	B-Language
and	O
Octave	B-Language
:	O
the	O
TSA	O
toolbox	O
contains	O
several	O
estimation	O
functions	O
for	O
uni-variate	O
,	O
multivariate	B-General_Concept
and	O
adaptive	O
autoregressive	B-Algorithm
models	I-Algorithm
.	O
</s>
<s>
PyMC3	B-Application
:	O
the	O
Bayesian	O
statistics	O
and	O
probabilistic	O
programming	O
framework	O
supports	O
autoregressive	B-Algorithm
modes	O
with	O
p	O
lags	O
.	O
</s>
<s>
Python	B-Language
:	O
implementation	O
in	O
statsmodels	O
.	O
</s>
<s>
The	O
impulse	O
response	O
of	O
a	O
system	O
is	O
the	O
change	O
in	O
an	O
evolving	O
variable	O
in	O
response	O
to	O
a	O
change	O
in	O
the	O
value	O
of	O
a	O
shock	O
term	O
k	O
periods	O
earlier	O
,	O
as	O
a	O
function	O
of	O
k	O
.	O
Since	O
the	O
AR	B-Algorithm
model	I-Algorithm
is	O
a	O
special	O
case	O
of	O
the	O
vector	O
autoregressive	B-Algorithm
model	I-Algorithm
,	O
the	O
computation	O
of	O
the	O
impulse	O
response	O
in	O
vector	O
autoregression	B-Algorithm
#impulse	O
response	O
applies	O
here	O
.	O
</s>
<s>
have	O
been	O
estimated	O
,	O
the	O
autoregression	B-Algorithm
can	O
be	O
used	O
to	O
forecast	O
an	O
arbitrary	O
number	O
of	O
periods	O
into	O
the	O
future	O
.	O
</s>
<s>
First	O
use	O
t	O
to	O
refer	O
to	O
the	O
first	O
period	O
for	O
which	O
data	O
is	O
not	O
yet	O
available	O
;	O
substitute	O
the	O
known	O
preceding	O
values	O
Xt-i	O
for	O
i	O
=	O
1	O
,	O
...	O
,	O
p	O
into	O
the	O
autoregressive	B-Algorithm
equation	O
while	O
setting	O
the	O
error	O
term	O
equal	O
to	O
zero	O
(	O
because	O
we	O
forecast	O
Xt	O
to	O
equal	O
its	O
expected	O
value	O
,	O
and	O
the	O
expected	O
value	O
of	O
the	O
unobserved	O
error	O
term	O
is	O
zero	O
)	O
.	O
</s>
<s>
The	O
output	O
of	O
the	O
autoregressive	B-Algorithm
equation	O
is	O
the	O
forecast	O
for	O
the	O
first	O
unobserved	O
period	O
.	O
</s>
<s>
Next	O
,	O
use	O
t	O
to	O
refer	O
to	O
the	O
next	O
period	O
for	O
which	O
data	O
is	O
not	O
yet	O
available	O
;	O
again	O
the	O
autoregressive	B-Algorithm
equation	O
is	O
used	O
to	O
make	O
the	O
forecast	O
,	O
with	O
one	O
difference	O
:	O
the	O
value	O
of	O
X	O
one	O
period	O
prior	O
to	O
the	O
one	O
now	O
being	O
forecast	O
is	O
not	O
known	O
,	O
so	O
its	O
expected	O
value	O
—	O
the	O
predicted	O
value	O
arising	O
from	O
the	O
previous	O
forecasting	O
step	O
—	O
is	O
used	O
instead	O
.	O
</s>
<s>
There	O
are	O
four	O
sources	O
of	O
uncertainty	O
regarding	O
predictions	O
obtained	O
in	O
this	O
manner	O
:	O
(	O
1	O
)	O
uncertainty	O
as	O
to	O
whether	O
the	O
autoregressive	B-Algorithm
model	I-Algorithm
is	O
the	O
correct	O
model	O
;	O
(	O
2	O
)	O
uncertainty	O
about	O
the	O
accuracy	O
of	O
the	O
forecasted	O
values	O
that	O
are	O
used	O
as	O
lagged	O
values	O
in	O
the	O
right	O
side	O
of	O
the	O
autoregressive	B-Algorithm
equation	O
;	O
(	O
3	O
)	O
uncertainty	O
about	O
the	O
true	O
values	O
of	O
the	O
autoregressive	B-Algorithm
coefficients	O
;	O
and	O
(	O
4	O
)	O
uncertainty	O
about	O
the	O
value	O
of	O
the	O
error	O
term	O
for	O
the	O
period	O
being	O
predicted	O
.	O
</s>
