Hi there,
I have a question about oo_.dr
Consider Schmidt-Grohe & Uribe (2004, JEDC) paper. Now consider a variable that is both forward- and backward-looking as opposed to purely forward-looking (i.e. jumper) or a purely backward-looking (i.e. state). If the model contains such variables, then what is the state-space representation of the first-order approximation to the model?
The easiest example of the code is the SGU(2003) “Closing Small Open Economy Models”, which is replicated by Johannes Pfeifer on GitHub (see below for a cleaned up version of 1/5 models in the code). Because of the capital adjustment costs, capital stock is not just a state variable, but also a control variable. I’m confused about how the partial derivatives are computed for such mixed variables.
Specifically, usually 1st-order approximation looks like this:
f_y’ * y(+1) + f_y * y + f_x’ x(+1) * f_x * x = 0,
where y is a vector of static or jumper variables, while x is a vector of endogenous and exogenous state variables. If the code contains k, k(+1), and k(+2), then does k(+1) enter x(+1) or simply y?
var
d % (1) net international investment position (NIIP)
r % (2) real rate of interest
k % (3) capital stock at date t
i % (4) investment
y % (5) output
w % (6) real wage
z % (7) rental rate of capital
c % (8) real consumption expenditure
lambda % (9) marginal utility of consumption
tb % (10) trade balance / output
ca % (11) current account / output
a % (12) total factor productivity (TFP)
h % (13) hours of labour
;predetermined_variables
d
r
k
;varexo
eps
;parameters
d_0 % (1) initial NIIP
beta % (2) time preference
delta % (3) capital depreciation rate
gamma % (4) external debt-elasticity of interest rate (EDEIR)
alpha % (5) capital share of income
rho % (6) persistence of TFP shocks
sigma % (7) std. of TFP shocks
varsigma % (8) elasticity of inter-temporal substitution
varphi % (9) Frisch elasticity of labour supply
chi % (10) convexity of quadratic capital adjustment costs
;d_0 = 0.7442;
beta = 1/1.04;
alpha = 0.32;
delta = 0.1;
gamma = 0.000742;
rho = 0.42;
sigma = 0.0129;
varsigma = 0.5;
varphi = 1.455;
chi = 0.028;model;
1 = ( exp(z(+1)) + 1 - delta + chi * (exp(k(+2))-exp(k(+1))) ) / ( (1 + exp(r(+1))) * (1 + chi * (exp(k(+1))-exp(k))) );
exp(lambda) = beta * (1+exp(r(+1))) * exp(lambda(+1));
exp(lambda) = (exp( c )-((exp(h)^varphi)/varphi))^(-1/varsigma);
exp(w) = exp(h)^(varphi-1);
exp(w) = (1-alpha) * exp(y) / exp(h);
exp(z) = alpha * exp(y) / exp(k);
exp(i) = exp(k(+1))-(1-delta) * exp(k);
exp(y) = exp(a) * (exp(k)^alpha) * (exp(h)^(1-alpha));
exp(r(+1)) = 1/beta - 1 + gamma * (exp(d(+1)-d_0)-1);
d(+1) = ( 1 + exp( r ) ) * d - exp(y) + exp( c ) + exp(i) + (chi/2) * (exp(k(+1)) - exp(k))^2;
tb = 1-((exp( c )+exp(i)+(chi/2) * (exp(k(+1))-exp(k))^2)/exp(y));
ca = (1/exp(y)) * (d-d(+1));
a = rho * a(-1)+sigma *eps;
end;steady_state_model;
d = d_0;
r = log(1/beta - 1);
h = log(((1-alpha) * (alpha/(1/beta-1+delta))^(alpha/(1-alpha)))^(1/(varphi-1)));
k = log(exp(h) / (((1/beta-1+delta)/alpha)^(1/(1-alpha))));
y = log((exp(k)^alpha) * (exp(h)^(1-alpha)));
z = log(alpha * exp(y) / exp(k));
w = log((1-alpha) * exp(y) / exp(h));
i = log(delta * exp(k));
c = log(exp(y)-exp(i)-exp( r ) * d);
tb = 1-((exp( c )+exp(i))/exp(y));
lambda = log((exp( c )-((exp(h)^varphi)/varphi))^(-1/varsigma));
a = 0;
ca = 0;
end;check;
steady;shocks;
var eps; stderr 1;
end;stoch_simul(order=1, irf=0, noprint, nograph);
% Report results from Table 3
y_pos=strmatch(‘y’,M_.endo_names,‘exact’);
c_pos=strmatch(‘c’,M_.endo_names,‘exact’);
i_pos=strmatch(‘i’,M_.endo_names,‘exact’);
h_pos=strmatch(‘h’,M_.endo_names,‘exact’);
tb_y_pos=strmatch(‘tb’,M_.endo_names,‘exact’);
ca_y_pos=strmatch(‘ca’,M_.endo_names,‘exact’);fprintf(‘\nstd(y): \t %2.1f \n’,sqrt(oo_.var(y_pos,y_pos))*100)
fprintf(‘std(c): \t %2.1f \n’,sqrt(oo_.var(c_pos,c_pos))*100)
fprintf(‘std(i): \t %2.1f \n’,sqrt(oo_.var(i_pos,i_pos))*100)
fprintf(‘std(h): \t %2.1f \n’,sqrt(oo_.var(h_pos,h_pos))*100)
fprintf(‘std(tb/y): \t %2.1f \n’,sqrt(oo_.var(tb_y_pos,tb_y_pos))*100)
if ~isempty(ca_y_pos)
fprintf(‘std(ca/y): \t %2.1f \n’,sqrt(oo_.var(ca_y_pos,ca_y_pos))*100)
else %complete markets case
fprintf(‘std(ca/y): \t %2.1f \n’,sqrt(oo_.var(ca_y_pos,ca_y_pos))*100)
end
fprintf(‘corr(y_t,y_t-1): \t %3.2f \n’,oo_.autocorr{1}(y_pos,y_pos))
fprintf(‘corr(c_t,c_t-1): \t %3.2f \n’,oo_.autocorr{1}(c_pos,c_pos))
fprintf(‘corr(i_t,i_t-1): \t %4.3f \n’,oo_.autocorr{1}(i_pos,i_pos))
fprintf(‘corr(h_t,h_t-1): \t %3.2f \n’,oo_.autocorr{1}(h_pos,h_pos))
fprintf(‘corr(tb/y_t,tb/y_t-1): \t %3.2f \n’,oo_.autocorr{1}(tb_y_pos,tb_y_pos))
if ~isempty(ca_y_pos)
fprintf(‘corr(ca/y_t,ca/y_t-1): \t %3.2f \n’,oo_.autocorr{1}(ca_y_pos,ca_y_pos))
else %complete markets case
fprintf(‘corr(ca/y_t,ca/y_t-1): \t %3.2f \n’,NaN)
end
fprintf(‘corr(c_t,y_t): \t %3.2f \n’,oo_.gamma_y{1}(c_pos,y_pos)/sqrt(oo_.var(c_pos,c_pos)*oo_.var(y_pos,y_pos)))
fprintf(‘corr(i_t,y_t): \t %3.2f \n’,oo_.gamma_y{1}(i_pos,y_pos)/sqrt(oo_.var(i_pos,i_pos)*oo_.var(y_pos,y_pos)))
fprintf(‘corr(h_t,y_t): \t %2.1f \n’,oo_.gamma_y{1}(h_pos,y_pos)/sqrt(oo_.var(h_pos,h_pos)*oo_.var(y_pos,y_pos)))
fprintf(‘corr(tb/y_t,y_t): \t %4.3f \n’,oo_.gamma_y{1}(tb_y_pos,y_pos)/sqrt(oo_.var(tb_y_pos,tb_y_pos)*oo_.var(y_pos,y_pos)))
if ~isempty(ca_y_pos)
fprintf(‘corr(ca/y_t,y_t): \t %4.3f \n’,oo_.gamma_y{1}(ca_y_pos,y_pos)/sqrt(oo_.var(ca_y_pos,ca_y_pos)*oo_.var(y_pos,y_pos)))
else %complete markets case
fprintf(‘corr(ca/y_t,y_t): \t %4.3f \n’,NaN)
end% generate impulse response functions in fig. 1
shocks;
var eps; stderr 1/sigma; % normalize to 1 percent shock
end;stoch_simul(order=1, irf=10, nograph);