# Missing observed varialbe in posterior\_predictive

**URL:** <https://discourse.pymc.io/t/missing-observed-varialbe-in-posterior-predictive/10783>\
**Category:** v5\
**Created:** [November 9, 2022, 2:01pm UTC](https://discourse.pymc.io/t/missing-observed-varialbe-in-posterior-predictive/10783 "2022-11-09T14:01:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterBleackley](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@PeterBleackley](https://discourse.pymc.io/u/PeterBleackley)\
**Post date:** [November 9, 2022, 2:01pm UTC](https://discourse.pymc.io/t/missing-observed-varialbe-in-posterior-predictive/10783/1 "2022-11-09T14:01:04Z")

</div>

I have a model with two observed varialbes, `Fz_obs` and `RPM_obs`. After sampling the model, I try to run posterior predictive checks as follows

```auto
with Fz_model:
    pymc.sample_posterior_predictive(idata,
                                    var_names=['Fz_obs','RPM_obs'],
                                    extend_inferencedata=True,
                                    return_inferencedata=True)
az.plot_ppc(idata)

```

However, when I run this, I get the following error message

```auto
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/.cache/pypoetry/virtualenvs/tool-insight-HtaDeJzl-py3.10/lib/python3.10/site-packages/arviz/utils.py:71, in _var_names(var_names, data, filter_vars)
     70 try:
---> 71 var_names = _subset_list(var_names, all_vars, filter_items=filter_vars, warn=False)
     72 except KeyError as err:

File ~/.cache/pypoetry/virtualenvs/tool-insight-HtaDeJzl-py3.10/lib/python3.10/site-packages/arviz/utils.py:149, in _subset_list(subset, whole_list, filter_items, warn)
    148 if not np.all(existing_items):
--> 149 raise KeyError(f"{np.array(subset)[~existing_items]} are not present")
    151 return subset

KeyError: "['RPM_obs'] are not present"

```

Examining the `posterior_predictive` section of `idata`, it does indeed appear that the posterior predictive distribution has only been generated for `Fz_obs` and not for `RPM_obs`. Why has this happened and what can I do about it?

---

<div class="post-metadata">

**Author:** ![PeterBleackley](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@PeterBleackley](https://discourse.pymc.io/u/PeterBleackley)\
**Post date:** [November 9, 2022, 3:59pm UTC](https://discourse.pymc.io/t/missing-observed-varialbe-in-posterior-predictive/10783/2 "2022-11-09T15:59:09Z")

</div>

Answering my own question here. Restarting the notebook and rerunning has solved the problem. I had copied and pasted a lot of code from another notebook, so that cell originally read `var_names='['Fz_obs'],` I must have run it before adding `RPM_obs` to the option, and subsequent invocations with a corrected option did not overwrite the existing `posterior_predictive`.
