Impulse Responses with Cointegrated Stochastic Trends

I have a 2-sector DSGE model with two cointegrated stochastic trends gu and gd (“upstream” and “downstream” technology), each with different mean growth rates. There is an error correction term in the downstream shock process, so an upstream shock should lead (with a 1-period delay) to a gradual response of the downstream technology. I can obtain the steady state, solve the model, even estimate the parameters. But I am having trouble making sense of the impulse responses with the error correction.

In the attached .mod file I hit each sector with a 0.02 technology shock (vu or vd). Without the error correction (thetadu=0) the irfs make sense. But with the error correction (thetadu=0.3 in the file), gd seems to have a contemporaneous response to the upstream shock, and immediately jump to its new steady state (if I’m interpreting the output correctly). That is, the simulated gd series is (-0.0085,0,0,0,0…) in response to a 0.02 shock to gu. I don’t understand either the magnitude (-0.0085) or the time path. Also, the 0.02 shock to gd results in an increase of 0.029. Ultimately I’m interested in the irfs for the other endogenous variables, but if I don’t understand the responses of the trends then I’m not sure how to view the irfs of the other variables. Would appreciate any help.
[Uploading: Model_hfac_2tr_EC.mod…]

File upload isn’t working, I’ll keep trying.
There seems to be a problem with the site: It won’t upload files, and when I try to copy and paste the code into the text, some characters are missing, so the code is unusable.

