Problem with vector autoregressive model (vgxvarx) - "Covariance is not positive-definite."
12 views (last 30 days)
Show older comments
Hi.
I have a dataset of 27 different variables measured during the same time period with the same lengths that I am trying to create a vector autoregressive model of using the method shown in the webinar “ Long Term Energy Forecasting with Econometrics in MATLAB ” which is basically:
Y=data; %10000x27 matrix of data
nAR = 12; % Define number of lags
Spec = vgxset('n', numel(YSeries), 'Constant', true, 'nAR', nAR, 'Series', YSeries);
Spec = vgxvarx(Spec, Y);
If I try running this with only two of the vectors Y(:,1:2) it works but the model obviously isn’t very good. When I start introducing more vectors to the model for example Y(:,1:10) I always get the error:
Error using mvregress (line 452)
Covariance is not positive-definite.
And I am unable to build the model.
What am I doing wrong here? In the webinar example he has many input vectors and the code never complains...
Thanks.
0 Comments
Accepted Answer
Hang Qian
on 28 Jul 2015
Hi Peta,
The codes appear syntactically correct. You might want to check the correlations of your 27 variables and the constant term, making sure they are not perfectly correlated. You may also consider a more parsimonious model, as 12 lags would imply more than 8000 unknown parameters in the model. There is a chance that numerical problems make the covariance matrix non-positive definite, though they are positive definite in theory. Also, most users would partition the data and set the name-value pair “Y0” as the initial observations, and Y for the remaining sample. This will yield the OLS results. The default “Y0” are padded by zeros.
- Hang Qian
2 Comments
Hang Qian
on 12 Aug 2015
Thank you very much for your suggestions on the single-precision algebra for the VAR model!
More Answers (1)
Maisa Melo
on 28 Aug 2018
Hi Peta,
I need implement a code using vgxvarx at Matlab, but I'm not know exacly how is the input data. I'm trying reproduce your code, but in your code there is no the valur of YSeries. I would like know your YSeries for I reproduce your code.
Best regard.
Maisa
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!