dyn_main needs to be a valid .mod file such that it can be parsed by Dynare’s internal routines.
From what I can see from the error reported here, your dyn_main is currently an .m file, which cannot be parsed by Dynare and therefore the eval call reports an error and Matlab cannot execute that command line.
Hi cmarch,
In my working folder I have a correctly running dyn_main.mod. However, when you run it, a dyn_main.m is created. I tried deleting it before running shock_loop.m . I get the error:
‘dyn_main’ is not found in the current folder or on the MATLAB path, but exists
in:
G:\Math11no_r
Change the MATLAB current folder or add its folder to the MATLAB path.
Error in shock_loop (line 19)
eval(['dynare ',dyn_main])
No… Unfortunately, this is not the problem. dyn_main.mod is in the folder where I work. This error appears when I delete the file dyn_main.m from my working folder (this file is created when I run my code from dyn_table.m which calls dyn_main.mod without problems).
It is true that files with the same name are in the other folder too. But those are for another version of the model…
I am not sure whether I should open a new line or go on here for this new error… Sorry.
Now when running shook_loop.m shock_loop.m (1.8 KB) I get the error:
Error using check_model (line 36)
The specified covariances for the structural errors are not consistent with the
variances as they imply a correlation larger than ±1
Error in stoch_simul (line 67) check_model(M_);
Error in shock_loop (line 65)
info=stoch_simul(var_list_); % loop over stoch_simul.
Where should I look to find the mistake? (I check a previous entrance in the forum -2014- but it did not apply to this case…)
Many thanks…
You defined correlations between shocks, but now you are only setting the diagonal of the covariance matrix. That cannot work. You also need to adjust the covariance terms to be consistent with the specified correlation
Sorry, I’m afraid, then, that I don’t understand what the loop exactly does…
Shock_loop.m creates a grid of different shock sizes (different standard deviations to the credit shock). And it retrieves the correspondent volatility (variance) for two variables (exports and imports). Am I correct?
If I “manually” change the standard deviation of the shock, dyn_main runs. Why, with the loop, it is not similar?
My final scope is to draw a 3D plot of exports and imports volatilities against shock size to check robustness in their behaviour and/or identify non-linearities…
When you run Dynare fully, it will set the covariance matrix based on the specified correlation and variances. Within your loop, you need to do that manually. Currently, you are only setting the variance. You need