Problem with vector autoregressive model (vgxvarx) - "Covariance is not positive-definite."

14 次查看(过去 30 天)
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.

采纳的回答

Hang Qian
Hang Qian 2015-7-28
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 个评论
Peta
Peta 2015-7-28
I’ve managed to get it working now, the problem occurred when most of my variables had values varying around 0.5-1.5 and others were varying around 100. By dividing the larger variables by 100 and thereby bringing them down to the same scale as the rest before constructing the model I don’t get the error. After the forecast I then multiply by 100 again to get the correct scale.
And also the VAR functions doesn’t appear to like working with single numbers, not only is it slower but it produces errors and warnings that I don’t receive when working with doubles. Which is a bit strange. Since large VAR models are very memory intensive it would be preferable for me to work in singles.

请先登录,再进行评论。

更多回答(1 个)

Maisa Melo
Maisa Melo 2018-8-28
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

类别

Help CenterFile Exchange 中查找有关 Chemistry 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by