Stability and Predetermined Variables

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.

Stability and Predetermined Variables

Postby jd1090 » Wed Feb 03, 2016 6:06 pm

Hi,

I have an emergency. I've written a paper months ago as part of my PhD and I was just about to submit it to a conference, but I read through it and found a mistake in the mod file.

The problem now is that the BK conditions fail to hold and I suspect that it is because of the time subscripts. I tried to follow the dynare user guide.

The code includes both bonds and capital stock. I solve the model using 2nd order approximation so upper case letters denote levels. Capital stock enters the household budget constraint, capital accumulation function and production function as K(-1). Bonds on the other hand are specificied via predetermined_variables command. The slight complication is that the household budget constraint considers the portfolio of bonds OMEGA, whereas the demands for different types of bonds are a function of this variable.

I can't find what is wrong with it. All variables and equations are described in detail, so if you didn't mind having a quick look at it, I would very much appreciate it.

P.S. The deadline is Friday 5th of February and I still need to run loops that are time consuming in order to obtain my key results.

Code: Select all
//-------------------------------------------------------------------------------------------------
//                      DECLARATION OF ENDOGENOUS VARIABLES
//-------------------------------------------------------------------------------------------------
var
//
//
%%%%%%%%%%%%%%%%%%%%%%
%%%%REAL VARIABLES%%%%
%%%%%%%%%%%%%%%%%%%%%%
//
//
Y               //AGGREGATE OUTPUT
I               //AGGREGATE INVESTMENT
NX              //NET EXPORTS OF RETAIL GOODS
C               //AGGREGATE CONSUMPTION
C_H             //AGGREGATE CONSUMPTION OF DOMESTICALLY PRODUCED RETAIL GOODS
C_F             //AGGREGATE CONSUMPTION OF IMPORTED RETAIL GOODS
UC              //MARGINAL UTILITY OF CONSUMPTION
UC_star         //FOREIGN MARGINAL UTILITY OF CONSUMPTION
W               //NOMINAL WAGES
B               //DOMESTICALLY HELD STOCK OF FOREIGN BONDS
D               //DOMESTICALLY HELD STOCK OF DOMESTIC BONDS
OMEGA           //ASSET PORTFOLIO
LAMBDA          //STOCHASTIC DISCOUNT FACTOR
XI              //FIRM PROFIT DIVIDEND
N               //AGGREGATE LEVEL OF EMPLOYMENT
K               //AGGREGATE CAPITAL STOCK
R               //REAL RATE OF RETURN FROM CAPITAL STOCK
TQ              //TOBINS Q
DELTA           //INVESTMENT ADJUSTMENT COSTS
MC              //REAL MARGINAL COSTS
PHI1            //AUXILIARY VARIABLE 1
PHI2            //AUXILIARY VARIABLE 2
A               //AGGREGATE LABOUR PRODUCTIVITY
//
//
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%NOMINAL VARIABLES%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
//
//
CPI             //CONSUMPER PRICE INDEX
PPI_H           //DOMESTIC PRODUCER PRICE INDEX
PPI_H_HAT       //RESET PRICE IN THE DOMESTIC ECONOMY
THETA           //PRICE DISPERSION
PI_CPI          //DOMESTIC CPI INFLATION
PI_PPI_H        //DOMESTIC PPI INFLATION
r               //NOMINAL INTEREST RATE
f               //FOREIGN BOND RATE OF INTEREST
S               //NOMINAL EXCHANGE RATE
Q               //REAL EXCHANGE RATE
//
//
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%FOREIGN VARIABLES%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
//
//
C_star          //FOREIGN AGGREGATE CONSUMPTION
C_H_star        //DOMESTIC EXPORTS
CPI_star        //FOREIGN CONSUMER PRICE INDEX
r_star          //FOREIGN NOMINAL INTEREST RATE
PPI_F           //FOREIGN PRODUCER PRICE INDEX
//
//
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%DEVIATIONS FROM THE STEADY STATE%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
//
y               //OUTPUT DEVIATION FROM THE STEADY STATE
c               //CONSUMPTION DEVIATION FROM THE STEADY STATE
k               //CAPITAL STOCK DEVIATION FROM THE STEADY STATE
i               //INVESTMENT DEVIATION FROM THE STEADY STATE
w               //NOMINAL WAGE DEVIATION FROM THE STEADY STATE
n               //EMPLOYMENT DEVIATION FROM THE STEADY STATE
ppi_H           //PPI DEVIATION FROM THE STEADY STATE
cpi             //CPI DEVIATION FROM THE STEADY STATE
pi_cpi          //CPI INFLATION DEVIATION FROM THE STEADY STATE
pi_ppi_H        //PPI INFLATION DEVIATION FROM THE STEADY STATE
mc              //REAL MARGINAL COST DEVIATION FROM THE STEADY STATE
ppi_H_HAT       //RESET PRICE DEVIATION FROM THE STEADY STATE
s               //NOMINAL EXCHANGE RATE DEVIATION FROM THE STEADY STATE
q               //REAL EXCHANGE RATE DEVIATION FROM THE STEADY STATE
//
//
;
predetermined_variables OMEGA;
//
//-------------------------------------------------------------------------------------------------
//                        DECLARATION OF EXOGENOUS VARIABLES
//-------------------------------------------------------------------------------------------------
//
varexo 
upsilon_A
upsilon_p
upsilon_star
upsilon_r
upsilon_mp;
//
//-------------------------------------------------------------------------------------------------
//                        DECLARATION OF PARAMETERS
//-------------------------------------------------------------------------------------------------
parameters
beta            //TIME-INVARIANT DISCOUNT FACTOR
varphi          //INVERSE FRISCH ELASTICITY OF LABOUR
alpha           //OPENNESS TO TRADE IN GOODS AND SERVICES
eta             //ELASTICITY OF SUBSTITUTION BETWEEN THE DOMESTIC AND FOREIGN GOODS
varepsilon      //ELASTICITY OF SUBSTITUTION BETWEEN THE DOMESTIC VARIETIES
sigma           //COEFFICIENT OF RELATIVE RISK AVERSION
pi              //INDEX OF PRICE STICKINESS
chi             //LABOUR SHARE OF INCOME
zeta            //SIZE OF THE ADJUSTMENT COSTS OF INVESTMENT
delta           //CAPITAL DEPRECIATION RATE
rho_a           //PERSISTENCE OF THE LABOUR PRODUCTIVITY
rho_p           //PERSISTENCE OF THE FOREIGN CPI
rho_star        //PERSISTENCE OF THE FOREIGN AGGREGATE CONSUMPTION
rho_r           //PERSISTENCE OF THE FOREIGN NOMINAL INTEREST RATE
phi             //MONETARY POLICY RESPONSIVENESS TO INFLATION
xi              //DEGREE OF IMPERFECT SUBSTITUTABILITY BETWEEN THE DOMESTIC AND FOREIGN BONDS
theta           //DEGREE OF FINANCIAL OPENNESS

