Good day professor,

I am interested in running a model with different values for a structural parameter, and basically get the correlation coefficient between relative consumption and real exchange rate for each of those parameters, and save the result in a vector. I followed the loop you suggested, as I think it is appropriate for my case:

```
thetas = [0.25, 0.5, 0.78, 0.99];
BK = [];
for i=1:length(thetas);
set_param_value('cHthetaF', thetas(i));
set_param_value('cFthetaH', thetas(i));
dynare IAM5 noclearall;
close all;
relcons = Hc_Heps - Fc_Heps;
corr_BK = corrcoef(Q_Heps, relcons);
BK(i) = corr_BK(1,2);
end
```

However, my vector BK is filled up with the same value (the only thing I can see is that the values of my endogenous are not changing). I don’t understand why it is not saving the different correlations that I think I am calculating in the last two lines of my loop. I attach my mod file.

I would appreciate very much your help on this issue.

IAM5.mod (4.4 KB)

In the file you provided, `Hc_Heps`

and `Fc_Heps`

are not computed.

My apologies, I attach the correct mod file this time:

IAM5.mod (4.4 KB)

This is the loop I am attempting to run. I want to set different values for cHthetaF and cFthetaH, run the model, and compute the new second moments that are generated. However, when I run the code I put below, my vector BK is filled up with the same result (i.e. the one coming from the first time I ran dynare).

```
dynare IAM5
close all
thetas = [0.25, 0.5];
BK = [];
for i=1:length(thetas);
set_param_value('cHthetaF', thetas(i));
set_param_value('cFthetaH', thetas(i));
[info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list_);
% Compute new moments with new parameters
cov_relconsQ = oo_.var(39, 4); % relcons and Q
var_relcons = oo_.var(39,39); % relcons
var_rer = oo_.var(4,4); % Q
corr_BK = cov_relconsQ/(sqrt(var_relcons)*sqrt(var_rer));
BK(i) = corr_BK;
end
```

I would appreciate if you could tell me what is wrong with my loop.

You are not handling parameter dependence correctly. Composite parameters should be model-local variables

So cHthetaF affects clambaF, so now I included this latter parameters in my loop to handle that parameter dependence. Is that what you were referring to? Anyway, I did that, but I still cannot get any different results.

```
thetas = [0.25, 0.5];
BK = NaN(1,length(thetas));
for i=1:length(thetas);
set_param_value('cHthetaF', thetas(i));
clambdaF = (1 - cHthetaF)*(1 - cbeta*cHthetaF)/cHthetaF;
set_param_value('cFthetaH', thetas(i));
clambdaH = (1 - cFthetaH)*(1 - cbeta*cFthetaH)/cFthetaH;
[info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list_);
close all
% Compute new moments with new parameters
cov_relconsQ = oo_.var(39, 4);
var_relcons = oo_.var(39,39);
var_rer = oo_.var(4,4);
corr_BK = cov_relconsQ/(sqrt(var_relcons)*sqrt(var_rer));
BK(i) = corr_BK;
end
```

Trying a loop changing any other parameter, I do get different results. I just don’t know why nothing changes with the particular parameters I am interested in changing.

This is not a proper way to handle parameter dependence. Again, please use model-local variables or a steady state file.