You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ensure imputed capital gains CDF is valid (monotonic) #83
impute_capital_gains currently interpolates/extrapolates the provided quantiles to a CDF by fitting splines. This can result in CDFs that are not monotonically increasing and thus invalid.
After asking ChatGPT for some ideas, I think a promising approach could be first synthesizing a pdf from the quantiles, smoothing it with a kernel density estimator, then integrating it to a cdf. Here's an example of how that might look:
Other options like isotonic regression or transformations could also work, and we may want something more complex if we want to consider all the data together rather than each income group independently.
Activity
MaxGhenis commentedon Feb 25, 2024
FWIW I only saw one income level where the spline was obviously nonmonotonic, so might not be such a high priority:

https://policyengine-uk-documentation.nw.r.appspot.com/Capital_Gains_Tax
MaxGhenis commentedon Feb 25, 2024
The PCHIP Interpolator seems ideally suited to this. It both preserves monotonicity and supports extrapolation.
Here's an example for the 99th income centile, which the spline currently produces a nonmonotonic interpolation from.
Relevant code (notebook):
MaxGhenis commentedon Jun 19, 2026
Closing as migrated/superseded. Populace should use QRF/support gates rather than the old spline-CDF path; see PolicyEngine/microcosm#148.