Mixture model in brms with known mixture locations

Here is a plot of some data I’ve simulated:

It is a poisson distribution with rate parameter 7, and inflated counts at 7, 14, and 21 (similar to a zero inflated poisson, or a zero one inflated beta).

With brms, I’d like to model:

a) rate parameter of the poisson, and
b) the mixture proportions of this data

My question is: how do I specify the family when the mixture locations are known and constant?

For reference, here is some code to simulate the data.

sim<-function(){
  
  mixture.probs  = c(0.6, 0.2, 0.15, 0.05)
  outcomes = c(7,14,21)
  mixture = sample(1:length(mixture.probs), size = 1, prob = mixture.probs)
  
  if(mixture==1){
    return(rpois(1,7))
  }
  else{
    return(outcomes[mixture-1])
  }
}

samples = unlist(purrr::rerun(100000,sim()) )
  • Operating System: OSX
  • brms Version: version 2.9.0

I think you will need to write your own response distribution with parameters for rate and 4-simplex for the mixture components. Some math and insight about the internals of both brms and Stan in general will be required, the vignette at
https://cran.r-project.org/web/packages/brms/vignettes/brms_customfamilies.html should get you started. Hope that helps.

1 Like

Ah, maybe it would be easier to just write in Stan then. Thanks!