# Autoregressive distributed lag model

Could someone point me in the direction of creating an autoregressive distributed lag model in mathematica?

• Please also see the "Related" questions shown in the sidebar to this question, particularly this one – Verbeia Sep 18 '13 at 12:26

There are basically two methods.

The first is to use the ARProcess function (or ARMAProcess or ARIMAProcess as needed) introduced in version 9. The answers to this question should be helpful. Here is a small example that modifies the example in the documentation to show how to plot the resulting TemporalData using DateListPlot rather than ListPlot: you have to extract the "Paths" attribute.

In:= myAR = ARProcess[{0.9, -0.2, 0.15}, 0.8]
Out= ARProcess[{0.9, -0.2, 0.15}, 0.8]

In:= data = RandomFunction[myAR, {1, 150}]
Out= TemporalData

In:= DateListPlot[data["Paths"], Joined -> True] The older pre-version-9 way would be to use some version of FoldList. The trick is that if you are creating an $AR(p)$ process where $p>1$, you need to store the lags initially and then keep only the first elements in each intervening vector, like this

 oldfashioned =
First /@ FoldList[
Join[{{0.9, -0.2, 0.15}.#1 + #2}, Most[#1]] &, {0., 0., 0.},
RandomVariate[NormalDistribution[0, 0.8], 150]];

ListLinePlot[oldfashioned, Frame -> True] The advantage of the old way using FoldList is that you don't have to assume Gaussian noise. Here is an example with Levy-stable noise:

stable = First /@ FoldList[ Join[{{0.9, -0.2, 0.15}.#1 + #2}, Most[#1]] &, {0., 0., 0.},
RandomVariate[StableDistribution[1, 1.1, -0.096, -0.0001, 0.005],  150]];

ListLinePlot[stable, Frame -> True, PlotRange -> All] If what you mean by "creating" a "model" is to estimate it from data, then I'd suggest the EstimatedProcess function. It does a pretty good job of estimating the AR parameters even with non-Gaussian noise and the "wrong" number of lags.

EstimatedProcess[stable, ARProcess]

(* ARProcess[{0.902147, -0.223932,  0.248928, -0.0532185,
-0.0262434, -0.00263604}, 0.00202357] *)


It does even better when you know the order of the underlying AR process.

EstimatedProcess[stable, ARProcess]

(* ARProcess[{0.889943, -0.214266, 0.185013}, 0.0020378] *)

• Great thank you! – ALEXANDER Sep 18 '13 at 12:34
• In this case you have used an autoregressive AR module, however I do not understand how to get Distributed lags in the model as well. – ALEXANDER Sep 19 '13 at 6:16
• If you mean distributed lags of exogenous variables, then you need to respecify the FoldList approach to have more than one element in each iterate of the list in the last argument. – Verbeia Sep 19 '13 at 7:11
• Could you give a example how it would look with two lags of expgenous variables.With the fold list and how a ARDL(2,2) model would look like? – ALEXANDER Sep 22 '13 at 11:07