# Trying to fit a model for zero-inflated distribution

**URL:** https://discourse.mc-stan.org/t/trying-to-fit-a-model-for-zero-inflated-distribution/24488
**Category:** Modeling
**Tags:** fitting-issues
**Created:** [September 19, 2021, 8:29am UTC](https://discourse.mc-stan.org/t/trying-to-fit-a-model-for-zero-inflated-distribution/24488 "2021-09-19T08:29:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![juthzi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/juthzi/32/12936_2.png) [@juthzi](https://discourse.mc-stan.org/u/juthzi)
#### Post date: [September 19, 2021, 8:29am UTC](https://discourse.mc-stan.org/t/trying-to-fit-a-model-for-zero-inflated-distribution/24488/1 "2021-09-19T08:29:23Z")

</div>

I am trying to fit a brms model to data which shows a zero-inflated bimodal distribution, namely the participants’ eye fixation duration within a certain region of interest which can be anything from 0 to 4.6 seconds. My independent variable is the pitch which accompanies the trial (2 different pitch levels) and the random terms for study participant and object in the trial.

* * *

The following is the model I have been trying to fit, after I found that the gaussian()-model might not be the best fit:

```stan
model <- brm(fixation_duration ~ 1 + pitch_fac
                                                 + (1 + pitch_fac | subject)
                                                 + (1 | object),
                                                 family = hurdle_gamma(link = 'log'), 
                                                 warmup = 1000, 
                                                 iter = 2000,
                                                 data = total_fix_duration_eyes_per_trial %>% filter(group == 0),
                                                 cores = 2)

```

However, the ppcheck shows this is not an optimal fit, either:

![Bildschirmfoto 2021-09-19 um 10.28.39](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/6/698a17a18124ad9a0428aceba6bcb7021ff1d9f4.png)

I am not sure how to best improve the fit (i.e. which family and link to choose) and my modelling skills are limited. So, if any of you have encountered a similar situation or know how to best approach this, I would be glad to get some tipps.

---

<div class="post-metadata">

### Author: ![Ara\_Winter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ara_winter/32/4284_2.png) [@Ara\_Winter](https://discourse.mc-stan.org/u/Ara_Winter)
#### Post date: [September 19, 2021, 11:09pm UTC](https://discourse.mc-stan.org/t/trying-to-fit-a-model-for-zero-inflated-distribution/24488/2 "2021-09-19T23:09:47Z")

</div>

I usually start pretty basic with any model, do the default priors make sense given the data, prior knowledge, and model you chose? I think that should be get\_priors in brms? If those make sense, does simulated data return the known parameters?

---

<div class="post-metadata">

### Author: ![juthzi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/juthzi/32/12936_2.png) [@juthzi](https://discourse.mc-stan.org/u/juthzi)
#### Post date: [October 18, 2021, 12:02pm UTC](https://discourse.mc-stan.org/t/trying-to-fit-a-model-for-zero-inflated-distribution/24488/3 "2021-10-18T12:02:11Z")

</div>

Thank you for your answer, Ara\_Winter. I checked whether the default priors made sense, and found that they did not. However, the gamma distribution was not a suitable distribution to begin with. I changed the model to be a zero\_inflated\_beta family model. For this, I transformed my values to be proportional in order to end up with values from 0 and 1. Using this distribution has the advantage that the non-zero-peak can be modelled anywhere between 0 and 1. Also, I changed the priors the model comes with. I chose priors that allow for great variation, because the data I will enter can have peaks in different locations.
