New Bug in StationaryDist_FHorz_Iteration_SemiExo_noz_raw

I got this error:

Error using sparse
Vectors must be the same length.

Error in StationaryDist_FHorz_Iteration_SemiExo_noz_raw (line 46)
    Gammatranspose=sparse(Policy_aprimesemiz(:,:,jj),II2,semiztransitions,N_a*N_semiz,N_a*N_semiz); % From (a,semiz) to (a',semiz')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in StationaryDist_FHorz_SemiExo (line 78)
        StationaryDist=StationaryDist_FHorz_Iteration_SemiExo_noz_raw(jequaloneDist,AgeWeightParamNames,Policy_dsemiexo,Policy_aprime,N_dsemiz,N_a,N_semiz,N_j,pi_semiz_J,Parameters);
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in StationaryDist_FHorz_Case1 (line 201)
    StationaryDist=StationaryDist_FHorz_SemiExo(jequaloneDist,AgeWeightParamNames,Policy,n_d,n_a,simoptions.n_semiz,n_z,N_j,simoptions.pi_semiz_J,pi_z_J,Parameters,simoptions);
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in StationaryDist_Case1_FHorz_PType (line 234)
        StationaryDist_ii=StationaryDist_FHorz_Case1(jequaloneDist_temp,AgeWeightParamNames_temp,Policy_temp,n_d_temp,n_a_temp,n_z_temp,N_j_temp,pi_z_temp,Parameters_temp,simoptions_temp);
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in fun_solve1 (line 124)
StatDist=StationaryDist_Case1_FHorz_PType(jequaloneDist,AgeWeightsParamNames,PTypeDistName,Policy,n_d,n_a,n_z,N_j,N_i,pi_z,Params,simoptions);
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in main (line 122)
[V, pol_s,pol_aprime,StatDist,ValuesOnGrid,AllStats,AgeStats,SimPanelValues,AgeStatsSim] = fun_solve1(Params,a_grid,s_grid,l_grid,g_grid,pi_l,pi_g,N_j,N_i);
                                                       

You can reproduce the error by running the code/main.m in this repo: GitHub - aledinola/life-cycle-search · GitHub

I got the error reported above today when I updated my vfi-toolkit repo.

@robertdkirkby: Did you modify something that broke the codes? It was working so well :smiley:

I’m working on a paper that uses this code… I did update from upstream/master and I guess it synced the local code on my computer to the official toolkit repo online. Is there a way I can revert back to the previous version? I apologize in advance for my limited knowledge of Github.

UPDATE
All good, I managed to revert back to the version before the commit " improve semiz iteration"
I definitely have to improve my knowledge of git and github :slight_smile:
The good thing is that now we isolated the problem.

Would be this change

But not obvious to me what the error was caused by as I tried a few examples that all worked and covered the obvious alternatives. Anyway, I’ll run your example on Monday and see if I can figure it out.

Fixed. Was a trivial error (in one place I accidentally left it saying N_semiz where it should have said N_semizshort).

Should work now. And should be faster than it used to be.

Also, this model will be better performing if you turn on grid interpolation layer.

1 Like

Thanks a lot, I will test it right now

All good. I use interpolation in my real project. This is just a demo to test the toolkit with a toy model and make sure the toolkit functions give correct results. You can notice that I have double coded everything with custom-made functions that run on cpu (with the exception of the panel simulation). The results are identical across toolkit and my own cpu implementation.

Since I don’t have time to code the interpolation method on the cpu, I am not using it in this test. I just trust the VFI-Toolkit :smiley:

P.S. With this method I found a previous bug in the distribution code.

2 Likes

That makes a lot of sense! Great to have you stress testing everything to the limit :smiley:

1 Like