Hi,
1 - After running a model, how can I access the decision rule matrix in Dynare Julia? I’ve examined the context object, but couldn’t find anything similar to ‘oo_.dr.ghx’ in Matlab. Is there a way to access it? Ideally, I would like to run the model with various parameters in a loop and save the policy functions for each iteration.
2 - Despite including ‘stoch_simul(order=1,nocorr, nodecomposition, nomoments, nograph)’ in the .mod file, I’m still receiving results. It seems that the stoch_simul options aren’t working as they do in Matlab.
Thanks in advance!
ehlmodel.mod (2.5 KB)
1, for now the equivalent of oo_.ghx
is in context.results.model_results[1].linearrationalexpectations.g1_1
oo_.ghu
in
context.results.model_results[1].linearrationalexpectations.g1_2
2. You are right options nocorr, nodecomposition, nomoments, nograph aren’t supported for now in DynareJulia. You can avoid the graphs with option irf=0
Best
1 Like
If I may, I’d like to ask one more question. Let’s assume that I want to save the decision rule from each iteration of this loop, even though that may not be the optimal way to create a loop. Would this be the appropriate course of action?
phip_val = [0.3, 0.4, 0.5, 0.6];
grid = zeros(24,6,4)
@#for i in 1:4
phip = phip_val(@{i});
stoch_simul(order=1);
grid(:,:,i) = context.results.model_results[1].linearrationalexpectations.g1_1
@#endfor
NKmodelV2.mod (2.6 KB)
I also attempted running the loop outside the mod function, but I was unable to generate distinct decision rule matrices. Something like this:
gridpolicy = zeros(24,6,4);
gridparam = [0.3, 0.4, 0.5, 0.6]
for i in eachindex(gridparam)
phip = gridparam[i];
context = @dynare C:\Users\depep.felipecs\Documents\Julia\DynareJulia\DynareJuliaV2\NKmodelV2.mod";
gridpolicy[:,:,i] = context.results.model_results[1].linearrationalexpectations.g1_1
end
Yes, this is fine. I have a small preference to keep the various matrices in a vector of matrices rather than in 3 dimensional array, but it is marginal. Something like
grid = [];
…
push!(grid, context.results.model_results[1].linearrationalexpectations.g1_1;
1 Like
I have tried this way, the problem is the decision rule matrices came all the same despite changing the value of the parameter. I did it mannually changing the values and got differences, but inside the loop it didnt happen.
The problem with calling @dynare in Julia loop is that we have no way of passing the value of phip to Dynare.
1 Like