Fitting a Mixture of Von Mises and Uniform Distributions in brms

I just discovered that BRMS is capable of fitting mixture models – is there anything it can’t do?!

In my field, I sometimes analyze data as arising from the mixture of a von mises and a uniform distribution with various predictors applied to Kappa and to the mixing proportions. In the past, I’ve had to code these models in base Stan. In following along with the documentation for the mixture() function. I think I understand how it works and have been able to fit a variety of mixtures using typical distributions (e.g., Normal). However, I cannot seem to work out how to incorporate a uniform distribution (ranging from -pi to pi). Is there a simple or preset way to do this with resorting to hacks?

Apologies in advance if I am being daft…

  • Operating System: OSX 10.13.6
  • brms Version: 2.6.0
1 Like

Using customfamily you can make your own custom family for the uniform distribution. Once you done that, you can do stuff along the following lines:

bform <- bf(
  mu1 ~ <predictors>,
  mu2 ~ 0,
  family = mixtrue(von_mises(), custom_uniform)

@paul.buerkner Could you offer any tips on creating a custom family for the uniform distribution? For example, it’s unclear to me what the linking functions should be.

Also, is it possible to fix the upper and lower bound parameters of the uniform distribution and merely estimate the mixing proportion? I know the uniform will span -pi to pi. I just want to estimate the probability that the data were drawn from this uniform distribution rather than the Von Mises.

Thanks for your time.

In this case it may be easier to just make a custom family that already is a mixture itself instead of using the mixture() function of brms. The Stan manual may give you some hints on how to write down mixtures in Stan and you can then use this to make you own uniform-von-mises mixture family to be used in brms.