Hall 2011, exp-ing model, my silliness and Berlin

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.

Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Thu Aug 08, 2013 2:30 pm

Hey guys,

thanks a lot for the help in this forum first, many of my questions were answered only by reading foreign topics. It is really good, to have such a world-wide community stick together!

But right now I am facing some problems, that I cant explain. I am replicating a model, used by Robert E. Hall 2011 to explain the fluctuations of aftercrisis US-economy with financial friction as a driving source. He implements the friciton as a exogenous driven shock that rises the price of capital for firms and housing for household. Households choose their consumption between "usual" consumption and durable goods and housing, so we have two different kinds of capital here.

The paper: http://www.federalreserve.gov/events/co ... 120909.pdf

Ok, my model doesn't replicate his results correct, but this is fine for me now, because I have to hand in my thesis on monday and ... better this, than nothing. The problem I am facing right now, and which I can't explain to myself, is: I put an exp() around each endogenous variable, but right know, I get some timing problems!!! This is really driving me crazy, and so I am hoping, that some intelligent genius can help me. If you are reading this ... I would be glad, if you help me ;-)

Soooo, my code that is running some kind of impulse responses:

Code: Select all
var y, py, k, d, r, w, c, pk, pd, h, qk, qd, cy, m, mu, f;
varexo e;

parameters sigma, chi, psi, beta, phi, alpha, kappa_k, kappa_d, delta_k, delta_d, omega, rho, rho_g;

sigma   = 0.41;
chi     = 1.01;
//chi     = -1.6713;
//chi     = 0.334;     // from Hall 2009b
psi     = 1.66;
//psi     = 1.54;      // from Hall 2009b
//psi     = 0.66;      // guess
beta    = 0.987;     
phi     = 0.82;
alpha   = 0.646;
kappa_k = 8.0;
kappa_d = 8.0;
delta_k = 0.0188;
delta_d = 0.0129;
omega   = 1.03;
rho     = 0.60;
rho_g   = 0.60;



// ##############################################################
// ###                       Model normal                     ###
// ##############################################################



model;

y = (h^alpha) * (k(-1)^(1-alpha));
(1-alpha) * (py * y) / (mu * pk) = k(-1);
//pd * d(-1) = (1 - phi) * c;
pd(+1) * d = (1 - phi) * c(+1);
(w * c^(-1/sigma)) * (1-chi*(1-1/sigma)*h^(1+1/psi)) = (-1*h^(1/psi))*(-chi*(1+1/psi)*c^(1-1/sigma)-1);
(1+r)*m = 1;
y = cy + 0.2 + k - (1-delta_k)*k(-1) + (kappa_k/2) * (((k-k(-1))^2)/k(-1)) + d - (1-delta_d)*d(-1) + ((kappa_d/2)*((d-d(-1))^2)/d(-1));
(phi^(-phi)) * ((1-phi)^(-(1-phi))) * (py^phi) * (pd^(1-phi)) = 1;
//pk = (1 + r(-1)) * (1 + f(-1)) * qk(-1) * py(-1) - (1-delta_k) * qk * py;
//pd = (1 + r(-1)) * (1 + f(-1)) * qd(-1) * py(-1) - (1-delta_d) * qd * py;
pk(+1) = (1 + r) * (1 + f) * qk * py - (1-delta_k) * qk(+1) * py(+1);
pd(+1) = (1 + r) * (1 + f) * qd * py - (1-delta_d) * qd(+1) * py(+1);

// ##### Auxilary Model #####

h = alpha * (py*y) / (mu*w);
qk = kappa_k * (k - k(-1))/(k(-1)) + 1;
qd = kappa_d * (d - d(-1))/(d(-1)) + 1;
cy = phi*c/py;
m = beta * (((c(+1)^(-1/sigma))/c^(-1/sigma)) * ((1-chi*(1-1/sigma)*(h(+1))^(1+1/psi)) / (1-chi*(1-1/sigma)*h^(1+1/psi))));
mu = (y/1.89942907558276)^(-omega);

f = rho*f(-1) + e;
end;

initval;

y   = 1.89942907558276;
py = 1.2054994131041;
k   = 21.2073462421196;
d   = 9.9703287551424;
r   = 0.0129058949799601;
w   = 2.92156533602169;
c   = 1.72314927796078;
pk = 0.038221437790282;
pd = 0.0311089912529679;
h   = 0.506298918774804;
qk  = 1;
qd  = 1;
cy  = 1.17211372528957;
m   = 0.987258544901434;
mu  = 1;
f   = 0;

end;
steady;

//model_diagnostics(M_,options_,oo_) ;

check;





write_latex_dynamic_model;
shocks;
var e = 0.015;
//var e_g = 1;
//var e; stderr 0.015;
end;

