Colinear equations - model with 2 sectors and investment

Hi All
I’m replicating an academic paper of an economy with two sectors (tradables and no-tradables) investment and one shock over productivity.

I’m getting the error message:“Error using print_info (line 32)
Blanchard & Kahn conditions are not satisfied: indeterminacy.”

I’m new in dynare and i’m having troubles to identify the colinear equation. Any help will be really appretiated.

Kind regards
Andrea


%model
var   A Uc Pc q k i pProdZ YtT YtN Yt Bt B_Y cT cN xN xT  ;

varexo eps;


parameters  pProd pAlpha pIntRate R pSigma pDelta kappa bbar_L bbar_H 
elast_c pIta elast_inv pTheta elastC_T_NT elastI_T_NT pProdZ_SS
rho  pPi pOmega pBeta r sigma PN_SS_res pN;

pProd             = 0.5; % in paper "a"  or 1-a
pAlpha            = 0.35; % alpha, standar value
pIntRate          = 0.02; % interest rate, standard value
R                 = pIntRate+1; % resultado
pSigma            = 4.00; % sigma, standard value
pDelta            = 0.10; % depreciation rate, standard value
kappa             = 0.09; % ACF de datos!!!
bbar_L            = -0.275 ; % ACF de datos!!!
bbar_H            = -0.31 ; % ACF de datos!!!
%PN_SS_res         = 2.10075281893842;
PN_SS_res         = 2.09368851037420;
pN             = log(PN_SS_res);
elast_c           = 0.83; % Bianchi (2011)
pIta              = 1/elast_c- 1; % resultado
elast_inv         = elast_c ; % resultado
pTheta            = 1/elast_c -1; % resultado
elastC_T_NT       = 1/(1+pIta); % resultado
elastI_T_NT       = 1/(1+pTheta); % resultado

pProdZ_SS         = 1;

rho            = 0.3;  % ACF de datos!!!
sigma          = 0.021;
pOmega         = 0.314;
%pBeta          = 0.962;
pBeta          = 1/R;
r              = R-1;
pPi            = pOmega;

model;
pProdZ(+1)=rho*pProdZ+ sigma*eps;

exp(A) = pOmega*exp(cT)^(-pIta)+(1-pOmega)*exp(cN)^(-pIta); %ACF ok base agregador

exp(Uc) = exp(A)^( (pSigma-1-pIta)/pIta )*pOmega*exp(cT)^(-1-pIta); %ACF ok CPO cT

exp(Uc) = pBeta*R*exp(Uc(+1)); %ACF ok Euler deuda

exp(q)*exp(Uc) =  pBeta*exp(Uc(+1))*( (1-pDelta)*exp(q(+1))+
   pAlpha*exp(pProdZ(+1))*exp(k(+1))^(pAlpha-1)*(pProd*exp(pN) + 1 - pProd) ) ; %ACF ok cpo k

exp(Pc) = (pOmega^(1/(1+pIta))+(1-pOmega)^(1/(1+pIta))*exp(pN)^(pIta/(1+pIta)))^((1+pIta)/pIta);

exp(q) = exp(Pc) ; % ACF ok Price q

exp(i)=exp(k(+1))-(1-pDelta)*exp(k); %ACF ok evolucion k

exp(YtT) = exp(pProdZ)*(1-pProd)*exp(k)^pAlpha;

exp(YtN) = exp(pProdZ)*pProd*exp(k)^pAlpha;

exp(Yt) = ( exp(pN)*exp(YtN) + exp(YtT) ); %ACF Producción

exp(xN) = ( (1-pPi)^(1/(1+pTheta))*(exp(Pc)/exp(pN))^(1/ (1+pTheta) ) ) * exp(i) ;

exp(cN) = exp(YtN) - exp(xN);

exp(xT) = ( exp(pN)*pPi/(1-pPi) )^(1/(1+pTheta))*exp(xN);

exp(cT) = exp(YtT) - exp(xT) + Bt -  Bt(-1)*R ;

B_Y = Bt/exp(Yt);


end;

