Dynare Julia - Loop over parameters


I’ve seen some threads about looping over parameters in dynare matlab, but I have no idea how to do that in dynare julia.

I thought about creating modules and trying to do this, but I’m not really sure if this is the right way to go.

Has anyone tried this or know somewhere I can read about it?


@MichelJuillard may be able to help.

Felipe, it depends a bit of what you want to do it for and the number of iterations. Could you please post the current state of your *.mod and explain exactly what you want to do with and how you want to handle the results.

CanonicalNK.mod (1.1 KB)

I want to look at some statistics of variables in the model when some parameters change.

For example, I want to run the model with a specific value of beta, then change the value and compute the statistics without running it all over again.

I believe it would be something similar to this in matlab:

For a few iterations as in your example, using the Dynare macro @#for is the simplest. Dynare macros work in DynareJulia. I attach an example:
CanonicalNK_loo.mod (1.2 KB)

I will also think about a Julia equivalent to your example: calling Dynare first then calling directly stoch_simul as a function

1 Like

@MichelJuillard At least under Matlab/Octave that loop via the preprocessor is strongly discouraged. It does not allow for proper error handling within the loop. In case an error is triggered, you would be wrongly reading out the results from the previous iteration.

@jpfeifer what alternative do you recommend?

Looping over the function itself and reading out the info-code:

Under Matlab, you can put the loop (ignoring the first time call) into a verbatim-block to simply do the loop.


Thank you very much!