Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

ECON 809: Problem Set 1

Faisal Khan, Garam Kim, Minoru Higa, Nam Phan Van

1 Question 1

1.1 Write this problem as a dynamical system

This problem can be represented by a dynamical system (P (S), M )., where P (S) is the
probability distribution over state space S, and M is a Markov operator that maps a
member of P (S), name it ψ, to ψM where:

P
ψM (y) = x∈S p(x, y)ψ(x)

In this assignment, P(S) is the probability distribution over state space of three mem-
bers: UN, EU and ES. ψ is the probability that a person falls in one of three states
described by x ∈ {U N, EU, ES} where UN: unemployed, EU: employed in an unskilled
firm, and ES: employed in a skilled firm. Note that p(x, y) is the stochastic kernel de-
scribing the probability that one changes/keeps their employment status when moving
to next period.

1.2 Stochastic kernel of this economy

The kernel takes the following form:

 
 1−α α 0 
 
p(x, y) = 
 δ 1−β−δ β 
 (1)
 
δ 1−δ−β β

With α = 0.2, β = 0.1, δ = 0.01, the kernel becomes:

1
 
 0.8 0.2 0 
 
p(x, y) = 
 0.01 0.89 0.1

 (2)
 
0.01 0.89 0.1

Therefore:

   
 0.8 0.2 0   UN 
   
ψM (y) = 
 0.01 0.89 0.1
 P r  EU
 

 (3)
   
0.01 0.89 0.1 ES

1.3 Works with Julia

1.3.1 Simulate and plot a typical trajectory of 50 periods starting from each
of the three states.

The typical trajectory starting from state 1, state 2, and state 3 is as follow, respectively:

2
Code is as follows:

using QuantEcon
import Plots

3
alpha = 0.2
beta = 0.1
delta = 0.01
P=[1-alpha alpha 0
delta 1-beta-delta beta
delta 1-beta-delta beta]

mc=MarkovChain(P, ["unemployed", "employed unskilled", "employed skilled"])

X=simulate(mc,50,init=1)
xaxis = linspace(0, 50, 50)
Plots.plot(xaxis, X)

Y=simulate(mc,50,init=2)
xaxis = linspace(0, 50, 50)
Plots.plot(xaxis, Y)

Z=simulate(mc,50,init=3)
xaxis = linspace(0, 50, 50)
Plots.plot(xaxis, Z)

1.3.2 Solve for stationary distribution

The stationary distribution is:

1-element Array{Array{Float64,1},1}:
[0.047619, 0.857143, 0.0952381]

They are the probability that a person is unemployed, employed in unskilled firm, and
employed in skilled firm, respectively.
Code is as follows:

stationary distributions(mc)

4
1.3.3 Compute the Dobrushin coefficient

It returns:

[0.21, 0.3759, 0.506961]

They correspond to the Dobrushin coefficient of Q, Q2 and Q3 , respectively.


Code is as follows:

#Raw code to find Dobrushin coefficient


alpha = 0.2
delta = 0.01
beta = 0.1
p = [1-alpha alpha 0;
delta 1-beta-delta beta;
delta 1-beta-delta beta]
dobrushin = zeros(3)

for v = 1:3
store = []
p iterate = pˆv
for i = 1:3
for j = 1:3
tri = zero(1)
for z = 1:3
tri = tri + min(p iterate[i,z],p iterate[j,z])
end
push!(store,tri)
end
end
dobrushin[v] = findmin(store)[1]
end

dobrushin

5
Then, we compute Dobrushin coefficient for different value of delta for kernel Q1
It returns the following graph:

Note that the vertical axis corresponds to the Dobrushin coefficient, and the horizontal
axis to the different values of δ
Code is as follows:

alpha = 0.2
beta = 0.1
dobrushin = []
deltas = linspace(0.01,1,100)
for delta in deltas

p = [1-alpha alpha 0;
delta 1-beta-delta beta;
delta 1-beta-delta beta]
store = []
for i = 1:3
for j = 1:3
tri = zero(1)
for z = 1:3

6
tri = tri + min(p[i,z],p[j,z])
end
push!(store,tri)
end
end
a = findmin(store)[1]
push!(dobrushin,a)
end

using Plots
plot(deltas,dobrushin, label = "Dobrushin cofficient")

2 Question 2

To introduce depreciation rate, we define production function as y(k) = ez ktα + (1 − δ)kt


where z is normally distributed. So that the resource constraint is still: ct + kt+1 = yt .
In order to find the stationary distribution, we do the following steps:

1. Define the appropriate bellman equation:

Z
w(yt ) = max {u(ct ) + β w(yt+1 )φ(dz))}

The integration is over ez where z is normally distributed

2. We solved for the fixed point of value function using the bellman operator. To get
the value function we used fitted value function iteration approach that is based
on linear interpolation. We carried out this step using the Julia function ”compute
fixed point”. Note that the expectation (or likewise, the integral) in the bellman
equation is handled by Monte Carlo.

3. Compute the policy function σ(yt ) = ct from the fixed point of bellman equation.
Apply linear interpolation to the policy function to evaluation the policy function
taking input in real number line.