Is the upload working now? Alternatively, paste the code, but enclose it in ```. That should preserve the formatting.

var nd,nu,n,A,Lam,gu,Omegau,Omegauprime,Omegad,Omegadprime,ng,yg,iig,cg,qug,qdg,mug,gd;
trend_var(growth_factor=gu) Bu;
trend_var(growth_factor=gd) Bd;
model_local_variable gc;
var(deflator=Bu) iu,id,ii;
var(deflator=Bu(+1)) ku,kd;
var(deflator=Bu^.33*Bd^.67) c,y ;
var(deflator=Bu^(-.33)*Bd^(-.67)) chi;
var(deflator=Bu^(-.67)*Bd^.67) qu,qd,mu; 
predetermined_variables kd,ku;

varexo vd,vu;
parameters phi,del1,del2,bet,gam,gamu,gamd,nupar,kappa,b,thetadu;
del1 = 0.1; del2 = 0.1;
phi = 0.33; 
bet = .99; 
gamu=.01; gamd=.003; 
thetadu=0.3;
nupar = 1;
gam = .25;
kappa=0.59;
b=0.65;

model; 
// first order conditions
  log(gu)=log(1+gamu)+vu;  //gu has mean gamu
  log(gd)=log(1+gamd)+thetadu*log(Bu(-1)/Bd(-1))+thetadu*log((1+gamu)/(1+gamd))+vd;
  #gc=(1+gamd)^.67*(1+gamu)^.33-1;
  chi = (1/c)*(1/(1-b*(1+gc)*((c(-1))/c))-bet*b/((c(+1)/(c*(1+gc)))-b));
  qd = bet*(chi(+1)/chi)*(qd(+1)*(1-del1)+phi*Lam(+1)*(Bd(+1)/Bu(+1))^(1-phi)*(kd(+1)/(Bu(+1)*nd(+1)))^(phi-1)); 
  qu = bet*(chi(+1)/chi)*(qu(+1)*(1-del2)+mu(+1)*phi*A(+1)*(ku(+1)/(Bu(+1)*nu(+1)))^(phi-1)); 
  chi*(1-phi)*Lam*Bd^(1-phi)*Bu^phi*(kd/(Bu*nd))^phi=gam*(nu+nd)^(1/nupar);
  qd*(1-Omegad-Omegadprime*(id/(id(-1)*(1+gamu))))=mu; 
  qu*(1-Omegau-Omegauprime*(iu/(iu(-1)*(1+gamu))))=mu; 
  c=Lam*kd^phi*(Bd*nd)^(1-phi);
  kd*(1-del1)+(1-Omegad)*id=kd(+1);
  ku*(1-del2)+(1-Omegau)*iu=ku(+1);
  nd+nu = n;
  A*ku^phi*(Bu*nu)^(1-phi)=iu+id;
  ii=iu+id;
  y=c+qu*iu+qd*id;
  Lam=1; //This is if only A is shocked
  A=1;
  Omegau=0.5*kappa*(iu/(iu(-1)*(1+gamu))-1)^2;
  Omegad=0.5*kappa*(id/(id(-1)*(1+gamu))-1)^2;
  Omegauprime=kappa*(iu/(iu(-1)*(1+gamu))-1);
  Omegadprime=kappa*(id/(id(-1)*(1+gamu))-1);
   
  ng=(n-n(-1))/n(-1);
  yg=0.7*cg+0.3*iig;
  iig=(ii-ii(-1))/ii(-1);
  cg=(c-c(-1))/c(-1);
  mu=Lam*Bd*(kd/(Bd*nd))^phi/(A*Bu*(ku/(Bu*nu))^phi);
  qug=(qu-qu(-1))/qu(-1);
  qdg=(qd-qd(-1))/qd(-1);
  mug=(mu-mu(-1))/mu(-1);
  end;
 
initval;
A = 1; 
Lam=1;
gu=1.01;
gd=1.003;

ku = 2.441; kd = 5.712;
qu = 1.012; qd = 1.012;
iu = 0.281; id = 0.657;
n =1.956;
nu = 0.586; nd = 1.370;
Lam = 1;
c = 2.195;
vd = 0; vu=0;
A = 1; Lam=1;
ii = 0.938;
y = 3.133;
Omegau=0; Omegad=0;
Omegauprime=0; Omegadprime=0;
chi=.4966;
cg=.002;
iig=.005;
yg=.005;
ng=0;
mu=1;
qug=.02;qug=.02;mug=.02;
end;
 
steady;
check;

shocks;
var vd; stderr 0.02;
var vu; stderr 0.02;
end;

stoch_simul(irf=150);

The upload still wasn’t working, but the ‘’’ thing seemed to work.

It seems the var-statement got lost.

Corrected. I had it on the same line as the ‘’'.

In a nutshell, you have
\ln \left( {{g^d_t}} \right) = \theta \ln \left( {\frac{{B_{t - 1}^u}}{{B_{t - 1}^d}}} \right) + {v_t}
Given the declared trends in the B, you can write this as
\ln \left( {{g^d_t}} \right) = \theta \ln \left( {\frac{{\frac{{{\tilde B}_t^u}}{{g_t^u}}}}{{\frac{{\tilde B_t^d}}{{g_t^d}}}}} \right) + {v_t}
i.e. going backwards in time using the growth rate from yesterday to today. But this shows you that when shocking the growth rate g^u_t will affect your process.

Sorry, but I don’t understand this explanation. Yes, B^u_t/g^u_t = B^u_{t-1}, so how does the shock to g^u_t show up here? The only time t variable on the RHS is v_t, the shock to g^d_t. Unless you’re saying that Dynare does something with B^u and B^d that somehow introduces the date t shock to g^u into the equation. But the math says that only date t-1 and earlier shocks to g^u are in the equation for g^d_t.

I need to think more about this. But what exactly are you trying to do? B^u_{t-1} is declared as pure trend (trend_var) in your model.

Thank you, and I will try to explain more clearly. B^u and B^d are stochastic trends, with stochastic growth rates g^u-1 and g^d-1. The error correction term \theta \ln(B^u_{t-1})/\ln(B^d_{t-1}) keeps the two trends cointegrated. A shock to g^u_t (denoted v^u_t) should gradually transmit to B^d_t (beginning at t+1) while a shock to g^d_t dissipates. The attached spreadsheet illustrates what I thought would be the irfs from each shock (with \theta=0.5). But the Dynare code doesn’t seem to produce those dynamics.
ECM.xlsx (20.7 KB)

I opened a ticket on this issue, discussing a potential flaw in Dynare’s detrending engine:

Thanks, I will keep an eye out for the response. In the meantime, I’d like to ask a related question about how to “read” the irf results for variables with stochastic trends. The manual says, “The IRFs are computed as the difference between the trajectory of a variable following a shock at the beginning of period 1 and its steady state value.” Suppose a model with stochastic trend A, and a variable x that trends with A, so there would be statements

trend_var (growth_factor=g) A;
var (deflator=A) x;

where, say, g = \gamma(1 + u), where \gamma is a parameter (a number like 1.02 if A has a mean growth rate of 2%) and u is a mean zero exogenous shock.
Suppose the steady state value of (normalized) x is 2, and I simulate a 0.05 u shock, and I see a resulting irf for x of -0.04, -0.02, -0.01, etc.
My presumption is that these values are relative to x=2.1 (the new steady state value of x after the shock, which would be 2\times 1.05=2.1, ignoring \gamma), so the simulated path of normalized x would be x=2 (the starting value), 2.06, 2.08, 2.09, etc.

Does all that seem correct? Or perhaps more precisely, the path would actually be 2,1.96\times1.05,1.98\times1.05, 1.99\times1.05,...=2,2.058,2.079,2.0895,...? (In other words, the irfs are relative to the normalized steady state of 2, but have to be multiplied by 1.05.) And it’s ok to ignore \gamma in these calculations?

I should add, the reason I’m asking is that when I apply the above procedure in a model I think I understand (such as the one in the .mod file I provided above), I’m getting nonsensical results, like capital stocks that jump immediately most of the way toward the new steady state (as x does in the above example). So the above can’t be right.

Sorry for the delay. I am a bit confused by your question. Your are working in a stochastic context. Shocks in your model are not permanent. Thus, there is no new steady state.

My language was probably unclear. The models have a unit root, so a 0.02 shock to g^u permanently increases the level of B^u by 2%, so eventually the capital stocks.k^u and k^d, and the level of investment should increase by 2%, while the models imply a 0.67% long-run increase in consumption c. Of course the deflated variables are stationary, but I want to see the paths of the undeflated levels. .

In fact I tweaked the code in the original .mod file (attached as Model_hfac.mod) and (for reasons that are not entirely clear to me) now actually get sensible looking results. So far so good. However, with a different though related model with the same long-run behavior (Model_fttb.mod) I am still getting incorrect results for the capital stocks (which only grow by 0.1%) and consumption (which jumps 0.5% immediately, impossible given that capital and labor in the downstream sector initially decline).

The only clue I can see is that if I deflate k^u and k^d by B^u, I get a “can’t find steady state” error, but if I deflate them by B^u(t+1) the code runs but with the bad results.

I understand you can’t go through the code in detail, but if you have any idea what might be wrong (especially given the above “clue”) it would be greatly appreciated. Thanks.
[Having trouble uploading files again, so I will try to put the code in directly below.]

/* 
Model_hfac.mod: Model with habit formation and investment adjustment costs. 
Upstream sector produces investment good, downstream produces consumption. 
Two stochastic trends in technology.
*/

var nd,nu,n,A,Lam,gu,Omegau,Omegauprime,Omegad,Omegadprime,ng,yg,iig,cg,qug,qdg,mug,gd,kug,kdg,nug,ndg;
trend_var(growth_factor=gu) Bu;
trend_var(growth_factor=gd) Bd;
model_local_variable gc;
var(deflator=Bu) iu,id,ii;
var(deflator=Bu) ku,kd;
var(deflator=Bu^.33*Bd^.67) c,y ;
var(deflator=Bu^(-.33)*Bd^(-.67)) chi;
var(deflator=Bu^(-.67)*Bd^.67) qu,qd,mu; 

varexo vd,vu;
parameters phi,del1,del2,bet,gam,gamu,gamd,nupar,kappa,b,thetadu;
del1 = 0.1; del2 = 0.1;
phi = 0.33; 
bet = .99; 
gamu=.01; gamd=.003; 
//thetadu=0.3;
thetadu=0;
nupar = 1;
gam = .25;
kappa=0.59;
b=0.65;

model; 
// first order conditions
//growth processes
  log(gu)=log(1+gamu)+vu;  //gu has mean gamu
  log(gd)=log(1+gamd)+thetadu*log(Bu(-1)/Bd(-1))+thetadu*log((1+gamu)/(1+gamd))+vd;
  #gc=(1+gamd)^.67*(1+gamu)^.33-1;

  chi = (1/c)*(1/(1-b*(1+gc)*((c(-1))/c))-bet*b/((c(+1)/(c*(1+gc)))-b));  //u'(c)
  //FOCs for capital stocks
  qd = bet*(chi(+1)/chi)*(qd(+1)*(1-del1)+phi*Lam(+1)*(Bd(+1)/Bu(+1))^(1-phi)*(kd/(Bu(+1)*nd(+1)))^(phi-1)); 
  qu = bet*(chi(+1)/chi)*(qu(+1)*(1-del2)+mu(+1)*phi*A(+1)*(ku/(Bu(+1)*nu(+1)))^(phi-1)); 
  //labor supply
  chi*(1-phi)*Lam*Bd^(1-phi)*Bu^phi*(kd(-1)/(Bu*nd))^phi=gam*(nu+nd)^(1/nupar);
  //investment with adjustment costs
  qd*(1-Omegad-Omegadprime*(id/(id(-1)*(1+gamu))))=mu; 
  qu*(1-Omegau-Omegauprime*(iu/(iu(-1)*(1+gamu))))=mu; 
  c=Lam*kd(-1)^phi*(Bd*nd)^(1-phi);  //downstream production
  kd(-1)*(1-del1)+(1-Omegad)*id=kd;  //capital accumulation
  ku(-1)*(1-del2)+(1-Omegau)*iu=ku;
  nd+nu = n;
  A*ku(-1)^phi*(Bu*nu)^(1-phi)=iu+id;  //upstream production
  ii=iu+id;
  y=c+qu*iu+qd*id;
  Lam=1; //This is if only A is shocked
  A=1;
  Omegau=0.5*kappa*(iu/(iu(-1)*(1+gamu))-1)^2;
  Omegad=0.5*kappa*(id/(id(-1)*(1+gamu))-1)^2;
  Omegauprime=kappa*(iu/(iu(-1)*(1+gamu))-1);
  Omegadprime=kappa*(id/(id(-1)*(1+gamu))-1);
  
  //various growth rates
  ng=(n-n(-1))/n(-1);
  nug=(nu-nu(-1))/nu(-1);
  ndg=(nd-nd(-1))/nd(-1);
  yg=0.7*cg+0.3*iig;
  iig=(ii-ii(-1))/ii(-1);
  cg=(c-c(-1))/c(-1);
  kug=(ku(+1)-ku)/ku;
  kdg=(kd(+1)-kd)/kd;
  mu=Lam*Bd*(kd(-1)/(Bd*nd))^phi/(A*Bu*(ku(-1)/(Bu*nu))^phi);
  qug=(qu-qu(-1))/qu(-1);
  qdg=(qd-qd(-1))/qd(-1);
  mug=(mu-mu(-1))/mu(-1);
  end;
 
initval;
A = 1; 
Lam=1;
gu=1.01;
gd=1.003;

ku = 2.441; kd = 5.712;
qu = 1.012; qd = 1.012;
iu = 0.281; id = 0.657;
n =1.956;
nu = 0.586; nd = 1.370;
Lam = 1;
c = 2.195;
vd = 0; vu=0;
A = 1; Lam=1;
ii = 0.938;
y = 3.133;
Omegau=0; Omegad=0;
Omegauprime=0; Omegadprime=0;
chi=.4966;
cg=.002;
iig=.005;
kug=.005;
kdg=.005;
yg=.005;
ng=0; nug=0;ndg=0;
mu=1;
qug=.02;qug=.02;mug=.02;
end;
 
steady;
check;

shocks;
//var vd; stderr 0.02;
var vu; stderr 0.02;
end;

stoch_simul(irf=150);
// Model_fttb.mod
// Upstream sector produces investment goods, downstream produces consumption. Two stochastic trends with
// shocks vu and vd. Five stages of production of investment goods, capital adjustment costs in each sector.
// July 2023

// endogenous variables
var nd,nu,n,A,Lam,gu,gd,iig,cg,kug,kdg,kappa,wipg,ndg,nug;
model_local_variable C1,C2,D1,D2,gc;
trend_var(growth_factor=gu) Bu;
trend_var(growth_factor=gd) Bd;
var(deflator=Bu) iu,id,ii,z0u,z0d,z1u,z1d,z2u,z2d,z3u,z3d,z4u,z4d,Z,wip,iw;
var(deflator=Bu(+1)) ku,kd;
var(deflator=Bu^.33*Bd^.67) c;
var(deflator=Bu^(-.67)*Bd^.67) pu,pd,qu,qd,mu;
var(deflator=Bu^(-.33)*Bd^(-.67)) chi;

varexo vu,vd;
parameters sigma,alpha,phi,del,eta,bet,gam,nupar,S,gamu,gamd,rhou,rhod,thetaud,thetadu;
S=4; //Stages of production 
sigma=0.8;
//sigma=0.5;
alpha=1/(S+1);
del = 0.1;
phi = 0.33;
eta=.1716;
bet = .99; 
gamu=.013; gamd=.0046;

nupar = 1;
gam = .25;
rhou=0; rhod=0;
//C1 = (del1+gu)^(1/eta); C2 = (del2+gu)^(1/eta);
//D1 = (del1+gu)/(1-eta); D2 = (del2+gu)/(1-eta);
thetaud = 0;
thetadu=0.254; thetadu=0;
//gc=(1+gamd)^.67*(1+gamu)^.33-1;
//muu=0.1; mud=0.1;
model;
// first order conditions
    //growth processes
  log(gu)=(1-rhou)*log(1+gamu)+rhou*log(gu(-1))+vu;
  log(gd)=(1-rhod)*log(1+gamd)+rhod*log(gd(-1))+thetadu*log(Bu(-1)/Bd(-1))+thetadu*log((1+gamu)/(1+gamd))+vd;
  #gc=(1+gamd)^.67*(1+gamu)^.33-1; //consumption growth    
  #C1 = (del+gamu)^(1/eta); #C2 = (del+gamu)^(1/eta); //capital adjustment costs calibration
  #D1 = (del+gamu)/(1-eta); #D2 = (del+gamu)/(1-eta);
  chi = 1/c;   //u'(c)
        //FOCs for id,iu,kd,ku given capital adjustment costs
  pd = qd*C1*(id/kd(-1))^(-1/eta);
  pu = qu*C2*(iu/ku(-1))^(-1/eta);
  qd = bet*(chi(+1)/chi)*(qd(+1)*(1-del-C1/(1-eta)*(id(+1)/kd)^(1-1/eta)+D1)+phi*Lam(+1)*(Bd(+1)/Bu(+1))^(1-phi)*(kd/(Bu(+1)*nd(+1)))^(phi-1)); 
  qu = bet*(chi(+1)/chi)*(qu(+1)*(1-del-C2/(1-eta)*(iu(+1)/ku)^(1-1/eta)+D2)+mu(+1)*phi*A(+1)*(ku/(Bu(+1)*nu(+1)))^(phi-1)); 
   //labor supply
  chi*(1-phi)*Bd*Lam*(kd(-1)/(Bd*nd))^phi=gam*n^(1/nupar);
  pd*chi*(z0d/(alpha*id))^(-1/sigma)*(1-phi)*A*Bu*(ku(-1)/(Bu*nu))^phi=gam*n^(1/nupar); 
    //investment goods at each stage  
  bet^4*pu(+4)*(chi(+4)/chi)*(z4u/(alpha*iu(+4)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  bet^3*pu(+3)*(chi(+3)/chi)*(z3u/(alpha*iu(+3)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  bet^2*pu(+2)*(chi(+2)/chi)*(z2u/(alpha*iu(+2)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  bet*pu(+1)*(chi(+1)/chi)*(z1u/(alpha*iu(+1)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  pu*(z0u/(alpha*iu))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  
  bet*pd(+1)*(chi(+1)/chi)*(z1d/(alpha*id(+1)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  bet^2*pd(+2)*(chi(+2)/chi)*(z2d/(alpha*id(+2)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  bet^3*pd(+3)*(chi(+3)/chi)*(z3d/(alpha*id(+3)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  bet^4*pd(+4)*(chi(+4)/chi)*(z4d/(alpha*id(+4)))^(-1/sigma)=pd*(z0d/(alpha*id))^(-1/sigma);
  
  //downstream production
  c=Lam*kd(-1)^phi*(Bd*nd)^(1-phi);
  //capital accumulation
  kd(-1)*(1-del)+(C1/(1-1/eta)*(id/kd(-1))^(1-1/eta)+D1)*kd(-1)=kd;
  ku(-1)*(1-del)+(C2/(1-1/eta)*(iu/ku(-1))^(1-1/eta)+D2)*ku(-1)=ku;
  //investment from stages of production
  (alpha^(1/sigma)*z0d^((sigma-1)/sigma)+alpha^(1/sigma)*z1d(-1)^((sigma-1)/sigma)+alpha^(1/sigma)*z2d(-2)^((sigma-1)/sigma)+alpha^(1/sigma)*z3d(-3)^((sigma-1)/sigma)+alpha^(1/sigma)*z4d(-4)^((sigma-1)/sigma))^(sigma/(sigma-1))=id;
  (alpha^(1/sigma)*z0u^((sigma-1)/sigma)+alpha^(1/sigma)*z1u(-1)^((sigma-1)/sigma)+alpha^(1/sigma)*z2u(-2)^((sigma-1)/sigma)+alpha^(1/sigma)*z3u(-3)^((sigma-1)/sigma)+alpha^(1/sigma)*z4u(-4)^((sigma-1)/sigma))^(sigma/(sigma-1))=iu;
  //upstream production
  A*ku(-1)^phi*(nu*Bu)^(1-phi)=Z;
  //works-in-process inventories
  wip = z1u(-1)+z2u(-1)+z2u(-2)+z3u(-1)+z3u(-2)+z3u(-3)+z4u(-1)+z4u(-2)+z4u(-3)+z4u(-4)+z1d(-1)+z2d(-1)+z2d(-2)+z3d(-1)+z3d(-2)+z3d(-3)+z4d(-1)+z4d(-2)+z4d(-3)+z4d(-4);
  wipg=(wip(+1)-wip)/wip;
  iw = z1u-z1u(-1)+z2u-z2u(-2)+z3u-z3u(-3)+z4u-z4u(-4)+
         z1d-z1d(-1)+z2d-z2d(-2)+z3d-z3d(-3)+z4d-z4d(-4);
  //aggregate labor and investment
  nd+nu = n;
  ii=iu+id;
  //growth rates of investment, consumption, labor, and capital
  iig=(ii-ii(-1))/ii(-1);
  cg=(c-c(-1))/c(-1);
  ndg=(nd-nd(-1))/nd(-1);
  nug=(nu-nu(-1))/nu(-1);
  kug=(ku(+1)-ku)/ku;
  kdg=(kd(+1)-kd)/kd;
    //Lam=A; //This is for a shock to both Lam and A, perfectly correlated.
  Lam=1; //This is if only A is shocked
  A=1; //This is if only Lam is shocked
  mu=pd*(z0d/(alpha*id))^(-1/sigma);
  kappa=(ku(-1)+kd(-1))/n;
  //kappa=(ku+kd)/n;
  Z=z0u+z0d+z1u+z1d+z2u+z2d+z3u+z3d+z4u+z4d;
end;
 
steady_state_model;
gu=1+gamu;
gd=1+gamd;
A=1;
Lam=1;
pd=alpha^(1/(1-sigma))*(1+(gu/bet)^(1-sigma)+(gu^2*bet^(-2))^(1-sigma)+(gu^3*bet^(-3))^(1-sigma)+(gu^4*bet^(-4))^(1-sigma))^(1/(1-sigma));
pu=pd;
kappa=(pd*(gu/bet-(1-del))/phi)^(1/(phi-1));
n=(((1-phi)*kappa^phi)/(gam*(kappa^phi-((kappa*(del+gamu))*alpha)*(pd^sigma*(1+bet^sigma*gu^(1-sigma)+bet^(2*sigma)*gu^(2*(1-sigma))+bet^(3*sigma)*gu^(3*(1-sigma))+bet^(4*sigma)*gu^(4*(1-sigma)))))))^(nupar/(1+nupar));  
ii=kappa*n*(del+gamu);
Z=alpha*ii*(pd^sigma*(1+bet^sigma*gu^(1-sigma)+bet^(2*sigma)*gu^(2*(1-sigma))+bet^(3*sigma)*gu^(3*(1-sigma))+bet^(4*sigma)*gu^(4*(1-sigma))));
c=kappa^phi*n-Z;
//k=kappa*n;
nd=c/kappa^phi;
nu=n-nd;
kd=kappa*nd;
ku=kappa*nu;
id=(del+gamu)*kd;
iu=(del+gamu)*ku;
z0d=id*alpha*pd^sigma;
z0u=iu*alpha*pu^sigma;
z1d=id*alpha*(pd*bet/gu)^sigma*gu;
z1u=iu*alpha*(pu*bet/gu)^sigma*gu;
z2d=id*alpha*(pd*bet^2*gu^(-2))^sigma*gu^2;
z2u=iu*alpha*(pu*bet^2*gu^(-2))^sigma*gu^2;
z3d=id*alpha*(pd*bet^3*gu^(-3))^sigma*gu^3;
z3u=iu*alpha*(pu*bet^3*gu^(-3))^sigma*gu^3;
z4d=id*alpha*(pd*bet^4*gu^(-4))^sigma*gu^4;
z4u=iu*alpha*(pu*bet^4*gu^(-4))^sigma*gu^4;
qd=pd;
qu=pu;
mu=1;
cg=gu^.33*gd^.67-1;
nug=0; ndg=0;
iig=gu-1;
kug=gu-1;
kdg=gu-1;
//gc=(1+gamd)^.67*(1+gamu)^.33-1;
chi=1/c;
wip = z1u/gu+z2u/gu+z2u/(gu^2)+z3u/gu+z3u/(gu^2)+z3u/(gu^3)+z4u/gu+z4u/(gu^2)+z4u/(gu^3)+z4u/(gu^4)+z1d/gu+z2d/gu+z2d/(gu^2)+z3d/gu+z3d/(gu^2)+z3d/(gu^3)+z4d/gu+z4d/(gu^2)+z4d/(gu^3)+z4d/(gu^4);
wipg=gu-1;
iw=wip*(gu-1);
end;

steady;

check;

shocks;
var vu; stderr 0.02;
//var vd; stderr 0.02;
end;
//stoch_simul(irf=40, periods=2000, drop=200);
stoch_simul(irf=150);
//simul(periods=100);

After looking at this for many hours, I think the source of the problem is the capital accumulation equations in the Model_fttb.mod file, along with how the variables are deflated. I haven’t figured out what the problem is yet, but it’s the main difference between the two models, and the irfs for capital the most clearly wrong. The equations worked for the stationary case, but something went wrong in moving to the unit root/stochastic trend version of the model. I’m sure I can figure it out.

Sorry for the delay, I was travelling. The best way to check what is going on is to inspect the LaTeX-output of the detrended model with

write_latex_original_model;
collect_latex_files;

That will create _TeX_binder.tex-file with the equations.

Thanks, I will try that. One issue may be that the capital adjustment cost involves I_t/K_{t-1}, so if I_t is deflated by B^u_t and K_{t-1} is deflated by B^u_{t-1} there’s an extra 1+g term and the parameters C and D have to be slightly different to satisfy the steady state conditions. I’m guessing that’s why Dynare wants K_{t-1} deflated by B^u_t, and that might throw off the impulse responses for K. But if I adjust the parameters I can have K_{t-1} deflated by B^u_{t-1}. We’ll see if that helps.

Hi, I am coming back to this issue almost a year later, as I’m revising the paper. I wasn’t sure whether to respond in the Gitlab hub (requires registration), but this seems to be the right place.

As a reminder, the model has two stochastic trends with different mean growth rates, and I want to allow them to be cointegrated, using an Error Correction Model.

Sebastien wrote:

I think the problem is that the detrending engine is here used in a way for which it has not been designed.

gd and gu are supposed to be the stochastic growth rates of Bu and Bd. In our framework, gd and gu are therefore supposed to determine Bu and Bd.

But here there is also the reverse causality, where Bu and Bd determine gu. This is not something that we had in mind when designing the engine.*>
More fundamentally, the ratio Bu(-1)/Bd(-1) is of unknown value, since those two variables are I(1) and thus this ratio has no steady state value. I don’t see how we could compute a meaningful solution for this model.

My response/question is this: If log(B^u) and log(B^d) are cointegrated, then log(B^u/B^d) in principle does have a steady state, in the sense that it is trend stationary (just like the other variables in the model, which has balanced growth). So I am wondering if a detrended version of log(B^u/B^d) can be used in the specification of the shock processes. I have done this, in the attached file hfac2x.mod (calling the detrended versions X^u and X^d). log(X^u/X^d) is stationary as long as the error correction coefficient \theta is positive.

The model solves, and I can do stochastic simulations, but I am unable to estimate the error correction parameter \theta ((minus) the hessian matrix at the “mode” is not positive definite!), even though the mode check graphs all look well-behaved. In addition, if I fix \theta at some reasonable value rather than estimate it, I can estimate the remaining parameters, though the estimates look “off” compared to those I’ve gotten without cointegration (as in the attached file hfac2.mod).

Is it legitimate to use the trend_var variables X^u and X^d in this way? Sebastien’s comments above suggest that maybe it’s not. And if not, is there some workaround that would allow cointegration of the two stochastic trends? Other research (e.g. Schmitt-Grohe and Uribe, Econometrica, 2011) has found cointegration of these stochastic trends to be important.
hfac2x.mod (4.0 KB)
hfac2.mod (3.4 KB)
cidata59g2024.xlsx (15.6 KB)