# Can't seem to \`sample\_prior\_predictive\` on model with missing value imputation

**URL:** <https://discourse.pymc.io/t/cant-seem-to-sample-prior-predictive-on-model-with-missing-value-imputation/7130>\
**Category:** Questions\
**Created:** [March 31, 2021, 5:32pm UTC](https://discourse.pymc.io/t/cant-seem-to-sample-prior-predictive-on-model-with-missing-value-imputation/7130 "2021-03-31T17:32:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonsedar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jonsedar/32/2590_2.png) [@jonsedar](https://discourse.pymc.io/u/jonsedar)\
**Post date:** [March 31, 2021, 5:32pm UTC](https://discourse.pymc.io/t/cant-seem-to-sample-prior-predictive-on-model-with-missing-value-imputation/7130/1 "2021-03-31T17:32:19Z")

</div>

Hi all,

I want to impute some missing values in the predictor features of a linear model, so followed @junpenglao’s excellent [pymcon 2020 tutorial](https://gist.github.com/junpenglao/7c505c6c76f99c928a4e2c1161cff43a), prior [2017 blogpost](https://junpenglao.xyz/Blogs/posts/2017-10-23-OOS_missing.html), and referenced a couple of questions from other folks here (@Dominik [1](https://discourse.pymc.io/t/automatic-imputation-and-posterior-predictive-sampling-with-new-data/6132)), and (@nico [2](https://discourse.pymc.io/t/masking-missing-values-of-predictors/5424)) that seem relevant.

I bumped into an issue with `sample_prior_predictive`: either I’m doing something wrong, or it has a shape issue when there’s missing data in the observations.

I’ve created my own MRE here which describes my question and issue fully: [MRE\_missing\_values · GitHub](https://gist.github.com/jonsedar/070319334bcf033773cc3e9495c79ea0)

Is this expected, or should I expect it to work? Have I done something wrong? Can I do something to fix it? I really ~~need~~ want prior predictive checks in my model workflow, so am grateful of any pointers.

_ **EDIT:** _

Aha, after going for a walk I realised it’s probably because the auto-generated `NoDistribution` doesn’t have a `random` function [pymc3/distribution.py at 2dee9dafb3541043ae23b66fe9262e70fbd2769a · pymc-devs/pymc3 · GitHub](https://github.com/pymc-devs/pymc3/blob/2dee9dafb3541043ae23b66fe9262e70fbd2769a/pymc3/distributions/distribution.py#L282). I’ll take a read through the process that instantiates the dist. Would it be reasonable in principle for me to PR and add a `random` func that returns something (the mean?) of the parent dist, or is `random` missing for a good reason?

_ **EDITEDIT** _

I gave it some thought and raised an issue with a proposed solution that I’ve manually hacked locally and it seems to work: see [Give NoDistribution a random method so that `sample_prior_predictive` can work · Issue #4598 · pymc-devs/pymc3 · GitHub](https://github.com/pymc-devs/pymc3/issues/4598)

Cheers!
