Error doing sensitivity analysis


I modified the code from ls2003.mod in order to do some sensitivity analysis (at
However, I got the following error
Error using legend>process_inputs (line 582)
Invalid argument. Type ‘help legend’ for more information.

Error in legend>make_legend (line 340)
[autoupdate,orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); %#ok

Error in legend (line 294)

Error in filt_mc_ (line 571)

Error in dynare_sensitivity (line 369)

Error in sensitivity (line 498)

Error in dynare (line 180)
evalin(‘base’,fname) ;

I double checked the codes that needed to be modified according to my model, but I did not find anything else. Could anyone can help me with this?

Another question is about interpreting these results before I got the above error

These parameters do not affect significantly the fit of ANY observed series:

These parameters affect ONE single observed series:

These parameters affect MORE THAN ONE observed series: trade off exists!

I am not quite sure how to interpret these results and what are the underlying problems? Here are my data file and mod file.

mydata.mat (5.3 KB)
sme_estimation.mod (7.0 KB)
sensitivity.mod (13.5 KB)

Many many thanks

  1. Did you use Dynare 4.5.5? And did you try it more than once? This sounds like a Matlab graphics problem during plotting? Maybe it is related to
  2. What exactly is your interpretation question?
  1. Ah, I see. I use Dynare 4.4.3. Thanks, I’ll try it again after I update it.
  2. I am trying to understand this statement and what is the underlying problem ‘These parameters affect MORE THAN ONE observed series: trade off exists!’.
    Is there any problem with the parameters affect more than one observed series?
    Similarly, for the parameters do not affect any observed series, does it implies a normal situation or a strange one.


  1. The global sensitivity analysis (GSA) is for analyzing the effect of a particular parameter for a particular object. But the questions you ask seem to refer to identification.

If I understand correctly, do you mean the parameter affect only one observed series, implies exact identification. With the parameter affect more than one, meaning that the model suffers in under identification?

No, each parameter has to independently affect at least one data moment to be identified. If they affect more than one moment that is even better as it usually implies stronger identification…

Thanks for the prompt reply.

Then I an confusing about the alert ‘trade off exist!’. Does it mean I need to delete one of the parameters?

Following your explanation, for those parameters do not affect significantly any observed series, is it a bad signal for the model?

Again, what is the underlying question that you want to have an answer to? I don’t think that the sensitivity analysis delivers it.

Sorry for confusing you with my stupid question. Let me hold up for this for a moment.
I updated the dynare to the latest version and get it run now. However, after the estimation in GSA, I got the following error.
Error using load
Unable to read file ‘sensitiv_mode’. Input cannot be a directory.

Error in dynare_estimation_init (line 167)
mode_file = load(options_.mode_file);

Error in dynare_sensitivity (line 124)
[dataset_,dataset_info,xparam1,hh, M_, options_, oo_,
estim_params_,bayestopt_]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_,

Error in sensitiv_mode (line 556)

Error in dynare (line 235)
evalin(‘base’,fname) ;

I tried to change the name of the mode file, but it still does not work. Could you please give me a hint on how to solve this problem.
sensitiv_mode.mod (12.7 KB)


Are you using 4.5.5 or the unstable version? I hope the former.

I am using 4.5.5

If your file is called sensitiv_mode, then the mode-file is named sensitiv_mode_mode.mat, not sensitiv_mode.mat

That is great! I got it run now. Many thanks.

Here are some of my results,
Smirnov statistics in driving the fit of i
Parameter d-stat p-value
SE_e_isme 0.813 0.000
SE_e_tau 0.643 0.000
alph1 0.580 0.000
ay 0.563 0.000
rho_isme 0.513 0.000
alph2 0.445 0.000
SE_e_aspb 0.384 0.000
SE_e_g 0.357 0.000
SE_e_rp 0.334 0.000
rho_d 0.319 0.000
rho_tau 0.303 0.000

Apart from these results, all of the rest results all have P-value equal 0. Does it mean that the observed data are all not follow the same distribution in the prior. Which means the priors I chose in the estimation are not appropriate. So I need to change the prior distributions.

One last question related to the latex file, the command in the following,

if system(['pdflatex -halt-on-error -interaction=batchmode ’ M_.fname ‘_TeX_binder.tex’])
error(‘TeX-File did not compile.’)

Is it trying to input all the sensitivity results into a latex file and produce it to a PDF document?
After running these code, I got an error,

Error using sensitiv_mode (line 616)
TeX-File did not compile.

Error in dynare (line 235)
evalin(‘base’,fname) ;

I am not quite sure how to fix this one. It is highly appreciate that if you could let me know what should I do next? Or do I need to use this command?

Many thanks

Again, I have no clue what you are doing here in terms of economics and can thus not answer any questions regarding intuition.

Regarding \LaTeX: Yes, that is only for generating a PDF with the results. You don’t need it. If you want to find out what the problem is, open the _TeX_binder.tex in your \LaTeX-editor and try compiling there.

I really appreciate your patience for my questions.

Initially, I calibrated my model and got quite nice IRFs. Then I estimated my model and also got reasonable results as well as nice Bayesian IRFs.
Maybe I misunderstood the purpose of the GSA, so please correct me if i am wrong. After the estimation, I want to know whether the prior distributions for the estimated parameters I chose are good enough. Whether the density of the priors consistent with the empirical data? That is why I want to do GSA in the first place (maybe I was wrong).
After learning some knowledge of GSA, now I know some motivations of conducting GSA, including

  1. What (parameter, assumption, model spec’s) drives the ‘behavior’ of a model?
  2. How much a change in model factors (parameters, assumptions, model spec’s) affects the ‘behavior’ of a model?
  3. Which parameters drive uniqueness of solutions or indeterminacy/unstable behavior?
  4. Which parameters mostly drive the fit of , e.g., GDP and which the fit of inflation?
  5. What is the ‘shape’ of the relationship between structural parameters and the solution of a DSGE model?

Turning to the results I got from these GSA,
I got the Smirnov statistics, which is from KS test. If I understand it correctly, K-S test is to tell whether the prior density is close to the density of the real data. So if the prior I chose is good enough, then the null hypothesis can not be rejected. However, as in the previous post, all the P-values I got are zero, so does it mean the prior I chose are not consistent with the data, and I actually chose bad priors even if I got good estimated results?

Again thanks for your patience and reading my long post. Please let me know if I interpreted the results incorrectly and also whether my results answer any of the 5 motivations above. Are these good results or bad results for me.