Skip to content
Open

. #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions code for hw2q2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
close all
delta=0.025 %depreciation rate
alpha=0.35 %capital share of income
beta=0.99 %discount rate
sigma=2 %utility parameter


nbk=20 %number of data points int he grid
nba=2 %number of value for the shocks
crit=1 %convergence criterion
epsi=1e-1 %convergence parameter


PI=[phh 1-phh;1-pll,pll] %transition matrix
pihh=0.977 %this is pi hh
pill=0.926 %p ll
ah=1.1
al=0.678
A=[ah al] %stochastic matrix


kmin=0.1
kmax=5
k=linspace(kmin,kmax,nbk)% k grid
c=zeros(nbk,nba)
util=zeros(nbk,nba)
v=zeros(nbk,nba)
Tv=zeros(nbk,nba)


%%%%%%%%%%%%%%%%%%set up%%%%%%%%%%%%%%%%%%%%%

while crit>epsi
for i=1:nbk
for j=1:nba
c=A(j)*k(i)^alpha+(1-delta)*k(i)-k
neg=find(c<0)
c(neg)=NaN
util(:,j)=(c.^(1-sigma))/(1-sigma)
util(neg,j)=-1e12
end
[Tv(i,:),pl(1,:)]=max(util+beta*(v*PI))
end
crit=max(abs(Tv-v))
v=Tv
i=i+1
end

plot(v(:,1))
hold on
plot(v(:,2))


Binary file added hmmm figure for value fn.fig
Binary file not shown.
Binary file added hmmm figure for value fn.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hw2 question2.pdf
Binary file not shown.