7
4. From the definition of production function, we establish the following recursive
function

yt+1 = ez (yt − σ(yt ))α + (1 − δ)(yt − σ(yt ))

With an initial condition y0 and a sequence of shocks, we can simulate a realization


of {yt }Tt=0 . We use Monte Carlo simulation to simulate 10000 realizations with
length 2000. For each realization, {kt+1 }Tt=0 is calculated by kt+1 = yt − σ(yt ). We
then sketch the histogram to illustrate the how capital is distributed over 10000
simulations. To transform the histogram into probability distribution graph, we
can divide the unit in vertical axis of histogram graph by 10000.

2.1

When δ = 0.2, the distribution of capital is as following histogram:

8
Most of mass points are clustered within (0, 10] interval.

The mean difference between distribution of capital in period 2000 and period 1999
is 0.034 and variance difference is 2.65. As number of simulation goes to infinity, these
two differences in moments should go to 0.

When δ = 1, the distribution of capital is as following histogram:

9
We observe that when the depreciate is higher, the mass points are dense to the left
of the distribution. Most of the mass points are in (0, 2] interval. It is intuitive since with
full depreciation rate we expect the capital stock to be lower than the case of non-full
depreciation rate.

2.2

When capital lasts for two periods, we simply set δ = 0 and go over the same procedure
above. We find that the distribution of capital moves to the right of real number line as
time goes by. This is due to the persistence of the capital stock and it accumulates more
as the economy goes into the future. The graphs below illustrate the idea

10
11
The shape of the distribution seems to be the same but the mass points when T =
2000 range from some 80000 to 120000 units of capital, while it ranges from some 20000
to 45000 units of capital where T = 1000. We conclude that the system is not stable and
also dependent on initial value, comparing to the case where δ = 0.2.

2.3

For part (c), we just need to redefine the utility function inside the bellman equation.
Assume full depreciation rate.

When σ = 0.5, the average capital stock is approximately 0.3 and it is 0.92 when σ = 2.

12
The mass points of distribution for capital stock shifts to the right when σ increases from
0.5 to 2. Also, in both cases, the global stability of capital stock distribution is achieved.

13
The reason behind this shift is that consumer is more risk averse though they tend to
invest more in capital in facing uncertainty future.
The code we use for question 2 is as following:

using QuantEcon
using Optim

function bellman operator(w::Vector,


grid::Vector,
beta::AbstractFloat,
shocks::Vector,

14
Tw::Vector = similar(w);
compute policy::Bool = false)

w func = LinInterp(grid, w)

if compute policy
= similar(w)
end

## For part 2c we explicity specify the utility function - ((cˆ(1-sigma) - 1)/(1-sigma))


in the Bellman equation.

for (i, y) in enumerate(grid)


objective(c) = - u(c) - beta * mean(w func.(shocks.*((y-c)ˆalpha)) + (y-c)*(1-d))
res = optimize(objective, 1e-10, y)

if compute policy
sigma[i] = res.minimizer
end
Tw[i] = - res.minimum
end

if compute policy
return Tw, sigma
else
return Tw
end
end

alpha = 1/3
beta = 0.96
mu = 0
s = 1
## Different value of delta is used for different parts of question 2.
d = 0.2; 0 ; 1;

15
## In 2c we specify sigma;
sigma = 2; 0.5;

grid max = 4 # Largest grid point


grid size = 200 # Number of grid points
shock size = 1000 # Number of shock draws in Monte Carlo integral

grid y = collect(linspace(1e-5, grid max, grid size));


shocks = exp.(mu + s * randn(shock size));

bellman operator(w) = bellman operator(w,


grid y,
beta,
shocks)

Tw = similar(grid y)
initial w = 5 * log.(grid y)
v star approx = compute fixed point(bellman operator,
initial w,
max iter=500,
verbose=2,
print skip=10,
err tol=1e-5);

Tw, sigma = bellman operator(v star approx,


grid y,
beta,
shocks,
compute policy=true)

sigma func = LinInterp(grid y, sigma)

ts length= 2000;
no simul = 10000;
y = Array{Float64}(ts length);

16
k = Array{Float64}(ts length);

store y = Array{Float64}(no simul,ts length);


store k = Array{Float64}(no simul,ts length);

y[1] = 0.1

for i = 1:no simul


eps = randn(ts length-1);

for t in 1:(ts length-1)


y[t+1] = (y[t] - sigma func(y[t]))ˆalpha * exp(mu + s * eps[t])
+ (y[t] - sigma func(y[t]))

k[t+1] = y[t+1] - sigma func(y[t+1])


end
store y[i,:] = y
store k[i,:] = k
end

using PyPlot

function plot histogram(period)


ioff()
fig = figure("pyplot histogram",figsize=(10,10))
ax = axes()
h = plt[:hist]((store k[:,period])',30)
grid("on")
xlabel("X")
ylabel("Y")
title("Histogram, T = $period")
end

period = ts length

17
plot histogram(period)

18

You might also like