stoch_simul(order = 1, irf = 10) y k d r pk pd f c h;



And now get ready for my exp-version of the model, that is somehow NOT working. And please be so kind and show me the mistake I made, and that I am not able to find.

Code: Select all
var y, py, k, d, r, w, c, pk, pd, h, qk, qd, cy, m, mu, f;
varexo e;

parameters sigma, chi, psi, beta, phi, alpha, kappa_k, kappa_d, delta_k, delta_d, omega, rho, rho_g;


sigma   = 0.41;
chi     = 1.01;
//chi     = -1.6713;
//chi     = 0.334;     // from Hall 2009b
psi     = 1.66;
//psi     = 1.54;      // from Hall 2009b
//psi     = 0.66;      // guess
beta    = 0.987;     
phi     = 0.82;
alpha   = 0.646;
kappa_k = 8.0;
kappa_d = 8.0;
delta_k = 0.0188;
delta_d = 0.0129;
omega   = 1.03;
rho     = 0.60;
rho_g   = 0.60;


// ##############################################################
// ###                       Model exp                        ###
// ##############################################################
   //## on: ( )  ||  off: (/*) ##


model;

exp(y) = (exp(h)^alpha) * (exp(k(-1))^(1-alpha));
(1-alpha) * (exp(py) * exp(y)) / (exp(mu) * exp(pk)) = exp(k(-1));
exp(pd) * exp(d(-1)) = (1 - phi) * exp(c);
//exp(pd(+1)) * exp(d) = (1 - phi) * exp(c(+1));
(exp(w) * exp(c)^(-1/sigma)) * (1-chi*(1-1/sigma)*exp(h)^(1+1/psi)) = (-1*exp(h)^(1/psi))*(-chi*(1+1/psi)*exp(c)^(1-1/sigma)-1);
(1+exp(r))*exp(m) = 1;
exp(y) = exp(cy) + 0.2 + exp(k) - (1-delta_k)*exp(k(-1)) + (kappa_k/2) * (((exp(k)-exp(k(-1)))^2)/exp(k(-1))) + exp(d) - (1-delta_d)*exp(d(-1)) + ((kappa_d/2)*((exp(d)-exp(d(-1)))^2)/exp(d(-1)));
(phi^(-phi)) * ((1-phi)^(-(1-phi))) * (exp(py)^phi) * (exp(pd)^(1-phi)) = 1;
exp(pk) = (1 + exp(r(-1))) * (1 + exp(f(-1))) * exp(qk(-1)) * exp(py(-1)) - (1-delta_k) * exp(qk) * exp(py);
exp(pd) = (1 + exp(r(-1))) * (1 + exp(f(-1))) * exp(qd(-1)) * exp(py(-1)) - (1-delta_d) * exp(qd) * exp(py);
//exp(pk(+1)) = (1 + exp(r)) * (1 + exp(f)) * exp(qk) * exp(py) - (1-delta_k) * exp(qk(+1)) * exp(py(+1));
//exp(pd(+1)) = (1 + exp(r)) * (1 + exp(f)) * exp(qd) * exp(py) - (1-delta_d) * exp(qd(+1)) * exp(py(+1));

// ##### Auxilary Model #####

exp(h) = alpha * (exp(py)*exp(y)) / (exp(mu)*exp(w));
exp(qk) = kappa_k * (exp(k) - exp(k(-1)))/(exp(k(-1))) + 1;
exp(qd) = kappa_d * (exp(d) - exp(d(-1)))/(exp(d(-1))) + 1;
exp(cy) = phi*exp(c)/exp(py);
exp(m) = beta * (((exp(c(+1))^(-1/sigma))/exp(c)^(-1/sigma)) * ((1-chi*(1-1/sigma)*(exp(h(+1)))^(1+1/psi)) / (1-chi*(1-1/sigma)*exp(h)^(1+1/psi))));
//exp(m(-1)) = beta * (((exp(c(0))^(-1/sigma))/exp(c(-1))^(-1/sigma)) * ((1-chi*(1-1/sigma)*(exp(h(0)))^(1+1/psi)) / (1-chi*(1-1/sigma)*exp(h(-1))^(1+1/psi))));
exp(mu) = (exp(y)/exp(1.89942907558276))^(-omega);
   
f = rho*f(-1) + e;     

end;


initval;

y   = log(1.89942907558276);
py  = log(1.2054994131041);
k   = log(21.2073462421196);
d   = log(9.9703287551424);
r   = log(0.0129058949799601);
w   = log(2.92156533602169);
c   = log(1.72314927796078);
pk  = log(0.038221437790282);
pd  = log(0.0311089912529679);
h   = log(0.506298918774804);
qk  = log(1);
qd  = log(1);
cy  = log(1.17211372528957);
m   = log(0.987258544901434);
mu  = log(1);
f   = 0;

