PType Weights--the new `units` error!

The title of this topic draws attention to the fact that it is easy to make mathematical errors by not taking units into account. And that in a sense, if we are expecting AggVars (or other things) to distribute across PType weights, then we must be consistent in that interpretation, both in the formation of the Aggregate value and in its use (such as in q GE equation).

I tracked down a problem to the fact that in trying to correct the warning message about PType Weights not summing to 1 (from StationaryDist_MixHorz_PType), I created a different problem in the interpretation of AggVars. The offender is this line from HeteroAgentStationaryEqm_MixHorz_PType_subfn:

AggVars=sum(AggVars_ConditionalOnPType.*PTypeStructure.ptweights',2);

In this case, my AggVars_ConditionalOnPtype is as follows:

AggVars_ConditionalOnPType =

         0    0.9444         0
         0    0.9506         0
         0    0.0877         0
         0    0.1917         0
         0    0.0001         0
         0         0         0
         0    0.0335         0
         0    0.0119         0
         0    0.3005         0
         0    0.0949         0
         0    0.0266         0
    0.7409         0         0
    1.4245         0         0
    0.0104         0         0
    0.0970         0         0
    0.1883         0         0
    0.6973         0         0
    0.0703         0         0
    0.1493         0         0
    0.0232         0         0
         0         0    1.2049
         0         0    1.0788
         0         0         0
         0         0    0.0000

and my ptweights are:

PTypeStructure.ptweights

ans =

    0.5000
    0.4000
    0.1000

Why these weights? Because both the general dollar value of economic activity and energy usage is distributed according to those numbers. However, as can be seen from the AggVars, none of them span multiple PTypes; they are all unique to their respective PTypes.

Clearly, due to this mutual exclusivity, I should not set the PType weights to other than 1, and somehow the warning message should be suppressed after taking the conditionality into account.

I’m posting this in case there are other considerations, either from the AggVars usage or generation perspective, or in other ways the PType weights are used.

UPDATE: I note that HeteroAgentStationaryEqm_MixHorz_PType does evaluate the conditionality term, so perhaps the solution is to port the conditionality logic from that function into StationaryDist_MixHorz_PType and only complain when the conditional values sum to other than 1.

Something like this, perhaps:

Am I correct that what you are saying is that
HeteroAgentStationaryEqm_MixHorz_PType_subfn
is calculating AggVars incorrectly when the sum of the ptype weights is not equal to one?

And more specifically, that the error is that it calculates the ‘unconditional mean’ rather than the ‘conditional mean’?

Thanks for giving the problem a more specific name. The calculation of the unconditional mean vs conditional is the specific problem. I’m happy that I’ve resolved the case where all weights are one and it no longer throws a warning. I don’t think my patch properly nomalizes the case where the weights sum to one [0.5, 0.4, 0.1] and the conditional mean properly divides out the values that do apply (dividing the PType2 AggVar by 0.4 to get the right answer).

Kind of makes sense as “weights that don’t add to one” is not really something that appears in most Econ models of the past 20 years, except those with entry and exit which get dealt with in the toolkit somewhat separately.

Once I return in July I will try and go through all the ptype commands and make sure they all calculate AggVars as conditional on ptype mass.