Plotting Policy Functions

Hi,

Im working on the following simple optimal growth model:
http://imageshack.us/a/img571/6075/cdpv.jpg
with the first-order conditions:
http://imageshack.us/a/img209/261/w1qc.jpg
The Dynare code is:

[code]%
%%%PREAMBLE%%%
%
var y invest k c z;
predetermined_variables k;
varexo eps;
parameters cbeta calpha crho ceta;

cbeta = .99;
calpha = .33;
crho = 0.9;
csigma = 0.035;
%
%%%MODELBLOCK%%%
%
model;
1/c = cbeta * 1/c(+1) * calpha * exp(z(+1)) * k(+1)^(calpha-1);
k(+1) = exp(z) * k^calpha - c;
z = crho*z(-1) + eps;
y = exp(z) * k^calpha;
invest = y - c;
end;
%
%%%INITIAL VALUE BLOCK%%%
%
initval;
k = 0.2;
c = 0.4;
z = 0;
end;
steady;
%
%%%SHOCKS%%%
%
shocks;
var eps = csigma^2;
end;

stoch_simul(periods = 2000,order=2, irf=40);

state_range=0:0.1:10;
state_name=‘k’;
plot_var_name=‘c’;
plot_policy_fun(state_name,state_range,plot_var_name);[/code]
For plotting the policy function I used the m-file by jpfeifer » Sat Mar 16, 2013 (attached)
My goal is to show the differences that occur between the policy functions using first and second order approximation due to certainty equivalence.
Yet I got really strange results. For the 2nd order approximation my policy function looks like
http://imageshack.us/a/img580/8256/xswe.jpg
and for my 1st order approx the policy function looks like
http://imageshack.us/a/img826/7357/bnim.jpg

Im very thankful for any help!
Best regards,
nbt
plot_policy_fun.m (3.39 KB)

Look at

[quote]STEADY-STATE RESULTS:

y 0.576369
invest 0.1883
k 0.1883
c 0.388069
z 0
[/quote]

You are plotting the policy function in an area where the approximation is poor, e.g. 100 times the steady state value of capital.
for first order, the policy function is linear and upward sloping. For second order, around the steady state, it is still upward sloping, but also concave. For k -> Infinity, the concavity starts to dominate.

Hi,
thanks very much, worked out well now!