# Singular matrix error

**URL:** <https://forum.dynare.org/t/singular-matrix-error/28351>\
**Category:** Estimation\
**Created:** [7 May 2026 09:44 UTC](https://forum.dynare.org/t/singular-matrix-error/28351 "2026-05-07T09:44:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![redbanana](https://forum.dynare.org/user_avatar/forum.dynare.org/redbanana/32/12120_2.png) [@redbanana](https://forum.dynare.org/u/redbanana)\
**Post date:** [7 May 2026 09:44 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/1 "2026-05-07T09:44:24Z")

</div>

Dear professor @jpfeifer,

I am tagging You and asking for Your help.

1. Trying to run the estimation files “run.m” and “runa.m” in attachment several times, MATLAB crashes each time after an hour, prior to the hard crash I obtain thousands of errors “Matrix is singular”.

2. Trying to run the file in Octave, I obtain the following three errors:

\>\> runa  
t0 = 1  
warning: optimset: unrecognized option: ‘LargeScale’  
warning: called from  
optimset\>setoptionfields at line 213 column 9  
optimset at line 195 column 12  
runa at line 151 column 10

warning: matrix singular to machine precision  
warning: called from  
runa at line 240 column 9

error: save: unable to save to tstarmat Permission denied  
error: called from  
runa at line 253 column 4

The original file “run.m” with data for France and my adjusted file “runa.m” with data for Slovenia are both attached (adjustments are commenting out few lines and replacing data file), as well as other required files:

[run.m](https://forum.dynare.org/uploads/short-url/efEsWJrg3uE5igRJxyflWwDbYYI.m) (6.6 KB)

[llfn.m](https://forum.dynare.org/uploads/short-url/pohlBgqdLcBfY2m0oz6he9LMlbD.m) (8.2 KB)

[llfnses.m](https://forum.dynare.org/uploads/short-url/1LLxJQxTviZ7JFFGiZ10LuPys5f.m) (7.4 KB)

[meancimpr.txt](https://forum.dynare.org/uploads/short-url/eQyQUri5aaj61rw21pJQ874CcOk.txt) (6.7 KB) (I couldn’t upload .DAT file, so I saved is as .TXT instead)

[runa.m](https://forum.dynare.org/uploads/short-url/vdo0TjpkeBAaYIg07VygYQkDqoJ.m) (6.4 KB)

[Slovenia\_centered2.mat](https://forum.dynare.org/uploads/short-url/3B27saZRqktm8ldwkYYajyTa2tD.mat) (4.4 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [8 May 2026 09:23 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/2 "2026-05-08T09:23:59Z")

</div>

What is the message of the crash? The singularity warning are from the matrix inversion of the forecast error matrix. If that continuously pops up, you either end up with strange parameter values or have a problem with stochastic singularity.

---

<div class="post-metadata">

**Author:** ![redbanana](https://forum.dynare.org/user_avatar/forum.dynare.org/redbanana/32/12120_2.png) [@redbanana](https://forum.dynare.org/u/redbanana)\
**Post date:** [8 May 2026 10:17 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/3 "2026-05-08T10:17:03Z")

</div>

Many thanks, I am most grateful for Your reply! Again, I apologize for bothering You, but I am stuck.

The crash message is in the printscreen in attachment:

 ![Crash](https://forum.dynare.org/uploads/default/original/3X/2/d/2d5e5858a2713e2c6f61f09c64686aba6d22c4a6.jpeg)

Finally, the professor who wrote this code confirmed me that he can run the file run.m successfully. How come only I have issues with strange parameter values or problem with stochastic singularity and he doesn’t? Thank You so much! I am running Dynare 6.2 and Octave 9.2.0 on Windows 11 Home.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [8 May 2026 10:41 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/4 "2026-05-08T10:41:32Z")

</div>

That is strange. What are the details, i.e. which function crashed Matlab for what reason?

---

<div class="post-metadata">

**Author:** ![redbanana](https://forum.dynare.org/user_avatar/forum.dynare.org/redbanana/32/12120_2.png) [@redbanana](https://forum.dynare.org/u/redbanana)\
**Post date:** [8 May 2026 16:49 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/5 "2026-05-08T16:49:59Z")

</div>

First, do You think I should contact the code author and ask him for advice? Perhaps, could You also try to run file run.m on Your machine?

Second, on MATLAB forum they said that the final cause for crash is irrelevant and that the key symptom is the warning “singular matrix” that comes from the command “inv(hessmatf)”.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [10 May 2026 09:53 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/6 "2026-05-10T09:53:44Z")

</div>

No, singularity of a matrix you are trying to invert will just trigger a warning as you see there. It does not explain why Matlab crashes completely.

---

<div class="post-metadata">

**Author:** ![redbanana](https://forum.dynare.org/user_avatar/forum.dynare.org/redbanana/32/12120_2.png) [@redbanana](https://forum.dynare.org/u/redbanana)\
**Post date:** [11 May 2026 13:28 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/7 "2026-05-11T13:28:16Z")

</div>

Dear professor,

I obtained an advice to run MATLAB from Command Prompt and it worked. The estimation took about 20 hours, but there was no crash. I obtain the error message in attachment.

Do you think the singularity warning is due to strange parameter values or a problem with stochastic singularity?

 ![11052026](https://forum.dynare.org/uploads/default/original/3X/2/e/2e4f3d610b34370016d3dd049a7a342411b082c5.png)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [11 May 2026 18:02 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/8 "2026-05-11T18:02:57Z")

</div>

Given that the message appears continuously and the f(x) is so huge that most likely something is off, I would suspect a systematic problem.

---

<div class="post-metadata">

**Author:** ![redbanana](https://forum.dynare.org/user_avatar/forum.dynare.org/redbanana/32/12120_2.png) [@redbanana](https://forum.dynare.org/u/redbanana)\
**Post date:** [13 May 2026 15:54 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/9 "2026-05-13T15:54:23Z")

</div>

Dear professor,

I have some very good news and some bad news.

1. The excellent news is that I can run the estimation file “runb” with data for France successfully. It took more than 30 hours and I still obtain thousands of “singular matrix” errors, but I get 5 output files produced perfectly, moreover, I used these data in computing both standard errors and parameter breaks successfully.

2. The bad news is that I can’t reproduce the same results for Slovenian data. I obtain the error above. The only two differences between Slovenian file “runa.m” and French file “runb.m” are real world data for respective countries, obviously, as well as commenting out few lines of code, as per advices I obtained on MATLAB forum (commented out lines are “clc”, “clear” and 5 data lines). Which of these two is most likely culprit for the error for You? Thank You so much!

---

<div class="post-metadata">

**Author:** ![redbanana](https://forum.dynare.org/user_avatar/forum.dynare.org/redbanana/32/12120_2.png) [@redbanana](https://forum.dynare.org/u/redbanana)\
**Post date:** [19 May 2026 18:04 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/10 "2026-05-19T18:04:14Z")

</div>

Dear professor @jpfeifer,

I am having big issues at testing for parameter structural breaks. I’ve obtained a code for France that works perfectly. The problem, however, is that I can’t reproduce the same results for Slovenia. I have pvqlrsb.txt file for France that is input to my test.m file. Could You advice me please how to know what data are in pvqlrsb.txt file and how to replace them with Slovenian data? Thank You so much!

[pvqlrsb.txt](https://forum.dynare.org/uploads/short-url/9SBqEzEVTztjufZdCoBE9afbNKt.txt) (9.5 KB)

[test.m](https://forum.dynare.org/uploads/short-url/kQM8FZBqkYSEjAYejCtDkX4MkaP.m) (4.4 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [22 May 2026 12:52 UTC](https://forum.dynare.org/t/singular-matrix-error/28351/11 "2026-05-22T12:52:40Z")

</div>

Sorry, I don’t know the answer. The data is not labeled and not commented on in the code. I guess you need to ask the original author.
