T. Sargent’s codes from Practicing Dynare replicating Chap. 11 of his and Lars Ljungqvist’s book do not seem to work under version 4.

The error message I get when running “Fig1131.mod” reads

??? Undefined function or method ‘var_index’ for input arguments of type ‘char’.

Error in ==> Fig1131 at 120

co = ys0_(var_index(‘c’));

Error in ==> dynare at 102

evalin(‘base’,fname) ;

Is there some change in version 4 that is incompatible with the original Sargent’s code? Is there some fix to use the files in version 4 too?

Thank you in advance,

Jan

I guess your hunch is right. Try to replace var_index with M_.endo_names. Version 4 groups almost everything into M_ and oo_. Try to look into the two structural variables to find what you want.

for this suggestion! However, it does not seem to work.

I also realised that it is easier to use version 3 for replicating Sargent’s codes than spending too much time sorting it out.

Best regards,

Jan

[quote=“jan.strasky”]T. Sargent’s codes from Practicing Dynare replicating Chap. 11 of his and Lars Ljungqvist’s book do not seem to work under version 4.

The error message I get when running “Fig1131.mod” reads

??? Undefined function or method ‘var_index’ for input arguments of type ‘char’.

Error in ==> Fig1131 at 120

co = ys0_(var_index(‘c’));

Error in ==> dynare at 102

evalin(‘base’,fname) ;

I was too sketchy about my answer. I think things are changed in version 4. var_index is supposed to be an array with numerical values. The input ‘c’ is a character value, so it is incompatible with var_index. The line is just to find what the steady state value corresponding to ‘c’, so what you need to do is to find the position of ‘c’. To use var_endo_names, you can find the location of ‘c’, and find the number in var_index to use it.

Is there some change in version 4 that is incompatible with the original Sargent’s code? Is there some fix to use the files in version 4 too?

Thank you in advance,

Jan[/quote]

I replaced the original code for:

%— Se derivan algunos vectores

c0 = ys0_(1);

k0 = ys0_(2);

g0 = ex0_(4);

rbig0 = 1/bet;

rbig = c(2:101).^(-gam)./(bet*c(3:102).^(-gam));

rq0 = alpha*A*k0^(alpha-1);

rq = alpha*A*k.^(alpha-1);

wq0 = A*k0^alpha-k0*alpha*A*k0^(alpha-1);

wq = A*k(1:100).^alpha-k(1:100).*alpha*A.*k(1:100).^(alpha-1);

sq0 = (1-ex0_(3))*A*alpha*k0^(alpha-1)+(1-del);

sq = (1-oo_.exo_simul(1:100,3))*A*alpha.*k(1:100).^(alpha-1)+(1-del);

It works nicely.

Juan