steady_state_model;
pProdZ = log(pProdZ_SS);
Bt = 1;
Pc = log( (pOmega^(1/(1+pIta))+(1-pOmega)^(1/(1+pIta))*exp(pN)^(pIta/(1+pIta)) )^((1+pIta)/pIta));
q = log( exp(Pc) ); % ACF ok Price q
k  = log ( ( pAlpha*(pProd*exp(pN) + 1 -pProd) / 
   ( exp(q)*(1/pBeta - (1-pDelta) ) )  )^(1/(1-pAlpha)) ); % ACF ok Euler Capital
i = log(pDelta*exp(k)); %ACF ok evolucion k
YtT = log((1-pProd)*exp(k)^pAlpha);
YtN = log(pProd*exp(k)^pAlpha);
Yt = log( ( exp(pN)*exp(YtN) + exp(YtT) ) ); %ACF Producción;
xN = log( ( (1-pPi)^(1/(1+pTheta))*(exp(Pc)/exp(pN))^(1/ (1+pTheta) ) ) * exp(i));
cN = log (exp(YtN)-exp(xN));
xT = log ( ( exp(pN)*pPi/(1-pPi) )^(1/(1+pTheta))*exp(xN) );
cT = log(exp(YtT)-exp(xT)-Bt*(R-1));
B_Y = Bt/exp(Yt);
A = log(pOmega*exp(cT)^(-pIta)+(1-pOmega)*exp(cN)^(-pIta)); %ACF ok base agregador
Uc = log( exp(A)^( (pSigma-1-pIta)/pIta )*pOmega*exp(cT)^(-1-pIta) ); %ACF ok CPO cT

end;
 

shocks;
var eps= 1; 
end;

options.TolFun=1e-2;
%stoch_simul(order=1,irf=11,nograph,noprint);

stoch_simul(order=1,irf=11,contemporaneous_correlation);
1 Like

Check your timing. For example, the timing of pProdz in

pProdZ(+1)=rho*pProdZ+ sigma*eps;

and of k does not conform to Dynare’s timing convention

1 Like

Thanks a lot, I’ve changed the timing in the equations of evolutions of capital and shock. Now it is working.
However, all steady state values are zero. Is there anything else I’m missing (sorry to bother but I’m new at Dynare)
Regards
Andrea

%model
var   C Uc B_Y Bt q k i pProdZ YtT YtN Yt cT cN xN xT pN ;

varexo eps;

predetermined_variables k;

parameters  pProd pAlpha pIntRate R pSigma pDelta kappa bbar_L bbar_H 
elast_c pIta elast_inv pTheta elastC_T_NT elastI_T_NT pProdZ_SS
rho  pPi pOmega pBeta r sigma PN_SS_res ;

pProd             = 0.5; % in paper "a"  or 1-a
pAlpha            = 0.35; % alpha, standar value
pIntRate          = 0.02; % interest rate, standard value
R                 = pIntRate+1; % resultado
pSigma            = 4.00; % sigma, standard value
pDelta            = 0.10; % depreciation rate, standard value
kappa             = 0.09; % ACF de datos!!!
bbar_L            = -0.275 ; % ACF de datos!!!
bbar_H            = -0.31 ; % ACF de datos!!!
PN_SS_res         = 2.10075281893842;
%PN_SS_res         = 2.09368851037420;
%pN             = log(PN_SS_res);
elast_c           = 0.83; % Bianchi (2011)
pIta              = 1/elast_c- 1; % resultado
elast_inv         = elast_c ; % resultado
pTheta            = 1/elast_c -1; % resultado
elastC_T_NT       = 1/(1+pIta); % resultado
elastI_T_NT       = 1/(1+pTheta); % resultado

pProdZ_SS         = 1;

rho            = 0.3;  % ACF de datos!!!
sigma          = 0.021;
pOmega         = 0.314;
%pBeta          = 0.962;
pBeta          = 1/R;
r              = R-1;
pPi            = pOmega;


model;
%Shock
pProdZ=rho*pProdZ(-1)+ sigma*eps;

%Consumo
exp(C) = (pOmega*exp(cT)^(-pIta)+(1-pOmega)*exp(cN)^(-pIta))^(-1/pIta); 

%FOC cT
exp(Uc) = exp(C)^( pIta+1-pSigma )*pOmega*exp(cT)^(-1-pIta);

