This post has been superseeded by:
I recommend you read that instead of the below which is outdated
I’ve started implementing interpolation on linearly spaced points between the a_grid points. It will be a long time while this is gradually rolled out across the toolkit, but I just wanted to briefly describe the concept here.
As user you just set
vfoptions.gridinterplayer=1
which tells toolkit to use a ‘gridded interpolation layer’, and then use
vfoptions.ngridinterp=5
to say how many points to use for the interpolation.
And then you put the same into simoptions.
Idea is that if you have, say, n_a=20 (and so a_grid is 20-by-1), then between every two consecutive points on the a_grid it will put vfoptions.ngridinterp evenly spaced points. Conceptually, the problem we want to solve is using aprime_grid=interp1(1:1:N_a,a_grid,linspace(1,N_a,N_a+(N_a-1)*vfoptions.ngridinterpt)); (N_a=prod(n_a);) We evaluate the ReturnFn exactly on this aprime_grid, but since a_grid is smaller and the value function will only be on a_grid we have to interpolate E[V] (the expected next period value function) from a_grid onto aprime_grid and this is one with linear interpolation.
Rather than do this in one hit, the codes do it in layers (to avoid the large aprime_grid causing out-of-memory errors). [Actually, I should try the one-hit as well, see how runtimes compare.]
First, the codes just do the usual thing of solving ‘pure discretization’ with the 20 points on next period assets (the same points used for current assets, so a_grid). [Or can use divide-and-conquer for this first part.] This gives us the optimal aprime index (on the a_grid) [Actually slightly different to usual, as solve for the optimal aprime conditional on the possible choices of d]
In a second ‘layer’, the codes consider the range for aprime from one a_grid point below the optimal aprime index to one point above, and puts ‘vfoptions.ngridinterp’ points between these (so we get a_grid-point-below-optimal then vfoptions.ngridinterp evenly spaced points then a_grid-point-optimal then vfoptions.ngridinterp evenly spaced points then a_grid-point-above-optimal), so consider 2*vfoptions.ngridinterp+3 points. This is done conditional on any decision variables, d. Finally find the optimal of these, using exact valuation ReturnFn, and linear interpolation of E[V].
The output for the value function is essentially the same, and the interpretation is identical. The output for the policy function now contains two indexes for the aprime value, the first is a ‘lower grid point’ and the second is from 1-to-(vfoptions.ngridinterp+2) and the two endpoints represent the lower grid point and the upper grid point (and the rest count the evenly spaced points we interpolated onto).
I’ll try write up a pseudo-code sometime soon.
This feature is likely to take at least a full year for me to roll out across VFI Toolkit, so will be a while before you can use it. But the good news is it works, and it is coming your way ![]()