I am currently trying to get the Ramsey allocation in a simple, benchmark GE model with public capital but I have failed to reach a stable solution using numerical entries for my four endogenous variables using the initval prompt. I have looked into most resources available on this forum but I cannot quite find what I am after. In particular, I do not have such a neat recursive solution as in the ramsey example provided by M. Julliard. What I would like to do instead is to have a separate steady state file computing the SS allocation given the values assigned by dynare.
I have copied the code of the mod file below. Note that I know this is currently not been pre-processed but I would like to know whether I can do something in the spirit of what I included in the steady_state_model block. I will really appreciate some guidance on this.
Many thanks,
Arthur
Full disclosure: I am new to Dynare (and Matlab).
Mod file
- Code: Select all
var y, c, l, k, kg, d, W, Pi, lambda, TFP,r,w,rg, tauh, tauc;
varexo z;
parameters beta, A, theta1, theta2, theta3, b, gamma, deltag, deltak;
// Calibration;
A = 1;
theta1=0.3;
theta2=0.6;
theta3=0.1;
deltak=0.1;
deltag=0.1;
gamma=3;
b=1.5;
beta=0.99;
// Dynamic system;
model;
//firm;
y = TFP*k(-1)^theta1*l^theta2*kg(-1)^theta3;
r=theta1*y/k(-1);
w=theta2*y/l;
Pi = theta3*y;
rg= theta3*y*kg(-1);
//government;
kg = kg(-1)*(1-deltag) + tauh*W + tauc*Pi;
//HH;
lambda/lambda(+1) = beta*(1 + (1-tauh)*(r(+1) - deltak));
1/(c-b*l^gamma) = lambda;
W = ((r - deltak)*k(-1) + w*l)+ d;
d = (1 - tauc)*Pi;
c + k = k(-1) + (1 - tauh)*W;
l = ((1 - tauh)*w/(gamma*b))^(1/(gamma-1));
//Technology process;
TFP = A + z;
end;
initval;
tauc=0.9;
tauh=0.05;
end;
steady_state_model;
TFP = A
x0=[0.5 2 0.5 1];
options = optimset('Algorithm','levenberg-marquardt','MaxFunEvals',2000,'Tolx',10e-12,'Tolfun',10e-12);
[SS, fval, exitflag,ouput]=csolve(@(x) SSnoDD(x,beta,tauh,tauc,theta1,theta2,theta3,b,gamma,deltag,deltak,TFP),[0.5 2 0.5 1],options);
k=SS(2);
l=SS(3);
kg=SS(4);
d=(1 - tauc)*Pi;
y=k^theta1*l^theta2*kg^theta3;
Pi=theta3*y;
d=(1 - tauc)*Pi;
lambda=1/(c-b*l^gamma);
r=theta1*y/k;
w=theta2*y/l;
rg=theta3*y/kg;
W=((r - deltak)*k + w*l)+ d;
end;
planner_objective(ln(c-b*l^gamma));
ramsey_policy(planner_discount=0.99,order=1);
And here is the function:
- Code: Select all
function y = SSnoDD(x,beta,tauh,tauc,theta1,theta2,theta3,b,gamma,deltag,deltak,TFP);
c=x(1);
k=x(2);
l=x(3);
kg=x(4);
y(1) = c + (1-tauh)*deltak*k - (1-tauh)*(1-tauc*theta3)*TFP*k^theta1*l^theta2*kg^theta3; %HH BC
y(2) = deltag*kg - (tauh+tauc*(1-tauh)*TFP*theta3)*k^theta1*l^theta2*kg^theta3+tauh*k*deltak; % GOV BC
y(3) = l - (theta2*(1 - tauh)/(b*gamma)*TFP*k^theta1*kg^theta3)^(1/(gamma - theta2)); % optimal l
y(4) = (1)/beta - (1 + (1 - tauh)*(theta1*TFP*k^(theta1-1)*l^theta2*kg^theta3-deltak));% EE