Cannot have number of chains for variance or coefficient bigger than 1

Dear Sir/Madam,

I am working on an MS-BVAR model.

I can run the model smoothly when I set the number of chain for variance = 1 and the number of chain for coefficient = 1.

I encounter problem when I set the number of chains for variance = 2 while keeping the number of chain for coefficient = 1.
The following error messages are displayed:

Error reading data after line identifier //== Number of states for state_variable[2] ==//.
Error in MS-SBVAR MEX file.

Error using mexErrCheck (line 41)
Error encountered in: ms_sbvar_create_init_file.

Error in ms_sbvar_setup (line 432)
mexErrCheck(‘ms_sbvar_create_init_file’,err);

Error in ms_estimation (line 40)
ms_sbvar_setup(options_);

Error in msbvar.driver (line 106)
[options_, oo_] = ms_estimation(M_, options_, oo_);

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;

Kindly please help me with this.
I attached the files.

Thank you very much for your help.

Best regards,
Eric

msbvar.mat (6.8 KB) msbvar.mod (885 Bytes)

My guess is that the two need to be consistent.

Dear Prof. Pfeifer,

Thank you very much for your answer.

I will try to use the same number of chains for variance and the coefficient to make them more consistent, then.

Best regards,
Eric

Dear Prof. Pfeifer,

I have tried to set equal number of chains for the variance and the coefficients (e.g. variance = 2, coefficient = 2; (3,3), etc.) , but still receive the same error messages.

I may misunderstood what you meant by consistency.
Kindly please let me know about the consistency that you referred to.

Or may be I have to accept the error as a sign of limitation to my model, i.e. it can only run for number of chain of variance = 1 and coefficient = 1.

I also wonder whether the error comes from the non-modelling issue, e.g. my computer server denies dynare to save due to the big size of the MEX file.

Thank you very much for your answer, Prof. Pfeifer.

Best regards,
Eric

The problem is that this is externally developed code which I have a hard time debugging. I contacted the authors but did not yet get a reply.

Dear Prof. Pfeifer,

Well noted about the issue.

Thank you very much for contacting the author.
I really appreciate your help.

Best regards,
Eric

Dear Prof. Pfeifer,

Still for the same case about I cannot set chain for variance or the coefficient bigger than 1 in the Hakkio model.
I tried to change coefficients of prior hyperparameters to see whether the problem comes from there.
By making the all the six coefficients smaller, the model can run more iterations to 48 iterations (from 32 in the initial coding) but cannot go further as improvement < crit termination.
The error message are displayed below.
I attach the mod file and the data as well.
It possible to lower to crit termination to enable the model to run?

Thank you very much for your answer.

Best regards,
Eric


Improvement on iteration 47 =        0.000000001
-----------------
-----------------
f at the beginning of new iteration,      6347.4239213651
x =    0.0006295044  0.00040519441  2.6815897e-05 -0.00040465661  0.00063034509
 -9.0167244e-05 -0.00027130291 -4.0049188e-05  -0.0014191614  3.9996363e-05
  0.00042205712 -0.00091225216
Predicted improvement:        0.000000000
lambda =          1; f =         6347.4239214
Norm of dx 3.4241e-09

ih =

     1

----
Improvement on iteration 48 =        0.000000000
improvement < crit termination
    0.5000         0
         0    1.0000
    0.5000         0

Error reading data after line identifier //== Number of states for state_variable[2] ==//.
Error in MS-SBVAR MEX file.

Error using mexErrCheck (line 41)
Error encountered in: ms_sbvar_create_init_file.

Error in ms_sbvar_setup (line 432)
mexErrCheck('ms_sbvar_create_init_file',err);

Error in ms_estimation (line 40)
    ms_sbvar_setup(options_);

Error in msbvar.driver (line 106)
[options_, oo_] = ms_estimation(M_, options_, oo_);

Error in dynare (line 293)
evalin('base',[fname '.driver']) ;

msbvar.mat (6.8 KB) msbvar.mod (897 Bytes)

Unfortunately, that is not the solution. Having improvement < crit termination simply means the step has successfully concluded. The problem is after that.

Dear Prof. Pfeifer,

Thank you for your answer.
Noted that the problem lies after that stage.

I will examine the coding and the data again.

Best regards,
Eric

Hi Eric,

I was wandering around the forum and stumbled upon this post. I notice there are a lot of economic/coding problems in your msbvar.mod file. Perhaps these are the reasons your code isn’t running.

  1. There are a lot of impact restrictions under svar_identification. Do you intend to have each variable respond to their own structural shock on impact? Wouldn’t this raise issues associated with over-identification?

  2. You wrote markov_switching(chain=1, number_of_regimes=3, duration=2); svar(variances, chain=2); svar(coefficients, chain=1);
    but do not have the second chain specified, e.g. markov_switching(chain=2, number_of_regimes=3, duration=2);.

  3. There are no file_tag or output_file_tag options selected in ms_estimation, ms_simulation, or ms_compute_mdd. These are important based on my experience.

  4. Why are you setting the Sims and Zha prior to coefficients_prior_hyperparameters=[0.0001 0.0001 0.0001 0.01 0.01 0.01]? Read Sims and Zha (1998, IER) for how to set the prior to monthly/quarterly data. If there is another reason for this prior setting (e.g., trying to set an uninformative prior), please ignore.

  5. Deleted all the commands below and including ms_compute_probabilities. These commands are buggy in Dynare. It is best to code them yourself.

Hope this helps,
Kenneth

Hi Kenneth,

Thank you very much for your suggestions.
They are very helpful.

After writing the second chain as you suggested in 2), the model works.

As for 1), yes, I just want to see how these variables respond to their own structural shock.

Well noted about 3), 4), and 5).

Thank you very much again, Kenneth.
I really appreciate your kind help.

Best regards,
Eric