//
//
//-------------------------------------------------------------------------------------------------
//                          CALIBRATION OF PARAMETERS
//-------------------------------------------------------------------------------------------------
//
beta=0.99;
varphi=3;
alpha=0.4;
eta=1;
varepsilon=6;
sigma=1;
pi=0.75;
chi=0.68;
zeta=2;
delta=0.05;
rho_a=0.757;
rho_p=0.91;
rho_star=0.832;
rho_r=0.732;
phi=1.5;
xi=1;
theta=0.99;
//
//-------------------------------------------------------------------------------------------------
//                       NON-LINEAR MODEL EQUATIONS
//-------------------------------------------------------------------------------------------------
model;
//
//
Y=C+I+NX;                                                                                               //(1) AGGREGATE RESOURCE CONSTRAINT                                                                                           
Y=C_H+C_H_star+I;                                                                                       //(2) AGGREGATE DEMAND FOR THE DOMESTIC VARIETIES
NX=C_H_star-C_F;                                                                                        //(3) NET EXPORTS IDENTITY
C_H=(1-alpha)*((PPI_H/CPI)^(-eta))*C;                                                                   //(4) DOMESTIC AGGREGATE DEMAND FOR THE DOMESTIC VARIETIES
C_F=alpha*((PPI_F/CPI)^(-eta))*C;                                                                       //(5) DOMESTIC AGGREGATE DEMAND FOR THE FOREIGN VARIETIES
C_H_star=alpha*((PPI_H/(S*CPI_star))^(-eta))*C_star;                                                    //(6) FOREIGN AGGREGATE DEMAND FOR THE DOMESTIC VARIETIES
//
//
B=theta*(OMEGA)/S;                                                                                      //(7) DOMESTIC DEMAND FOR THE FOREIGN BONDS
D=(1-theta)*OMEGA;                                                                                      //(8) DOMESTIC DEMAND FOR THE DOMESTIC BONDS
OMEGA(+1)=(1/(PI_CPI(+1)*LAMBDA(+1)))*(OMEGA/CPI+(W/CPI)*N+(R(-1)/CPI)*K(-1)+(XI/CPI)-C-I);             //(9) HOUSEHOLD BUDGET CONSTRAINT
XI=PPI_H*Y-W*N-R(-1)*K(-1);                                                                             //(10) DOMESTIC FIRM PROFITS
f=r_star+xi*(exp(S*B)-1);                                                                               //(11) FOREIGN BOND RATE OF INTEREST
W=CPI*(N^varphi)*(C^sigma);                                                                             //(12) INVERSE LABOUR SUPPLY SCHEDULE
PI_CPI(+1)=beta*(UC(+1)/UC)*(1/LAMBDA);                                                                 //(13) EULER EQUATION
UC=1/(C^sigma);                                                                                         //(14) MARGINAL UTILITY OF CONSUMPTION
LAMBDA=(1-theta)*exp(-r)+theta*((exp(-f)*S)/S(+1));                                                     //(15) STOCHASTIC DISCOUNT FACTOR
//
//
Y=(((A*N)^chi)*(K(-1))^(1-chi))/THETA;                                                                  //(16) AGGREGATE PRODUCTION FUNCTION
MC=((varepsilon-1)/varepsilon)*((W*N)/(CPI*Y))*(STEADY_STATE(Y)/STEADY_STATE(N));                       //(17) REAL MARGINAL COSTS
PPI_H_HAT=CPI*(PHI1/PHI2);                                                                              //(18) RESET PRICE IDENTITY
PHI1=(varepsilon/(varepsilon-1))*(Y*UC)*MC+pi*beta*(PI_CPI(+1)^varepsilon)*PHI1(+1);                    //(19) AUXILIARY VARIABLE 1
PHI2=(Y*UC)+pi*beta*(PI_CPI(+1)^(varepsilon-1))*PHI2(+1);                                               //(20) AUXILIARY VARIABLE 2
THETA=pi*(PI_PPI_H^varepsilon)*THETA(-1)+(1-pi)*(PHI1/PHI2)^(-varepsilon);                              //(21) PRICE DISPERSION
//
//
K=(1-delta)*K(-1)+(1-DELTA)*I;                                                                          //(22) CAPITAL ACCUMULATION FUNCTION
DELTA=(zeta/2)*((I/I(-1))-1)^2;                                                                         //(23) INVESTMENT ADJUSTMENT COSTS
K(-1)=(((1-chi)*W)/(chi*R(-1)))*N;                                                                      //(24) COST-MINIMISING CAPITAL LABOUR RATIO
TQ=beta*((UC(+1)/UC)*((R/CPI(+1))+TQ(+1)*(1-delta)));                                                   //(25) REAL RATE OF RETURN
1=TQ*(1-DELTA-zeta*((I/I(-1))-1)*(I/I(-1)))-beta*TQ(+1)*(UC(+1)/UC)*zeta*((I(+1)/I)-1)*((I(+1)/I)^2);   //(26) TOBIN'S Q
//
//
PI_CPI=CPI/CPI(-1);                                                                                     //(27) CPI INFLATION IDENTITY
PPI_H=((1-pi)*PPI_H_HAT^(1-varepsilon)+pi*PPI_H(-1))^(1/(1-varepsilon));                                //(28) PPI IDENTITY
PI_PPI_H=PPI_H/PPI_H(-1);                                                                               //(29) PPI INFLATION IDENTITY
S=CPI*Q/CPI_star;                                                                                       //(30) REAL EXCHANGE RATE IDENTITY
Q=UC_star/UC;                                                                                           //(31) CONSUMPTION RISK SHARING EQUATION
UC_star=1/(C_star^sigma);                                                                               //(32) FOREIGN MARGINAL UTILITY OF CONSUMPTION
PPI_F=(CPI_star*(S/PPI_H)^alpha)^(1/(1-alpha));                                                         //(33) FOREIGN PPI
//
//
r=-log(beta)+phi*log(CPI/CPI(-1))+upsilon_mp;                                                           //(34) CIT
//r=-log(beta)+phi*log(PPI_H/PPI_H(-1))+upsilon_mp;                                                     //(34) DIT
//exp(-r)=(S/S(+1))*((1-theta)*exp(-r_star)+theta*exp(-f))+upsilon_mp;                                  //(34) ERP (1)
//S=S(-1)^(1-theta);                                                                                    //(34) ERP (2)
//
//
log(A)=rho_a*log(A(-1))+upsilon_A;                                                                      //(35) LABOUR PRODUCTIVITY SHOCK
log(CPI_star)=rho_p*log(CPI_star(-1))+upsilon_p;                                                        //(36) FOREIGN CPI SHOCK
log(C_star)=(1-rho_star)*log(STEADY_STATE(C))+rho_star*log(C_star(-1))+upsilon_star;                    //(37) FOREIGN AGGREGATE CONSUMPTION SHOCK
r_star=(rho_r-1)*log(beta)+rho_r*r_star(-1)+upsilon_r;                                                  //(38) FOREIGN NOMINAL INTEREST RATE SHOCK
//
//DEVIATIONS FROM THE STEADY STATE
//
y=(Y-STEADY_STATE(Y))/STEADY_STATE(Y);
c=(C-STEADY_STATE(C))/STEADY_STATE(C);
k=(K-(STEADY_STATE(K)))/(STEADY_STATE(K));
i=(I-(STEADY_STATE(I)))/(STEADY_STATE(I));
w=(W-(STEADY_STATE(W)))/(STEADY_STATE(W));
n=(N-STEADY_STATE(N))/STEADY_STATE(N);
pi_cpi=(PI_CPI-STEADY_STATE(PI_CPI))/STEADY_STATE(PI_CPI);
pi_ppi_H=(PI_PPI_H-STEADY_STATE(PI_PPI_H))/STEADY_STATE(PI_PPI_H);
s=(S-STEADY_STATE(S))/STEADY_STATE(S);
q=(Q-STEADY_STATE(Q))/STEADY_STATE(Q);
mc=(MC-STEADY_STATE(MC))/STEADY_STATE(MC);
ppi_H_HAT=(PPI_H_HAT-STEADY_STATE(PPI_H_HAT))/STEADY_STATE(PPI_H_HAT);
ppi_H=(PPI_H-STEADY_STATE(PPI_H))/STEADY_STATE(PPI_H);
cpi=(CPI-STEADY_STATE(CPI))/STEADY_STATE(CPI);
//
end;
//-------------------------------------------------------------------------------------------------
//                          INITIAL VALUE DECLARATION
//-------------------------------------------------------------------------------------------------
steady_state_model;
//
//
R=(1-beta*(1-delta))/beta;
N=(1/(((1-chi)/(chi*R))^(1-chi)-delta*((1-chi)/(chi*R))))^(sigma/(varphi+sigma));
C=(1/N)^(varphi/sigma);
K=((1-chi)/(chi*R))*N;
I=delta*K;
Y=(N^chi)*K^(1-chi);
TQ=1;
//
//
LAMBDA=beta;
OMEGA=0;
B=0;
D=0;
XI=Y-N-R*K;
//
//
NX=0;
C_H=(1-alpha)*C;
C_F=alpha*C;
C_H_star=alpha*C;
UC_star=C^(-sigma);
UC=C^(-sigma);
//
//
W=1;
MC=((varepsilon-1)/varepsilon);
PPI_H_HAT=1;
PHI1=(Y*UC)/(1-pi*beta);
PHI2=(Y*UC)/(1-pi*beta);
THETA=1;
PPI_H=1;
PI_PPI_H=1;
CPI=1;
PI_CPI=1;
PPI_F=1;
//
//
S=1;
Q=1;
//
//
r=-log(beta);
f=-log(beta);
//
//
A=1;
C_star=C;
CPI_star=1;
r_star=-log(beta);
//
//
y=0;
c=0;
k=0;
i=0;
w=0;
n=0;
pi_cpi=0;
pi_ppi_H=0;
s=0;
q=0;
mc=0;
ppi_H_HAT=0;
ppi_H=0;
cpi=0;
//
//
end;
steady;
//
//-------------------------------------------------------------------------------------------------
//                          SPECIFICATION OF SHOCKS
//-------------------------------------------------------------------------------------------------
//
shocks;
//
//
var upsilon_A; stderr 0.017849756;
var upsilon_star; stderr 0.017607805;
var upsilon_p; stderr 0.019746341;
var upsilon_mp; stderr 0.619270244;
var upsilon_r; stderr 1;
var upsilon_A, upsilon_star = 0.000181107;
var upsilon_A, upsilon_p = -0.00010589;
var upsilon_A, upsilon_mp = 0.003279128;
var upsilon_A, upsilon_r = 0.005925295;
var upsilon_star, upsilon_p= 6.30558E-05;
var upsilon_star, upsilon_mp= 0.008338872;
var upsilon_star, upsilon_r= 0.012283231;
var upsilon_p, upsilon_mp = 0.003338938;
var upsilon_p, upsilon_r = 0.003023887;
var upsilon_mp, upsilon_r = 0.402146342;
//
//
end;
//
//
stoch_simul(order=2,pruning,irf=24,ar=10)      
y
c
k
i
NX
n
w
mc
ppi_H_HAT
r
f
B
D
TQ
OMEGA
LAMBDA
s
q
ppi_H
cpi
pi_cpi
pi_ppi_H;
Justas Dainauskas
Department of Economics and Related Studies
University of York
Heslington
York
YO10 5DD
United Kingdom
jd1090
 
Posts: 62
Joined: Wed Mar 25, 2015 11:12 am

Re: Stability and Predetermined Variables

Postby jpfeifer » Thu Feb 04, 2016 12:39 pm

This is a tricky one. Your model looks superficially ok, but there are non-standard features that are hard to evaluate without knowing the details. I would first try to find out whether it is a matter of parameterization, i.e. whether for some parameter values the BK conditions are satisfied. But I doubt that this is the problem.

You should probably rather focus on the debt allocation between foreign and domestic. This is the place where timing is often tricky, see e.g. http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=3564 for a similar issue with respect to capital stocks.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Stability and Predetermined Variables

Postby jd1090 » Fri Feb 05, 2016 10:23 am

Thanks for your reply. I managed to get it to work without the capital stock by updating all the subscripts one period backwards (relative to the paper) for all the assets. So in the above scenario that would've been OMEGA=....OMEGA(-1)+(W/CPI)*N+XI/CPI+......

My best guess was that the combination of using the "updating" approach and the "predetermined_variables" approach together may lead to some hurdles in dynare that are beyond me.

I managed to submit the paper by the way. Thanks again.
Justas Dainauskas
Department of Economics and Related Studies
University of York
Heslington
York
YO10 5DD
United Kingdom
jd1090
 
Posts: 62
Joined: Wed Mar 25, 2015 11:12 am


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 11 guests