# Plot doesn't look good from pp\_check() in brms

**URL:** <https://discourse.mc-stan.org/t/plot-doesnt-look-good-from-pp-check-in-brms/30164>\
**Category:** Modeling\
**Tags:** brms\
**Created:** [January 25, 2023, 8:24pm UTC](https://discourse.mc-stan.org/t/plot-doesnt-look-good-from-pp-check-in-brms/30164 "2023-01-25T20:24:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhffk](https://avatars.discourse-cdn.com/v4/letter/z/858c86/32.png) [@zhffk](https://discourse.mc-stan.org/u/zhffk)\
**Post date:** [January 25, 2023, 8:24pm UTC](https://discourse.mc-stan.org/t/plot-doesnt-look-good-from-pp-check-in-brms/30164/1 "2023-01-25T20:24:28Z")

</div>

Hi all,

I ran a linear mixed model with brms and checked the plot from pp\_check(). I’m not very familiar with bayesian analysis, so this might be a dumb question.

What should I do if there seems to be a big discrepancy between y and y rep. What does this discrepancy mean? Can I go with this model? If not, how should I resolve the discrepancy?

Here’s my model and the plot from pp\_check(), in case these matter:

```plaintext
model <- brm(rating ~ a*b*c + (1|subjectID), 
                                       family = gaussian(), data = data, save_pars = save_pars(all=TRUE),
                                       cores = 2, chains = 2, iter = 10000, warmup = 5000,
                                       prior = set_prior('student_t(3, 0, 2.5)', class = 'b'))

pp_check(model, "dens_overlay")

```

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/c/cb254930617470a47a9d1b465a323400000b9ddc.jpeg)

Thank you!

---

<div class="post-metadata">

**Author:** ![jsocolar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jsocolar/32/2486_2.png) [@jsocolar](https://discourse.mc-stan.org/u/jsocolar)\
**Post date:** [January 25, 2023, 9:07pm UTC](https://discourse.mc-stan.org/t/plot-doesnt-look-good-from-pp-check-in-brms/30164/2 "2023-01-25T21:07:28Z")

</div>

Here your data are bimodal and your modeled response is not. This suggests that either the random component of the response is itself bimodal, which can be achieved in `brms` using a custom family that is a mixture of two distributions (rather than a single Gaussian as in your model), or that your model is missing a key covariate that can distinguish which mode a point is likely to fall into. Faced with this PPC, I would suggest first examining the sets of points whose response is greter than about 3.5 and the set of points whose response is less than about 3 to see whether I overlooked anything obvious that could differentiate those sets of points. If not, I would consider modeling the response as a mixture of two Gaussians.

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [January 26, 2023, 2:09pm UTC](https://discourse.mc-stan.org/t/plot-doesnt-look-good-from-pp-check-in-brms/30164/3 "2023-01-26T14:09:04Z")

</div>

@jsocolar answer is good. I would also be curious as to what your response variable `rating` is. Is it a continuous unbounded variable? Based on the density plot for the posterior predictive check, I would hazard a guess that it is a variable that is bounded at 0 on the lower end and maybe 5 on the upper end? Is it continuous or discrete? What does `pp_check(model, type="hist")` look like?

---

<div class="post-metadata">

**Author:** ![Solomon](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/solomon/32/2495_2.png) [@Solomon](https://discourse.mc-stan.org/u/Solomon)\
**Post date:** [January 27, 2023, 2:42pm UTC](https://discourse.mc-stan.org/t/plot-doesnt-look-good-from-pp-check-in-brms/30164/4 "2023-01-27T14:42:58Z")

</div>

Building off of @jd_c, your `rating` variable looks like it might be ordinal. If so, you might consider ditching the conventional Gaussian likelihood for an ordinal model (see [here](https://journals.sagepub.com/doi/pdf/10.1177/2515245918823199)).
