import numpy as np
Estimating income processes
Consider households indexed by who are in the labor market for periods indexed by .
Their wage income is stochastic and given by
where
- is the standard deviation of the permanent shocks,
- is the standard deviation of the transitory shocks,
- is the risk of unemployment.
The data you have access to is:
dataY = np.load('dataY.npy')
T,N = dataY.shape
Question 1: Calculate income growth rates as log-changes
where is not-a-number (i.e. np.nan
).
Question 2: Calculate the following 3 statistics from the data
- : Share of observations with
- : Variance of income growth rate,
- : Co-variance of income growth rates one period apart,
Question 3: Simulate the income process using your own choice of , , , and . Calculate the 3 same statistics. Compare with the data statistics.
- : Share of observations with
- : Variance of income growth
- : Co-variance of income growth one periods apart
Question 4: Solve the following minimization problem to estimate , and
where for each new guess of , , and you should be re-simulating the data with the same seed and re-calculating the 3 statistics.
def objective():
pass
# res = optimize.minimize(objective,x,method='L-BFGS-B',bounds=?,args=?,options={'eps':1e-4})
# hint: options={'eps':1e-4} uses a larger step-size when approximating the jacbian, which is useful in this case
Wealth in the utility function
In the final period, , the household solves the following problem
where
- is end-of-period assets in period
- is consumption in period
- is the CRRA-coefficient for consumption utility
- is the CRRA-coefficient for wealth utility
- is an additive scaling factor for wealth utility
- is a multiplicative scaling factor for wealth utility
- is the rate of return
- is income
The optimal consumption function is denoted .
The optimal savings function is denoted .
# a. parameters
rho = 2.0
sigma = 1.2
kappa = 0.6
a_ubar = 2.0
r = 0.04
y = 1.0
# b. grids
a_lag_vec = np.linspace(0,300,300)
Question 1: Find and plot the functions , , and .
In all periods before the last, , the household solves:
where is the discount factor for future utility.
beta = 0.97
T = 20
Question 2: Find and plot and .
Question 3: Find for and plot them in a single figure.
Define the saving rate as:
Question 4: Plot . Do the rich or the poor save the most?
Question 5: Can you change the parameter choices such that is monotonically decreasing in ?
Refined grid search
Let be a two-dimensional vector.
Consider the following algorithm:
Algorithm: grid_search()
Goal: Minimize the function .
- Choose a grid size and minimum and maximum values of and denoted and
Calculate step-sizes
Find the grid point with the lowest function value by solving
- Return , and .
Question 1: Implement the grid_search()
algorithm to minimize the rosen function.
Hint: The global minimum of the rosen function is at .
def rosen(x):
return (1.0-x[0])**2+2*(x[1]-x[0]**2)**2
def grid_search(f,x1_min,x1_max,x2_min,x2_max,N):
return np.nan,np.nan,np.nan
# settings
x1_min = 0
x1_max = 5
x2_min = 0
x2_max = 4
N = 100
# apply grid search
x1,x2,f = grid_search(rosen,x1_min,x1_max,x2_min,x2_max,N)
print(f'minimum found at ({x1:.8f},{x2:.8f}) with the function value {f:.8f}')
minimum found at (nan,nan) with the function value nan
Also, consider the following algorithm:
Algorithm: refined_grid_search()
Goal: Minimize the function .
Choose a grid size and minimum and maximum values of and denoted and , and a refinement-level
Set
If : Update the minimum and maximum values by
Apply the
grid_search()
algorithm returning , andIncrement by one
If return to step 3 else continue
Return , and
Question 2: Implement the refined_grid_search()
algorithm to minimize the rosen function.
def refined_grid_search(f,x1_min,x1_max,x2_min,x2_max,N,K):
return np.nan,np.nan,np.nan
# more settings
K = 10
# apply refined grid search
x1,x2,f = refined_grid_search(rosen,x1_min,x1_max,x2_min,x2_max,N,K)
print(f'minimum found at ({x1:.8f},{x2:.8f}) with the function value {f:.8f}')
minimum found at (nan,nan) with the function value nan