# Plotting Policy Functions

**URL:** <https://forum.dynare.org/t/plotting-policy-functions/3441>\
**Category:** Dynare help (legacy posts)\
**Created:** [13 October 2013 12:46 UTC](https://forum.dynare.org/t/plotting-policy-functions/3441 "2013-10-13T12:46:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbt](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@nbt](https://forum.dynare.org/u/nbt)\
**Post date:** [13 October 2013 12:46 UTC](https://forum.dynare.org/t/plotting-policy-functions/3441/1 "2013-10-13T12:46:26Z")

</div>

Hi,

Im working on the following simple optimal growth model:  
[http://imageshack.us/a/img571/6075/cdpv.jpg](http://imageshack.us/a/img571/6075/cdpv.jpg)  
with the first-order conditions:  
[http://imageshack.us/a/img209/261/w1qc.jpg](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](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](http://imageshack.us/a/img826/7357/bnim.jpg)

Im very thankful for any help!  
Best regards,  
nbt  
[plot\_policy\_fun.m](https://forum.dynare.org/uploads/default/original/2X/c/cdea7bb02b0e0fa2a7f4bb392502b6b628ed77a0.m) (3.39 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [14 October 2013 09:48 UTC](https://forum.dynare.org/t/plotting-policy-functions/3441/2 "2013-10-14T09:48:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nbt](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@nbt](https://forum.dynare.org/u/nbt)\
**Post date:** [14 October 2013 14:02 UTC](https://forum.dynare.org/t/plotting-policy-functions/3441/3 "2013-10-14T14:02:13Z")

</div>

Hi,  
thanks very much, worked out well now!
