Estimation of vector autoregressive (VAR) process

9

4

To estimate 1-dimensional VAR process (which is AR process) you can easily use functions EstimatedProcess or FindProcessParameters like this:

sample = RandomFunction[ARProcess[{.2,-.4},.1], {1,300}];

EstimatedProcess[sample, ARProcess[{a,b},v]]
(*or*)
FindProcessParameters[sample, ARProcess[{a,b},v]]

Now lets say we have sample

alpha = {{.2,.1}, {-.3,.2}};
sigma = {{1.0,0}, {0,0.3}};
sample = RandomFunction[ARProcess[{alpha},sigma], {1,100}]

which is based on two dimensional VAR process (I took this definition from ARProcess documentation).

Then neither of this two ways does work:

EstimatedProcess[sample,ARProcess[{{{a1,a2}, {a3,a4}}}, {{v1,v2}, {v3,v4}}]]

FindProcessParameters[sample,ARProcess[{{{a1,a2}, {a3,a4}}}, {{v1,v2}, {v3,v4}}]]

Is it possible to estimate vector autoregressive process in Mathematica?

matt525252

Posted 2014-01-29T15:15:21.363

Reputation: 273

The error message "Estimation is not currently supported for the parameters in process ARProcess[{{{a1,a2},{a3,a4}}},{{v1,v2},{v3,v4}}]" says no. So, other than programming it yourself it looks like it's not possible. – Sjoerd C. de Vries – 2014-01-30T21:54:32.110

1Thanks for asking, I've long wanted to ask the same question here. It seems that in time series and macroeconomic modeling mma lags far behind packages such as free IRIS Toolbox for Matlab or EViews. – iav – 2014-04-10T14:57:40.583

1

Look at this demo: http://demonstrations.wolfram.com/AModelOfVectorAutoregression/ If you download the source code you'll easily find functions for OLS and Yule-Walker estimation procedures.

– iav – 2014-04-10T17:21:10.163

2Thanks for the answer and especially thanks for recommending my demo. :) At first, I was using EViews as well but its not that difficult to apply those methods using such a friendly language as Wolfram language. – matt525252 – 2014-04-11T19:04:47.900

@matt525252, it would be very nice of you if you would be able to share some of the tools you've developed. The demo is impressive. Have you ever tried to implement and estimate any of the state-space models in mma? – iav – 2014-04-23T15:36:21.497

1@iav, thank you. I focused only on VAR models. Every function I developed should be included in demo. I basically made this demo as a tool because of some calculations in my masters thesis. But maybe in the future I will have time to create some other functions for estimating different types of models. And what do you mean by mma? – matt525252 – 2014-04-28T12:22:49.740

@matt, it seems that mma is used here as a shorthand for Mathematica. – iav – 2014-04-29T16:46:53.723

@matt525252, both of your expressions work. – garej – 2017-08-15T07:10:38.280

Answers

2

I prepared a small demonstration with a solution: demonstrations.wolfram.com/AModelOfVectorAutoregression

matt525252

Posted 2014-01-29T15:15:21.363

Reputation: 273

5

Let's estimate the parameters for the following model.

sample = 
  RandomFunction[
    ARProcess[{{{.2, -.4}, {-.2, 0}}}, {{.1, -0.05}, {-0.05, .15}}], 
    {1, 1000}]

Next, use the function EstimatedProcess to perform the estimation:

α = {{α1, α2}, {α3, α4}};
Σ = {{σ11, σ12}, {σ21, σ22}};
EstimatedProcess[sample, ARProcess[{α}, Σ]] 

Note that when you pass ARProcess to EstimatedProcess the matrix α should be under curly brackets {α}.

If you want to run a Restricted VAR, you only need to include the restricted parameters in the α matrix. For example, if you want to set α2 = 0.5 and α3 = 0.03`, you can run

α = {{α1, 0.5}, {0.03, α4}};
Σ = {{σ11, σ12}, {σ21, σ22}};
EstimatedProcess[sample, ARProcess[{α}, Σ]] 

Diogo

Posted 2014-01-29T15:15:21.363

Reputation: 96

notice that FindProcessParameters[sample, ARProcess[{α}, Σ] works as well. – garej – 2017-08-15T06:27:21.913

4

As was mentioned in the comments above as of yet Mathematica is not able to estimate VAR processes.

So I've tried and implemented VAR estimation function. Actually I've directly translated Cesa-Bianchi's MATLAB code [1].

My code is available here: http://www.alexisakov.com/p/economica.html.

Here is a simple example:

<<Economica`
S = Import[FileNameJoin[{$UserBaseDirectory, "Applications", "Economica", 
 "Kernel", "TimeSeries", "VAR", "BQ_Data.xls"}], {"Data", 1}];
data = S[[3 ;;, {2, 3}]];

Then fit VAR:

 VARout = VARModelFit[data, 8];

VARModelFit returns association with a number of results. Matrix of coefficient estimates is Ft:

coeffs=VARout["Ft"]

Other properties are fit residuals and variance-covariance matrix. Generally all the names are similar to those used by [1].

  1. Ambrogio Cesa-Bianchi, 2014. "VAR Toolbox", sites.google.com/site/ambropo/".

iav

Posted 2014-01-29T15:15:21.363

Reputation: 1 875

according to documentation VAR(p) is simply ARProcess[p] in MMA, so OP's issue is solved with EstimatedProcess[sample, ARProcess[1]]. – garej – 2017-08-15T01:29:46.853