Parameter loop does not correctly update results

Hi all. I learnt so much from this thread so I decide to post my question here instead of starting a new one. I’m trying to get simulation samples with parameters updated.

code here:

list_alpha = [0.3 0.7 0.75 0.8 0.9];
first_time = 1;

for m=1:length(list_alpha)

    if first_time
    dynare dgp03 noclearall; 
    first_time = 0;


    set_param_value('alpha',list_alpha(m)); % update alpha, get the simulation
    info = stoch_simul(var_list_);

    simdata = sim_array([1 2],:, :);

    %playing with the simulation sample


The code works. My problem is that the results I got from the above code is quite different from the results when I manually update the alpha value in a new dynare/mod file. Any suggestion is welcomed.

Thank you all in advance.

I would need to see the mod-file

Hi professor, please see attached
dgp03.mod (1.0 KB)

You are not handling parameter dependence correctly.

kappa   = ((1-alpha)*(1-alpha*beta)*(omega+theta))/(alpha*sigma*(omega+theta));

should be a model-local variable, not an independent parameter:

#kappa   = ((1-alpha)*(1-alpha*beta)*(omega+theta))/(alpha*sigma*(omega+theta));

It solves my problem! Thank you so much!