%FOC deuda
exp(Uc) = pBeta*R*exp(Uc(+1)); %ACF ok Euler deuda

%FOC k
exp(q)*exp(Uc) = pBeta*exp(Uc(+1))* ( (1-pDelta)*exp(q(+1))
    +pAlpha*exp(pProdZ)*exp(k(+1))^(pAlpha-1)*(pProd*exp(pN(+1)) + 1 - pProd) );

%FOC i   
exp(q) = (pPi^(1/(1+pTheta))
    +(1-pPi)^(1/(1+pTheta))*exp(pN)^(pTheta/(1+pTheta)))^((1+pTheta)/pTheta);

%evolution k
exp(i)=exp(k(+1))-(1-pDelta)*exp(k); 

%production tradable
exp(YtT) = exp(pProdZ)*(1-pProd)*exp(k)^pAlpha;

%production no tradable
exp(YtN) = exp(pProdZ)*pProd*exp(k)^pAlpha;

%GDP
exp(Yt) = ( exp(pN)*exp(YtN) + exp(YtT) ); 

%inputs no tradable (de market clearing)
exp(xN) =  (1-pPi)^(1/(pTheta+1))*( pPi^(1/(pTheta+1))*exp(pN)^(-pTheta/(pTheta+1))
     +(1-pPi)^(1/(pTheta+1)) )^(- 1/ pTheta )  * exp(i) ;

% market clearing no tradable
exp(cN) = exp(YtN) - exp(xN);

%de TMS xT y xN
exp(xT) = ( exp(pN)*pPi/(1-pPi) )^(1/(1+pTheta))*exp(xN);

%de TMS cT y cN
exp(cT) = ( exp(pN)*pOmega/(1-pOmega) )^(1/(1+pIta))*exp(cN);

%evolution debt
Bt = - exp(YtT) + exp(xT) + exp(cT) + Bt(-1)*R ;

%debt to GDP
B_Y = Bt/exp(Yt);
end;


steady_state_model;
pProdZ = log(pProdZ_SS);
%Bt = 1;
pN = log(PN_SS_res);
q = log( (pPi^(1/(1+pTheta))
    +(1-pPi)^(1/(1+pTheta))*exp(pN)^(pTheta/(1+pTheta)))^((1+pTheta)/pTheta) ); % ACF ok Price q
k  = log ( ( pAlpha*(pProd*exp(pN) + 1 -pProd) / 
   ( exp(q)*(1/pBeta - (1-pDelta) ) )  )^(1/(1-pAlpha)) ); 
i = log(pDelta*exp(k)); 
YtT = log(exp(pProdZ)*(1-pProd)*exp(k)^pAlpha);
YtN = log(exp(pProdZ)*pProd*exp(k)^pAlpha);
Yt = log( ( exp(pN)*exp(YtN) + exp(YtT) ) ); 
xN = log( (1-pPi)^(1/(pTheta+1))*( pPi^(1/(pTheta+1))*exp(pN)^(-pTheta/(pTheta+1))
    +(1-pPi)^(1/(pTheta+1)) )^(- 1/ pTheta )  * exp(i));
cN = log (exp(YtN)-exp(xN));
xT = log(( exp(pN)*pPi/(1-pPi) )^(1/(1+pTheta))*exp(xN));
cT = log( ( exp(pN)*pOmega/(1-pOmega) )^(1/(1+pIta))*exp(cN));
Bt = (1/(R-1))*(exp(YtT)-exp(xT)-exp(cT));
B_Y = Bt/exp(Yt);
C = log((pOmega*exp(cT)^(-pIta)+(1-pOmega)*exp(cN)^(-pIta))^(-1/pIta)); 
Uc = log(exp(C)^( pIta+1-pSigma )*pOmega*exp(cT)^(-1-pIta));
end;

shocks;
var eps= 5; 
end;

options.TolFun=1e-2;
%stoch_simul(order=1,irf=11);

stoch_simul(order=1,irf=11,contemporaneous_correlation);
1 Like

If you use steady, you will see that the steady states are different from 0.

1 Like

Thanks a lot, i used the steady option bu. i’m getting NaN because of singularity problems. I’ve realized that i need to add a restriction to ensure stationarity. I’ve tried to to do it thorough an additional restriction on beta following Uribe & Schmitt Grohen. However, after changing the model this is not working.

