# PType Weights--the new \`units\` error!

**URL:** https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675
**Category:** Uncategorized
**Created:** [June 20, 2026, 1:49am UTC](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675 "2026-06-20T01:49:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MichaelTiemann](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/michaeltiemann/32/220_2.png) [@MichaelTiemann](https://discourse.vfitoolkit.com/u/MichaelTiemann)
#### Post date: [June 20, 2026, 1:49am UTC](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675/1 "2026-06-20T01:49:36Z")

</div>

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`:

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

```

In this case, my `AggVars_ConditionalOnPtype` is as follows:

```auto
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:

```auto
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`.

---

<div class="post-metadata">

### Author: ![MichaelTiemann](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/michaeltiemann/32/220_2.png) [@MichaelTiemann](https://discourse.vfitoolkit.com/u/MichaelTiemann)
#### Post date: [June 20, 2026, 3:36am UTC](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675/2 "2026-06-20T03:36:18Z")

</div>

Something like this, perhaps:

> <https://github.com/MichaelTiemann/VFIToolkit-matlab/commit/253039b64adae1ad0123f74486d8dc4a88ebbb75>

---

<div class="post-metadata">

### Author: ![robertdkirkby](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/robertdkirkby/32/287_2.png) [@robertdkirkby](https://discourse.vfitoolkit.com/u/robertdkirkby)
#### Post date: [June 20, 2026, 6:09am UTC](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675/3 "2026-06-20T06:09:59Z")

</div>

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’?

---

<div class="post-metadata">

### Author: ![MichaelTiemann](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/michaeltiemann/32/220_2.png) [@MichaelTiemann](https://discourse.vfitoolkit.com/u/MichaelTiemann)
#### Post date: [June 20, 2026, 6:30am UTC](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675/4 "2026-06-20T06:30:27Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![robertdkirkby](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/robertdkirkby/32/287_2.png) [@robertdkirkby](https://discourse.vfitoolkit.com/u/robertdkirkby)
#### Post date: [June 20, 2026, 11:33am UTC](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675/5 "2026-06-20T11:33:39Z")

</div>

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.
