disp('A one good two country model, bond economy (Baxter and Crucini) with adjustment costs, and public spending'); disp('Requires the Uhlig toolkit package') % Utility is Cobb Douglas in labor and leisure, public spending is financed with lumpsum taxation % Notice that here the interest rate on bonds, R(t) is defined as state. This is done for convenience even though it is not a true state % Setting parameters: bita = .99; % Discount rate theta = .4; % Capital share delta = .025; % Depreciation rate for capital gama = -1.0; % Exponent in utility function, RA = 1 -gama psi = 1; % autocorrelation of technology shock spi = 0.0; % spillover coefficient gpsi = .95; % autocorrelation of public spending gspi = 0; % spillover coefficient of public spending grat =0.2; % public spending as a fraction of gdp nbar=0.32; % Fraction of time spent working (total time endowment is normalized to 1) rho = (1/bita)-1; sigma_eps = 0.01; % Standard deviation of technology shock. corr_eps = .2; % Cross-country corrrelation of technology shocks. sigma_epsg = 0.005; % Standard deviation of shocks to g. corr_epsg = .1; % Cross-country corrrelation of g-shocks. phi = .8; % Capital ajustment cost parameter badj = 0.00001; %Bond holdin cost parameter % Calculating the steady state (same for bond and complete markets) v01=( (rho+delta)/theta ); kbar=(v01/nbar^(1-theta))^(1/(theta-1)); ybar=(kbar^theta)*(nbar^(1-theta)); gbar=grat*ybar cbar=ybar-delta*kbar-gbar; wbar=(1-theta)*ybar/nbar; rbar=theta*ybar/kbar; mu = (cbar/(wbar*(1-nbar))) / (1 + (cbar/(wbar*(1-nbar))) ); % Consumption share in utility qbar=bita; xbar=delta*kbar; tmat=[ psi spi 0 0 spi psi 0 0 0 0 gpsi gspi 0 0 gspi gpsi]; % Declaring the matrices. VARNAMES = ['K1 ', %1 'K2 ', %2 'B1 ', %3 'R ', %4 'C1 ', %5 'C2 ', %6 'N1 ', %7 'N2 ', %8 'X1 ', %9 'X2 ', %10 'R1 ', %11 'R2 ', %12 'W1 ', %13 'W2 ', %14 'Y1 ', %15 'Y2 ', %16 'NX ', %17 'Z1 ', %18 'Z2 ', %19 'G1 ', %20 'G2 ']; %21 % Translating into coefficient matrices. % The equations are, conveniently ordered: % Non expectational equations %1) 0 = -C*c1(t) -X*x1(t) -Q*b1(t) +Yy1(t) +b1(t-1) %2) 0 = -C*(c1(t)+c2(t)) -X*(x1(t)+x2(t)) + + G(g1(t_ +g2(t)) + Y(y1(t) + y2(t)) %3) 0 = -K*k1(t) + X*x1(t) + (1-delta)*K*k1(t-1) %4) 0 = -K*k2(t) + X*x2(t) + (1-delta)*K*k2(t-1) %5) 0 = -w1(t) + z1(t) + theta*k1(t-1) - theta*n1(t) %6) 0 = -w2(t) + z2(t) + theta*k2(t-1) - theta*n2(t) %7) 0 = -r1(t) + z1(t) + (1-theta)*n1(t) - (1-theta)*k1(t-1) %8) 0 = -r2(t) + z2(t) + (1-theta)*n2(t) - (1-theta)*k2(t-1) %9) 0 = -w1(t) + (N/(1-N))n1(t) + c1(t) %10) 0 = -w2(t) + (N/(1-N))n2(t) + c2(t) %11) 0 = -nx(t) + Y1y1(t) - Cc1(t) - Xx1(t) %12) 0 = -Yy1(t)+WN*(w1(t)+n1(t)) +R*K*(r1(t)+k1(t-1)) %13) 0 = -Yy2(t)+WN*(w2(t)+n2(t)) +R*K*(r2(t)+k2(t-1)) % Expectational equations %1) 0 = -(mu*gama-1)*c1(t) + (1-mu)*gama*(N/(1-N))*n1(t) - phi*(k1(t) -k1(t-1)) % + E(t)[(mu*gama-1)*c1(t+1)-(N/(1-N))*(1-mu)*gama*n1(t+1)+beta*r1(t+1)*R] % +2*beta*phi*(k1(t+1) -k1(t)) %2) 0 = -(mu*gama-1)*c2(t) + (1-mu)*gama*(N/(1-N))*n2(t) - phi*(k2(t) -k2(t-1)) % + E(t)[(mu*gama-1)*c2(t+1)-(N/(1-N))*(1-mu)*gama*n2(t+1)+beta*r2(t+1)*R] % +2*beta*phi*(k2(t+1) -k2(t)) %3 0=E_t( (mu*gama-1)(c1(t+1)-c1(t))-((N/(1-N))*(1-mu)*gama)(n1(t+1)-n1(t) - % (mu*gama-1)(c2(t+1)-c2(t))-((N/(1-N))*(1-mu)*gama)(n2(t+1)-n2(t) %4 0=E_t( (mu*gama-1)(c1(t+1)-c1(t))-((N/(1-N))*(1-mu)*gama)(n1(t+1)-n1(t) + R(t) % Shocks %1) 0 = -z1(t+1) + A11*z1(t) + A12*z2(t) +eps(t+1) %2) 0 = -z2(t+1) + A22*z2(t) + A21*z1(t) +eps(t+1) %3) 0 = -g1(t+1) + gA11*g1(t) + gA12*g2(t) +geps(t+1) %4) 0 = -g2(t+1) + gA22*g2(t) + gA21*g1(t) +geps(t+1) % % Endogenous state variables "x(t)": k1(t), k2(t), b1(t), R(t) % Endogenous other variables "y(t)": c1(t), c2(t), n1(t), n2(t), x1(t), x2(t) r1(t), r2(t) % w1(t), w2(t), y1(t), y2(t), nx(t) % Exogenous state variables "z(t)": z1(t), z2(t), g1(t), g2(t) eeq=4; % # expectational equations neeq=13; % # non expectational equations endst=4 % # endogenous states endct=13 % # endogenous controls exvar=4 % # exogenous variables % Switch to that notation. Find matrices for format % 0 = AA x(t) + BB x(t-1) + CC y(t) + DD z(t) % 0 = E_t [ FF x(t+1) + GG x(t) + HH x(t-1) + JJ y(t+1) + KK y(t) + LL z(t+1) + MM z(t)] % z(t+1) = NN z(t) + eps(t+1) with E_t [ eps(t+1) ] = 0, % coefficients of k(t) in the NE equations: RK=rbar*kbar; % k1(t) k2(t) b1(t) R(t) AA = [ 0 0 -qbar 0 0 0 0 0 -kbar 0 0 0 0 -kbar 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % coefficients of k(t-1) in the NE equations: % k1(t-1) k2(t-1) b1(t-1) R(t-1) BB = [ 0 0 1 0 0 0 0 0 (1-delta)*kbar 0 0 0 0 (1-delta)*kbar 0 0 -theta 0 0 0 0 -theta 0 0 1-theta 0 0 0 0 1-theta 0 0 0 0 0 0 0 0 0 0 0 0 0 0 RK 0 0 0 0 RK 0 0]; % coefficients of y(t) in the NE equations: WN=wbar*nbar; RK=rbar*kbar; N1N=nbar/(1-nbar); % c1(t), c2(t), n1(t), n2(t), x1(t), x2(t) r1(t), r2(t) w1(t), w2(t), y1(t), y2(t), nx(t) CC = [ -cbar 0 0 0 -xbar 0 0 0 0 0 ybar 0 0 -cbar -cbar 0 0 -xbar -xbar 0 0 0 0 ybar ybar 0 0 0 0 0 xbar 0 0 0 0 0 0 0 0 0 0 0 0 0 xbar 0 0 0 0 0 0 0 0 0 theta 0 0 0 0 0 1 0 0 0 0 0 0 0 theta 0 0 0 0 0 1 0 0 0 0 0 theta-1 0 0 0 1 0 0 0 0 0 0 0 0 0 theta-1 0 0 0 1 0 0 0 0 0 1 0 N1N 0 0 0 0 0 -1 0 0 0 0 0 1 0 N1N 0 0 0 0 0 -1 0 0 0 cbar 0 0 0 xbar 0 0 0 0 0 -ybar 0 1 0 0 WN 0 0 0 RK 0 WN 0 -ybar 0 0 0 0 0 WN 0 0 0 RK 0 WN 0 -ybar 0 ]; % coefficients of z(t) in the NE equations: DD = [ 0 0 0 0 0 0 -gbar -gbar 0 0 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]; % coefficients of x(t+1) in the E equations: % k1(t+1) k2(t+1) b1(t+1) R(t+1) FF = [ 2*bita*phi 0 0 0 0 2*bita*phi 0 0 0 0 0 0 0 0 0 0]; % coefficients of x(t) in the E equations: % k1(t) k2(t) b1(t) R(t) GG = [ -phi*(2+2*bita) 0 0 0 0 -phi*(2+2*bita) 0 0 0 0 -4*badj 0 0 0 0 1]; % coefficients of x(t-1) in the E equations: % k1(t-1) k2(t-1) b1(t-1) HH = [ 2*phi 0 0 0 0 2*phi 0 0 0 0 0 0 0 0 0 0]; % coefficients of y(t+1) in the E equations: v11=mu*gama-1; v13=-(1-mu)*gama*nbar/(1-nbar); br=bita*rbar; % c1(t+1),c2(t+1),n1(t+1),n2(t+1),x1(t+1),x2(t+1) r1(t+1), r2(t+1) w1(t+1), w2(t+1) y1(t) y2(t) nx(t) R JJ = [ v11 0 v13 0 0 0 br 0 0 0 0 0 0 0 v11 0 v13 0 0 0 br 0 0 0 0 0 v11 -v11 v13 -v13 0 0 0 0 0 0 0 0 0 v11 0 v13 0 0 0 0 0 0 0 0 0 0 ]; % coefficients of y(t) in the E equations: % c1(t),c2(t),n1(t),n2(t),x1(t),x2(t) r1(t), r2(t) w1(t), w2(t) y1(t) y2(t) nx(t) KK = [ -v11 0 -v13 0 0 0 0 0 0 0 0 0 0 0 -v11 0 -v13 0 0 0 0 0 0 0 0 0 -v11 v11 -v13 v13 0 0 0 0 0 0 0 0 0 -v11 0 -v13 0 0 0 0 0 0 0 0 0 0 ]; % coefficients of z(t+1) in the E equations: LL = zeros(eeq,exvar); % coefficients of z(t+1) in the E equations: MM = zeros(eeq,exvar); NN = tmat; Sigma = [ sigma_eps^2 corr_eps 0 0 corr_eps sigma_eps^2 0 0 0 0 sigma_epsg^2 corr_epsg 0 0 corr_epsg sigma_epsg^2]; % Setting the options: [l_equ,m_states] = size(AA); [l_equ,n_endog ] = size(CC); [l_equ,k_exog ] = size(DD); HORIZON = 32; % how far out should the impulse responses be calculated PERIOD = 4; % number of periods per year, i.e. 12 for monthly, 4 for quarterly DO_PLOTS = 1; % if impulse response plots should be made, = 0, if not. IMP_SELECT = [ 3 4 5 6 ]; % Select the variables to plot implulse responses. For the variable numbers refer to varnames HP_SELECT = 1:(m_states+n_endog+k_exog); % Selecting the variables for the HP Filter calcs. GNP_INDEX = 15; % Index of output among the variables selected for HP filter % Starting the calculations: do_it;