Danke schön

%model
var   C Uc B_Y Bt q k i YtT YtN Yt cT cN xN xT pProdZ pN eBeta;

varexo eps;

predetermined_variables k;

parameters  pProd pAlpha pIntRate R pSigma pDelta kappa bbar_L bbar_H 
elast_c pIta elast_inv pTheta elastC_T_NT elastI_T_NT pProdZ_SS
rho  pPi pOmega pBeta sigma PN_SS_res r Phi ;

pProd             = 0.5; % in paper "a"  or 1-a
pAlpha            = 0.35; % alpha, standar value
pIntRate          = 0.02; % interest rate, standard value
R                 = pIntRate+1; % resultado
r                 = pIntRate;
pSigma            = 4.00; % sigma, standard value
pDelta            = 0.10; % depreciation rate, standard value
kappa             = 0.09; % ACF de datos!!!
bbar_L            = -0.275 ; % ACF de datos!!!
bbar_H            = -0.31 ; % ACF de datos!!!
PN_SS_res         = 2.10075281893842;
elast_c           = 0.83; % Bianchi (2011)
pIta              = 1/elast_c- 1; % resultado
elast_inv         = elast_c ; % resultado
pTheta            = 1/elast_c -1; % resultado
elastC_T_NT       = 1/(1+pIta); % resultado
elastI_T_NT       = 1/(1+pTheta); % resultado

pProdZ_SS         = 1;

rho            = 0.3;  % ACF de datos!!!
sigma          = 0.021;
pOmega         = 0.314;
pBeta          = 1/R;
pPi            = pOmega;
Phi            = 0.11;


model;
%Consumo
exp(C) = (pOmega*exp(cT)^(-pIta)+(1-pOmega)*exp(cN)^(-pIta))^(-1/pIta); 

%FOC cT
exp(Uc) = exp(C)^( pIta+1-pSigma )*pOmega*exp(cT)^(-1-pIta);

%FOC deuda
exp(Uc) = eBeta*(1+r)*exp(Uc(+1)); %ACF ok Euler deuda

%Beta
eBeta = (1+exp(cT))^(-eBeta);

%FOC k
exp(q)*exp(Uc) = eBeta*exp(Uc(+1))* ( (1-pDelta)*exp(q(+1))
    +pAlpha*exp(pProdZ)*exp(k(+1))^(pAlpha-1)*(pProd*exp(pN(+1)) + 1 - pProd) );

%FOC i   
exp(q) = (pPi^(1/(1+pTheta))
    +(1-pPi)^(1/(1+pTheta))*exp(pN)^(pTheta/(1+pTheta)))^((1+pTheta)/pTheta);

%evolution k
exp(i)=exp(k(+1))-(1-pDelta)*exp(k); 

%production tradable
exp(YtT) = exp(pProdZ)*(1-pProd)*exp(k)^pAlpha;

%production no tradable
exp(YtN) = exp(pProdZ)*pProd*exp(k)^pAlpha;

%GDP
exp(Yt) = ( exp(pN)*exp(YtN) + exp(YtT) ); 

%inputs no tradable (de market clearing)
exp(xN) =  (1-pPi)^(1/(pTheta+1))*( pPi^(1/(pTheta+1))*exp(pN)^(-pTheta/(pTheta+1))
     +(1-pPi)^(1/(pTheta+1)) )^(- 1/ pTheta )  * exp(i) ;

% market clearing no tradable
exp(cN) = exp(YtN) - exp(xN);

%de TMS xT y xN
exp(xT) = ( exp(pN)*pPi/(1-pPi) )^(1/(1+pTheta))*exp(xN);

%de TMS cT y cN
exp(cT) = ( exp(pN)*pOmega/(1-pOmega) )^(1/(1+pIta))*exp(cN);

%evolution debt
Bt = - exp(YtT) + exp(xT) + exp(cT) + Bt(-1)*(1+r) ;

%debt to GDP
B_Y = Bt/exp(Yt);

%Shock
pProdZ=rho*pProdZ(-1)+ sigma*eps;

end;

steady;
steady_state_model;
pProdZ = log(pProdZ_SS);
eBeta = pBeta;
pN = log(PN_SS_res);
cT = log(eBeta^(-1/eBeta)-1) ;
cN= log(exp(cT)/((exp(pN) *(pOmega/(pOmega)))^1/(1+pIta)));
q = log( (pPi^(1/(1+pTheta))
    +(1-pPi)^(1/(1+pTheta))*exp(pN)^(pTheta/(1+pTheta)))^((1+pTheta)/pTheta) ); % ACF ok Price q
k  = log ( ( pAlpha*(pProd*exp(pN) + 1 -pProd) / 
   ( exp(q)*(1/eBeta - (1-pDelta) ) )  )^(1/(1-pAlpha)) ); 
i = log(pDelta*exp(k)); 
YtN = log(exp(pProdZ)*pProd*exp(k)^pAlpha);
xN = log(exp(YtN)-exp(cN));
YtT = log(exp(pProdZ)*(1-pProd)*exp(k)^pAlpha);
Yt = log( ( exp(pN)*exp(YtN) + exp(YtT) ) ); 
%xN = log( (1-pPi)^(1/(pTheta+1))*( pPi^(1/(pTheta+1))*exp(pN)^(-pTheta/(pTheta+1))
    +(1-pPi)^(1/(pTheta+1)) )^(- 1/ pTheta )  * exp(i));
%cN = log (exp(YtN)-exp(xN));
xT = log(( exp(pN)*pPi/(1-pPi) )^(1/(1+pTheta))*exp(xN));
%cT = log( ( exp(pN)*pOmega/(1-pOmega) )^(1/(1+pIta))*exp(cN));
Bt = (1/r)*(exp(YtT)-exp(xT)-exp(cT));
B_Y = Bt/exp(Yt);
C = log((pOmega*exp(cT)^(-pIta)+(1-pOmega)*exp(cN)^(-pIta))^(-1/pIta)); 
Uc = log(exp(C)^( pIta+1-pSigma )*pOmega*exp(cT)^(-1-pIta));
end;
 


shocks;
var eps= 1; 
end;

options.TolFun=1e-2;
%stoch_simul(order=1,irf=11);

stoch_simul(order=1,irf=11,contemporaneous_correlation);
1 Like

You need to adjust your steady state to reflect the changes.

Thanks a lot. Now it is working, I’ve attached the last version of the code in case anyone finds it useful.
this is an economy with 2 sectors (tradables and non tradables), investment and capital accumulation that replicates the model in Bianchi y Mendoza (2020) “A Fisherian approach to financial crises: Lessons from the Sudden Stops literature”. I added stationarity through the discount factor.

Kind regards
Andrea

%model
var   Yt Bt B_Y ca ca_Y YtT YtN cT cN xN xT k i q pN  pProdZ eBeta xT_N Uc C;

varexo eps;

predetermined_variables k;

parameters  Alpha ri R Sigma Delta bbar_L bbar_H 
nu Ita mu Theta  Z_SS
rho Pi Omega pBeta sig_e pN_SS r Phi share;

share             = 0.5; % in paper "Alpha"  or 1-Alpha
Alpha            = 0.35; % alpha, standar value
ri          = 0.02; % interest rate, standard value
R                 = ri+1; % resultado
r                   = ri;
Sigma            = 4.00; % sig_e, standard value
Delta            = 0.10; % depreciation rate, standard value
bbar_L            = -0.275 ; % ACF de datos!!!
bbar_H            = -0.31 ; % ACF de datos!!!
pN_SS         = 2.10075281893842;
nu           = 0.83; % Bianchi (2011)
Ita              = 1/nu- 1; % resultado
mu         = nu ; % resultado
Theta            = 1/nu -1; % resultado

Z_SS         = 1;

rho            = 0.3;  % ACF de datos!!!
sig_e          = 0.021;
Omega         = 0.314;
pBeta          = 1/R;
Pi            = Omega;
Phi            = 0.11;


model;
%Consumo
exp(C) = (Omega*exp(cT)^(-Ita)+(1-Omega)*exp(cN)^(-Ita) )^(-1/Ita); 

%FOC cT
exp(Uc) = exp(C)^( Ita+1-Sigma )*Omega*exp(cT)^(-1-Ita);

