How to properly use vgxvarx for VAR estimation and why is it different from mvregress?
2 views (last 30 days)
Show older comments
Hello,
I am running Matlab 2014b and I am trying to understand how vgxvarx works when estimating a VAR model. My ultimate goal is to have a big structure and to impose restriction on the parameters, but for the moment let me start with a simple example.
Let Y be a T x 2 matrix of data that I want to model as a bivariate VAR(1). I am interested in the AR parameters as well as the covariance matrix of the errors/innovations. For the purpose of the example ignore any restrictions and let's estimate the full structure. I have both coded the MLE estimates on my own as well as used the mvregress function that Matlab provides. Both have produced the same output.
[beta,sigma,E,CovB,logL] = mvregress([ones(T-1,1) Y(1:end-1,:)],Y(2:end,:));
The column of ones is included as the data is not demeaned. The results are:
beta' = 0.0011 0.7298 0.0605
0.0023 -0.3871 0.7129
sigma = 1.0e-05 *
0.0435 -0.0023
-0.0023 0.6993
As far as I am concerned this are the results that I expect that get.
Next I have tried to obtain the same output using vgxvarx.
restriction_u = [1,1;1,1];
Spec_u = vgxset('n',2,'ARsolve',{logical(restriction_u)},'aSolve',true(2,1));
[EstSpec_u,EstStdErrors_u,LLF_u,W_u] = vgxvarx(Spec_u,Y,[],[],'CovarType','full');
[EstSpec_u.a cell2mat(EstSpec_u.AR)]
0.0024 0.4760 0.0638
0.0032 -0.5791 0.7154
EstSpec_u.Q
1.0e-05 *
0.0643 0.0143
0.0143 0.6943
Obviously I do not understand how to use the constant in vgxvarx so that is my first question.
Next I simply demeaned both series before estimation and ran the code again:
[beta,sigma,E,CovB,logL] = mvregress(Y(1:end-1,:),Y(2:end,:));
beta' = 0.7298 0.0605
-0.3867 0.7125
sigma = 1.0e-05 *
0.0435 -0.0023
-0.0023 0.6994
Trying again with vgxvarx, I get:
restriction_u = [1,1;1,1];
Spec_u = vgxset('n',2,'ARsolve',{logical(restriction_u)});
[EstSpec_u,EstStdErrors_u,LLF_u,W_u] = vgxvarx(Spec_u,Y,[],[],'CovarType','full');
[EstSpec_u.a cell2mat(EstSpec_u.AR)]
0.7298 0.0605
-0.3867 0.7125
EstSpec_u.Q
1.0e-05 *
0.0425 -0.0008
-0.0008 0.7099
The AR parameter estimates are spot on, but the covariance matrix is still off. Also the log likelihoods computed by the 2 functions are different. From mvregress I get 406.418530748933 while vgxvarx gives 417.008031450293. I don't understand what am I doing wrong.
Thanks for any help you can provide! Alex
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!