# Combining a hurdle\_lognormal with lognormal in a mixture model

**URL:** https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496
**Category:** brms
**Tags:** mixture, specification, brms
**Created:** [June 14, 2024, 2:08pm UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496 "2024-06-14T14:08:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![johkaa](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@johkaa](https://discourse.mc-stan.org/u/johkaa)
#### Post date: [June 14, 2024, 2:08pm UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496/1 "2024-06-14T14:08:07Z")

</div>

We would like to fit a model combining a hurdle model and a finite mixture model. We want to model the probability for a zero, and then for the non-zero values, we want to assume that the observations come from two separate processes. The question is, is it possible to combine a hurdle model with a finite mixture model in brms code?

We are familiar with the mixture function where you can model two gaussian processes and their proportion. Can this be extended to a model that includes also the hurdle part? Naively we would think that this should work with using mixture (hurdle\_lognormal, lognormal) for the family.

We tried the following code, and got this error:  
Error: The parameter ‘hu’ is not a valid distributional or non-linear parameter. Did you forget to set ‘nl = TRUE’?

We tried setting the nl=TRUE, but it didn’t help.

```no-highlight
mix <- mixture(hurdle_lognormal,lognormal)

hurdle3 <- 
  brm(bf(IA_DWELL_TIME ~ 1 , 
         mu1 ~ 1 , 
         mu2 ~ 1 ,
         theta2 ~ 1 ,
         hu ~ 1 ),
      data = df,
      family = mix)

```

Would be grateful if you had any ideas!

---

<div class="post-metadata">

### Author: ![Ax3man](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ax3man/32/11894_2.png) [@Ax3man](https://discourse.mc-stan.org/u/Ax3man)
#### Post date: [June 14, 2024, 8:40pm UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496/2 "2024-06-14T20:40:30Z")

</div>

When I run in `brms` v2.21.0

```no-highlight
mix <- mixture(hurdle_lognormal,lognormal)

```

I get:

```no-highlight
Error: Some of the families are not allowed in mixture models.

```

---

<div class="post-metadata">

### Author: ![Christopher-Peterson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/christopher-peterson/32/13_2.png) [@Christopher-Peterson](https://discourse.mc-stan.org/u/Christopher-Peterson)
#### Post date: [June 15, 2024, 2:35am UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496/3 "2024-06-15T02:35:31Z")

</div>

The defined mixture doesn’t really make sense to me.  
The lognormal distribution only has support for data with positive values. The hurdle-lognormal modification allows the presence of zeroes by specifying a separate process for zero and non-zero components. I have a hard time conceiving of data that would require both the hurdle-lognormal and the lognormal?

Are you trying to run a mixture of two lognormals for the non-zero component? I’m not certain if you’ll be able to do that out of the box in brms, though it should be doable in Stan.

---

<div class="post-metadata">

### Author: ![johkaa](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@johkaa](https://discourse.mc-stan.org/u/johkaa)
#### Post date: [June 15, 2024, 4:18am UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496/4 "2024-06-15T04:18:13Z")

</div>

The data are reading times of words within a sentence. Sometimes readers skip words, resulting in reading time = 0. The conditional reading time (i.e. the reading time if the word is NOT skipped) seems to have two peaks, suggesting that we have two processes driving those observations (reflected as faster and slower reading time). And as all reaction time measures, the distribution is right-skewed (thus, lognormal).

So yes, we are trying to run a mixture of hurdle for the skipping (0 = skipped), and two lognormals for the non-zero component.

Traditionally, the word skipping has been split into a separate variable of skipping probability, and the conditional reading time into another variable, and these are then modeled separately. Would be cool to include them in the same model.

Any ideas of how this could be done would be very welcome!

---

<div class="post-metadata">

### Author: ![aakhmetz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/aakhmetz/32/18672_2.png) [@aakhmetz](https://discourse.mc-stan.org/u/aakhmetz)
#### Post date: [June 15, 2024, 8:25am UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496/5 "2024-06-15T08:25:38Z")

</div>

Why not to use the hurdle mixture model then? I think it would be equivalent,

---

<div class="post-metadata">

### Author: ![Christopher-Peterson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/christopher-peterson/32/13_2.png) [@Christopher-Peterson](https://discourse.mc-stan.org/u/Christopher-Peterson)
#### Post date: [June 16, 2024, 3:20am UTC](https://discourse.mc-stan.org/t/combining-a-hurdle-lognormal-with-lognormal-in-a-mixture-model/35496/6 "2024-06-16T03:20:37Z")

</div>

I agree that a mixture of two hurdle-lognormal models should work. Are you fitting any predictors to the zero component? If not, you can use `set_prior()` to constrain the second hurdle parameter to be equal to the first (using the `constant()` prior); this should should make the results mathematically equivalent to what you want.  
If you are fitting predictors to your prior, you _should_ still be able to use a constant constraint, but I don’t remember the details of how to do it; in any case, a bit of experimentation should reveal the right syntax.