%FOC deuda
exp(Uc) = eBeta*(1+r)*exp(Uc(+1)); %ACF ok Euler deuda

%Beta
eBeta = (1+exp(cT))^(-Phi);
%eBeta = pBeta;

%FOC k
exp(q)*exp(Uc) = eBeta*exp(Uc(+1))* ( (1-Delta)*exp(q(+1))
    +Alpha*exp(pProdZ)*exp(k(+1))^(Alpha-1)*(share*exp(pN(+1)) + 1 - share) );

%FOC i   
exp(q) = ( Pi^(1/(1+Theta))
    +(1-Pi)^(1/(1+Theta))*exp(pN)^(Theta/(1+Theta)) )^((1+Theta)/Theta);

%evolution k
exp(i)=exp(k(+1))-(1-Delta)*exp(k); 

%production tradable
exp(YtT) = exp(pProdZ)*(1-share)*exp(k)^Alpha;

%production no tradable
exp(YtN) = exp(pProdZ)*share*exp(k)^Alpha;

%GDP
exp(Yt) = ( exp(pN)*exp(YtN) + exp(YtT) ); 
%Desde acá market clearing
%Ratio xT_xT
xT_N = ( exp(pN)*(Pi/(1-Pi)) )^(1/(1+Theta));

%inputs no tradable (de market clearing investment)
exp(xN) =  (  Pi*xT_N^(-Theta) +(1-Pi) )^(1/ Theta )  * exp(i) ;

%de TMS xT y xN
exp(xT) = xT_N*exp(xN);

% market clearing no tradable
exp(cN) = exp(YtN) - exp(xN)  ;

%de TMS cT y cN
exp(cT)=  exp(cN)*( (exp(pN) *(Omega/(1-Omega)) )^(1/(1+Ita)) );

%evolution debt
Bt = - exp(YtT) + exp(xT) + exp(cT) + Bt(-1)*(1+r) ;

%debt to GDP
B_Y = Bt/exp(Yt);

%current account
ca = Bt - Bt(-1);

%ca to GDP
ca_Y = ca/exp(Yt);

%Shock
pProdZ=rho*pProdZ(-1)+ sig_e*eps;

end;

steady_state_model;
pProdZ = log(Z_SS);
pN = log(pN_SS);
q = log( (Pi^(1/(1+Theta))
    +(1-Pi)^(1/(1+Theta))*exp(pN)^(Theta/(1+Theta)) )^((1+Theta)/Theta) ); % ACF ok Price q
k  = log ( ( Alpha*(share*exp(pN) + 1 -share) / 
   ( exp(q)*(R - (1-Delta) ) )  )^(1/(1-Alpha)) );
YtN = log(exp(pProdZ)*share*exp(k)^Alpha); %rev 
YtT = log(exp(pProdZ)*(1-share)*exp(k)^Alpha); %rev
Yt = log(  exp(pN)*exp(YtN) + exp(YtT)  );  %rev
i = log(Delta*exp(k)); 
xT_N = ( exp(pN)*(Pi/(1-Pi)) )^(1/(1+Theta)); %rev
xN = log(  (  Pi*xT_N^(-Theta) +(1-Pi) )^(1/ Theta )  * exp(i)   ); %rev
xT = log(xT_N*exp(xN)); %rev
cN = log( exp(YtN) - exp(xN) ); %rev
cT = log( exp(cN)*( (exp(pN) *(Omega/(1-Omega)) )^(1/(1+Ita)) ) );
Bt = (1/r)*(exp(YtT)-exp(xT)-exp(cT)); %rev
B_Y = Bt/exp(Yt); %rev
ca = 0;
ca_Y = ca/exp(Yt);
Phi = -log(1/R)/( log(1+exp(cT)) );
eBeta = (1+exp(cT))^(-Phi);
C = log( ( Omega*exp(cT)^(-Ita)+(1-Omega)*exp(cN)^(-Ita) )^(-1/Ita) ); %rev
Uc = log( exp(C)^( Ita+1-Sigma )*Omega*exp(cT)^(-1-Ita) ); %rev
end;

check;

shocks;
var eps= 1; 
end;

stoch_simul(order=1,irf=11,contemporaneous_correlation);