# Zero one inflated beta regression in STAN

**URL:** <https://discourse.mc-stan.org/t/zero-one-inflated-beta-regression-in-stan/1519>\
**Category:** Modeling\
**Created:** [August 8, 2017, 3:19pm UTC](https://discourse.mc-stan.org/t/zero-one-inflated-beta-regression-in-stan/1519 "2017-08-08T15:19:53Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![markhw](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/markhw/32/5701_2.png) [@markhw](https://discourse.mc-stan.org/u/markhw)\
**Post date:** [November 27, 2017, 6:33pm UTC](https://discourse.mc-stan.org/t/zero-one-inflated-beta-regression-in-stan/1519/12 "2017-11-27T18:33:49Z")

</div>

Would replacing `inv_logit` and `bernoulli` to `bernoulli_logit` actually decrease the bias in estimation, increase the efficiency of the computing, or is it to make the code more readable?

The `is_discrete` variable is modeling whether or not the `y` is {0, 1}. If it is, then `y_discrete` is the value (0 or 1) that the discrete variable takes. `y` is then for all other observations (0, 1).

I was worried about unmodeled gaps, too. We are trying to model alpha, gamma, mu, and phi, however, where the values of 0 and 1 have the probabilities:

 ![41 PM](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/9/9efee9841d6ea99d6fce8d08749d94986c2b6873.png)

(taken from 6 here: [https://arxiv.org/pdf/0705.0700.pdf](https://arxiv.org/pdf/0705.0700.pdf))

That might help explain the `is_discrete` variable. So if we condition on alpha and then to the if-else, we incorporate the alpha \* gamma probability of being one.

I felt that the unmodeled gaps would be an issue, so I tried to model it:

```
is_discrete ~ bernoulli(alpha);
  for (i in 1:n) {
    if (is_discrete[i] == 1) {
      y[i] ~ bernoulli(gamma[i]);
    } else {
      y[i] ~ beta(p[i], q[i]);
    }
  }

```

But it throws an error for using two different likelihoods, depending on the case?

---

_[View the full topic](https://discourse.mc-stan.org/t/zero-one-inflated-beta-regression-in-stan/1519)._
