# Gaussian Mixture Modeling/LPA in Stan?

Hello all,
I’m a graduate student hoping to use Bayesian latent profile analysis (aka, Gaussian mixture modeling) in my dissertation project. Does anyone know of examples where this kind of model has been fit using Stan? Any leads appreciated - thank you!

Sections 5, 7, & 9 of the Stan User Guide should be pertinent.

For continuous indicators, you can do this with brms. Here is a simple example with 2 variables

``````
library(lavaan)
library(brms)

dat <- HolzingerSwineford1939

mix <- mixture(gaussian, gaussian)
prior <- c(
prior(normal(0, 7), class=Intercept, resp=x1, dpar = mu1),
prior(normal(5, 7), class=Intercept, resp=x1, dpar = mu2),
prior(normal(0, 7), class=Intercept, resp=x2, dpar = mu1),
prior(normal(5, 7), class=Intercept, resp=x2, dpar = mu2)
)

get_prior(bf(x1 ~ 1)+bf(x2 ~ 1), dat, family = mix, prior=prior)

fit1 <- brm(bf(x1 ~ 1)+bf(x2 ~ 1), dat, family = mix,
prior = prior, chains = 2)
summary(fit1)
pp_check(fit1, resp = "x1")
pp_check(fit1, resp = "x2")
``````

In this case it defines the mixture by differences on the intercepts

Hope this helps