# Weird stoch_simul

Hello,
I am trying to understand this code:
What is it exactly doing? it is similar to the github for gali chapter 4

stoch_simul(order=1,irf=0,noprint) l y x pi de s;
l_pos=strmatch(‘l’,var_list_ ,‘exact’);
variance.l=NaN(1,length(r_pi_vec))
[info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list_)
;welf_PEG.mod (8.3 KB)

Hi Alisa,

``````l_pos=strmatch('l',var_list_ ,'exact');
``````

would like to find the `pos`ition of `l`abor in the `var_list_`, after we run

``````stoch_simul(order=1,irf=0,noprint) l y x pi de s;
``````

such that in line 202, dynare will return the variance of `l` :

``````variance.l(ii)=oo_.var(l_pos,l_pos);
``````

In some cases, I manually find the position of `l` in `oo_.var` in the workspace/variable window, for example, here the 1st postion:

``````variance.l(ii)=oo_.var(1,1);
``````

I think this command is also okay. BTW, the latest version of MATAB suggests using “string compare” `find(strcmp())` to replace `strmatch` “string match”.

Then

``````variance.l=NaN(1,length(r_pi_vec))
``````

Note line 182-183:

``````r_pi_vec=[1.5   1.5 5 1.5];
r_x_vec =[0.125 0   0 1  ];
``````

They seem to be four alternative regimes. Each time, we assign new values to

``````    set_param_value('r_pi',r_pi_vec(ii));
set_param_value('r_x',r_x_vec(ii));
``````

`r_pi` is one-to-one to `r_x`. The whole loop will be executed 4 times in all.

``````    [info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list_); %loop over stoch_simul
if ~info(1)
If `info` number is not 1 (error), after running `stoch_simul`, `oo_` and `options_` will be updated.