# Ptypes and conditional statistics

**URL:** https://discourse.vfitoolkit.com/t/ptypes-and-conditional-statistics/677
**Category:** Uncategorized
**Created:** [June 20, 2026, 8:21pm UTC](https://discourse.vfitoolkit.com/t/ptypes-and-conditional-statistics/677 "2026-06-20T20:21:35Z")
**Posts on this page:** 1
**Showing post:** 2

<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, 8:40pm UTC](https://discourse.vfitoolkit.com/t/ptypes-and-conditional-statistics/677/2 "2026-06-20T20:40:10Z")

</div>

I think you are running into the same problem I noted in the post [PType Weights--the new `units` error!](https://discourse.vfitoolkit.com/t/ptype-weights-the-new-units-error/675)

That you are trying to compute a variance based on age and not on PType may not be relevant. What is likely relevant is how you compute your AggVars (the sum of evaluations of a function). What I found is that the per-PType AggVars have their values divided by their PType weights, anticipating that they will ultimately be summed to produce a correct result. But if you use the AggVar by itself (asking what is the Income of one of the PTypes), it will give you a weight-factored answer, which is not what you want.

I solved the simple problem of computing the conditional mean across PTypes. I think the problem you have identified, which I also note in the above thread, remains to be solved. I could give it a crack later today, in which case I’ll post to this thread a link to the commits that will get you there.

---

_[View the full topic](https://discourse.vfitoolkit.com/t/ptypes-and-conditional-statistics/677)._
