T. Sargent's codes from Practicing Dynare

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

T. Sargent's codes from Practicing Dynare

Postby jan.strasky » Tue Aug 05, 2008 4:35 pm

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
jan.strasky
 
Posts: 4
Joined: Sat Mar 17, 2007 6:47 pm

Postby bigbigben » Tue Aug 05, 2008 6:41 pm

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.
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Thank you

Postby jan.strasky » Tue Sep 30, 2008 9:48 am

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
jan.strasky
 
Posts: 4
Joined: Sat Mar 17, 2007 6:47 pm

Re: T. Sargent's codes from Practicing Dynare

Postby bigbigben » Tue Sep 30, 2008 3:20 pm

[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

[color=red]??? 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) ;[/color]

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]
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: T. Sargent's codes from Practicing Dynare

Postby j-segura » Tue Jun 08, 2010 3:39 am

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
j-segura
 
Posts: 1
Joined: Sat Dec 26, 2009 8:05 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 9 guests