When using iid shocks, you have to pass the grid e_grid
and probability vector pi_e
to vfoptions
and simoptions
.
I have passed pi_e
as a row vector to the distribution by mistake, i.e.
vfoptions.pi_e = pi_e(1,:)';
simoptions.pi_e = pi_e(1,:); % Here I forgot the transpose!!!
and the code returns with an error
Error in StationaryDist_FHorz_Case1 (line 161)
simoptions.pi_e_J=simoptions.pi_e.*ones(1,N_j,‘gpuArray’);
This can be easily fixed by typing
simoptions.pi_e = pi_e(1,:)'
Interestingly, if I pass a row vector pi_e to the VFI, then I get an informative error:
vfoptions.pi_e is not the correct shape (should be of size N_e-by-1 or N_e-by-N_j)
I would propose to add this error also to the stationary distribution, or to add to both VFI and distribution the following three lines:
if isrow(simoptions.pi_e)
simoptions.pi_e=simoptions.pi_e'
end
Unrelated to the error: Is it possible to pass two iid shocks? My idea is
vfoptions.e_grid = [e1_grid;e2_grid];
vfoptions.pi_e = kron(e2_prob,e1_prob); %note kron in reverse order