k-order DLL: check computed policy functions at order 9 against Burnside's model

Ref #217
time-shift
Sébastien Villemot 2019-04-26 18:41:51 +02:00
parent 72afafe3d4
commit f1b16ced4e
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 104 additions and 0 deletions

View File

@ -134,6 +134,7 @@ MODFILES = \
k_order_perturbation/fs2000k3_m.mod \
k_order_perturbation/fs2000k3_p.mod \
k_order_perturbation/fs2000k4.mod \
k_order_perturbation/burnside_k_order.mod \
partial_information/PItest3aHc0PCLsimModPiYrVarobsAll.mod \
partial_information/PItest3aHc0PCLsimModPiYrVarobsCNR.mod \
arima/mod1.mod \

View File

@ -0,0 +1,103 @@
/*
Check the policy functions obtained by perturbation at a high approximation
order, using the Burnside (1998, JEDC) model (for which the analytical form of
the policy function is known).
As shown by Burnside, the policy function for y is:
y = β exp[a+b(xx)]
where:
θ² 2ρ 1ρ²
a = iθx + σ² i (1ρ) + ρ²
2(1ρ)² 1ρ 1ρ²
θρ
b = (1ρ)
1ρ
x is the steady state of x
σ is the standard deviation of e.
With some algebra, it can be shown that the derivative of y at the deterministic
steady state is equal to:
² y (2p)!
= β b ρ c exp(iθx)
x e ²s ¹ p!
where:
s is the stochastic scale factor
θ² 2ρ 1ρ²
c = i (1ρ) + ρ²
2(1ρ)² 1ρ 1ρ²
The policy function as returned in the oo_.dr.g_* matrices has the following properties:
its elements are pre-multiplied by the Taylor coefficients;
derivatives w.r.t. the stochastic scale factor have already been summed up;
symmetric elements are folded (and they are not pre-multiplied by the number of repetitions).
As a consequence, the element g corresponding to the m-th derivative w.r.t.
to x and the n-th derivative w.r.t. to e is given by:
1 c
g = β b ρ exp(iθx)
(m+n)! 02pk-m-n ¹ p!
where k is the order of approximation.
*/
@#define k = 9
var y x;
varexo e;
parameters beta theta rho xbar;
xbar = 0.0179;
rho = -0.139;
theta = -1.5;
theta = -10;
beta = 0.95;
model;
y = beta*exp(theta*x(+1))*(1+y(+1));
x = (1-rho)*xbar + rho*x(-1)+e;
end;
shocks;
var e; stderr 0.0348;
end;
initval;
x = xbar;
y = beta*exp(theta*xbar)/(1-beta*exp(theta*xbar));
end;
steady;
stoch_simul(order=@{k},k_order_solver,irf=0);
sigma2=M_.Sigma_e;
i = 1:800;
c = theta^2*sigma2/(2*(1-rho)^2)*(i-2*rho*(1-rho.^i)/(1-rho)+rho^2*(1-rho.^(2*i))/(1-rho^2));
b = theta*rho*(1-rho.^i)/(1-rho);
for ord = 0:@{k}
g = oo_.dr.(['g_' num2str(ord)])(2,:); % Retrieve computed policy function for variable y
for m = 0:ord % m is the derivation order with respect to x(-1)
v = 0;
for p = 0:floor((@{k}-ord)/2) % 2p is the derivation order with respect to s
if ord+2*p > 0 % Skip the deterministic steady state constant
v = v + sum(beta.^i.*exp(theta*xbar*i).*b.^ord.*rho^m.*c.^p)/factorial(ord)/factorial(p);
end
end
if abs(v-g(ord+1-m)) > 1e-14
error(['Error in matrix oo_.dr.g_' num2str(ord)])
end
end
end