Skip to content

TransitionPath_FHorz_substeps_Step2_AdjustPolicy over-adjusts a2primeIndexesPath #97

@MichaelTiemann

Description

@MichaelTiemann

Lines 69-110 adjust a2primeIndexesPath and a2primeProbsPath to include the upper index and upper prob respectively. This changes the shape from [N_a,N_ze,N_j-1,1,T-1] (with z and/or e) to [N_a,N_ze,N_j-1,2,T-1], which is then further reshaped to [N_a*(N_j-1)*N_ze,2,T-1]. So far, so good. The code without z and e is similar in spirit (slightly different in shape) all that follows applies to it in its respective shape as well.

Later (following the z and/or e case) we create:

        elseif N_probs>1 % for a reason other than gridinterplayer
            PolicyaprimejzPath=reshape(PolicyaprimejzPath,[N_a*(N_j-1)*N_z,1,T-1]); % so can assume this size later

So far, so good.

At line 475,. and quite many other cases, we run into trouble:

                PolicyaprimejzPath=repmat(PolicyaprimejzPath,1,2,1)+repelem(simoptions.setup_experienceasset.N_a1*(a2primeIndexesPath-1),1,2,1);

The first half of the sum is the PolicyaprimejzPath needing to cover the upper and lower grids--all good. The second half of the sum attempts to re-expand a2primeIndexesPath. I think this should be the pattern (and similarly adjusted in the case of no z and no e):

                PolicyaprimejzPath=repmat(PolicyaprimejzPath,1,2,1)+simoptions.setup_experienceasset.N_a1*(a2primeIndexesPath-1);

Even better, we could lift the repmat up to the construction of PolicyaprimejzPath and PolicyProbsPath so that it is correct coming out of the gate, saving over a dozen calls to repmap thoughout the 4 z/e combinations across two fastOLG options across both variables.

I'm going to merge that into my changes for when you are ready to take a look at it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions