hac results vary bewteen MATLAB R2015b and MATLAB R2016b
Show older comments
Hi, my problem was related to the matlab function "hac". I used the same code last year (with R2015b version) and obtained the heteroscedasticity and serial correlation consistent standard errors (StdErr* 7.9709 0.0321 3.7480 0.0404 2.9265 10.7310 )and pvalues (pValue* 1.89E-01 1.49E-02 8.13E-21 3.30E-02 0.0033 0.0414), shown as below. Under R2016b version, the function now reports error message: "Error using hac (line 559) Matrix must be positive definite." Can you help me to figure out what happened? thanks a lot. Note: df_ttest = 27
1 Comment
Walter Roberson
on 6 Jan 2017
Note: df_ttest is not defined in your .mat or your code.
However, that line of your code is not reached until after hac() has worked, so it is not a primary problem.
Accepted Answer
More Answers (1)
Hang Qian
on 6 Jan 2017
0 votes
Hi Lucia,
Thank you for reporting this edge case.
The codes work on my Windows computer both in R2016a and R2016b. The results are the same as what you reported. Your hardware and software platforms might be different than mine. Occasionally, the results could be different in edge cases. It appears that the error message comes from the Cholesky decomposition of a matrix (named PhiHat in line 557). When I run the codes, I saw that matrix is ill-conditioned, and thus it is possible that Cholesky decomposition fails on your computer.
The predictor matrix X has some problems in this case. The values of the third variable are all zeros except for a single observation being one. Meanwhile, a constant term is included as the first predictor. The data have strong collinearity. A regression might not work well for that dataset.
Also, try to adjust the scale of the regressors, either by the data scale or the OLS estimator scale. It may help improve conditioning and overcome the edge case.
Regards,
Hang Qian
1 Comment
Lucia Ryan
on 6 Jan 2017
Edited: Lucia Ryan
on 6 Jan 2017
Categories
Find more on Linear Algebra in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!