The Endogenous grid method (EGM) using fast upper-envelope scan (FUES).
Initial beta replication material for `Fast upper-envelope scan for discrete-continuous dynamic programming' by Dobrescu and Shanker (2023).
See slides....pdf
for overview of upper envelope scan.
Suppose we have the following arrays: an unrefined endogenous grid x_hat
, the value correspondence on the unrefined grid v_hat
and two policy functions, c_hat
and a_prime_hat
.
from FUES.FUES import FUES
x_clean, vf_clean, c_clean, a_prime_clean, dela \
= FUES(x_hat, v_hat, c_hat, a_prime_hat, M_bar = 2, LB = 10)
The outputs are the refined grids, M_bar
is the jump detection threshold and LB
is the number of steps to take in the forward and backward scans.
Consumption policy function generated using Ishkakov et al (2017) params and no smoothing:
Upper envelope generation using FUES and Ishkakov et al (2017) params (age 17):
Upper envelope and policy functions for Ishkakov et al (2017) params and smoothing param = 0.05:
Comparison with DC-EGM (age 17):
The following code block in retirement_plot.py
compares DC-EGM with FUES across an array of parameter values:
To perform the comparison, we first solve the full model using FUES, which gives the final solution computed using FUES and also the unrefined endogenous grids for each age. For a given age, we then compute the upper envelope using DC-EGM and FUES. The upper envelopes are compared on the optimal endogenous grid points as determined by DC-EGM.
(Compared on optimal points to avoid picking up errors arising from different interpolation steps used by DC-EGM and FUES. DC-EGM interpolates line segments on the unrefined grid while FUES first calculates the optimal points then interpolates over the unrefined grid.)
Test DC-EGM vs. FUES on uniform grid of 1000 parameters:
beta: (0.85,0.98), y: (10,25), delta: (0.5,1.5)
Avg. error between DC-EGM and FUES: 0.000000
Timings:
Avg. FUES time (secs): 0.001375
Avg. worker iteration time (secs): 0.004314