end;
steady;
check;

shocks;
var e = 0.015;
end;

stoch_simul(order = 1, irf = 10) y k d r pk pd f;


If you can help me:
Thanks a lot :-)

Valentin

P.S. If there is someone outside, that can help me to replicate Halls results correctly, I will regard him or her as a friend and he or she will be my guest in berlin, providing a deep look into the beautiful and funny side of this city ... ... ... :P seriously
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby richardgu26 » Fri Aug 09, 2013 2:00 am

If you had timing problem, you can try capital stock first. Is it predetermined variable?

You can declare predetermined_variables k; right after var block. Or change the timing in dynare like
k(+1)=(1-delta)*k; instead of k=(1-delta)*k(-1) in your model.

Haven't tried out your model yet. Hope this can fix your problem.

Cheers!
richardgu26
 
Posts: 13
Joined: Wed May 22, 2013 6:41 am

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Fri Aug 09, 2013 5:04 pm

Hey Richard, thanks a lot for your answer!

But I think I didn't really got your point. Should I declare it direct under the var term, or just as the first equation?

I will play with the timing and post my results!

Best regards,

Valentin
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby federico » Fri Aug 09, 2013 8:32 pm

If your problem is to log linearized is instead to linearized I think I fixed the problem

see the attached file
Attachments
prova2.mod
(3.07 KiB) Downloaded 160 times
federico
 
Posts: 68
Joined: Fri Mar 30, 2012 4:46 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Sat Aug 10, 2013 9:04 am

Oh yeah, amazing! Thank you a lot!

I really appreciate your solution, it is in fact quite simple. Only introduce some new variables that are the percentage deviation from the steady state values. Simple, but you have to come to the idea. Thanks again!

My Dynare code is running, but still it is not replicating the results from the original paper. So, if you have time on saturday, maybe you could do some dynare magic, too :-) The euqtions are summarized on 22 with one mistake: (A.4) needs to have minus sign on one site, like one site has to be negative.

Best regards and thanks,

Valentin
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Sat Aug 10, 2013 9:06 am

By the way, who wants to come to Berlin ? :-)
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby federico » Sat Aug 10, 2013 3:53 pm

Hi,
Assuming that you insert correctly the equation and the parameters in the mod file I have a couple of remarks.
I didn't read deeply the Hall's paper but at page 30 the author describes the soluton method used,
He used a perfect foresight approach (basicly the dynare simul (or the extended path) command instead of stoch_simul) ans not a stochastic one. Even if for small shock the give "essentially the same results of the log - linearization" this does not mean that they are exacly the same . If the difference between ypur model and the original one are small maybe this is the reason.
federico
 
Posts: 68
Joined: Fri Mar 30, 2012 4:46 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Sat Aug 10, 2013 4:33 pm

Hey federico, thank you for your answer.

So you said, I could reach better results with a deterministic variant of the model? I am checking it out right know, the results are somehow proper, but still I am not convinced.

Can dynare print out some IRFs for a deterministic solution?

Best,
Valentin
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby federico » Sat Aug 10, 2013 6:21 pm

Honestly i don't know.
Hall used a deterministic simulation in his paper,
With a small shock he claimed that the results should be "essentially" the same. But they could differ.
Under deterministic simulation you could plot the path of the endogenous variables to the steady state

after simul
add

rplot y (or any another endogenous variables) and you could see the path
federico
 
Posts: 68
Joined: Fri Mar 30, 2012 4:46 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Sat Aug 10, 2013 10:53 pm

Hey,

with the deterministic model and the plot of the relative values (Thanks again!) I get quite fine values. I even think, that the values would do a good job, if there wouldn't be something like a big jump, that my variables do in the beginning of the periods, that I really can't explain. They jump up, when the shock hits the economy, then jump down again, and than they are back on their path to steady state...

Do you have an idea?
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby Valentin_Seehausen » Mon Aug 12, 2013 4:04 am

Ah ok, now everything is working perfectly.

Thank you guys for your help, thanks dynare and thanks to my Bachelor.

Best regards,

Valentin
Valentin_Seehausen
 
Posts: 7
Joined: Thu Aug 08, 2013 2:10 pm

Re: Hall 2011, exp-ing model, my silliness and Berlin

Postby federico » Mon Aug 12, 2013 4:41 pm

Why don't you share your working code with us?Maybe it could be usefull ... :)
federico
 
Posts: 68
Joined: Fri Mar 30, 2012 4:46 pm


Return to Dynare contributions and examples

Who is online

Users browsing this forum: No registered users and 1 guest