Mixture model rejecting initial value

Hello,

I’m fitting finite mixture models with a continuous outcome. After building up to it from simpler models, I’ve found that two skew-normal distributions are able to model the data. I can create a reproducible example if that’s what is required here, but I’m thinking something simpler is going on that I just don’t understand.

library(brms)

skew_skew_mixture <- mixture(skew_normal(), skew_normal(), order = TRUE)

skew_skew_prior <- c(
  prior(normal(5,5), class="alpha1"),
  prior(normal(0,1), class="alpha2"),
  prior(normal(0,1), class="sigma1"),
  prior(normal(0,1), class="sigma2"),
  prior(beta(4,4), class="theta1"),
  prior(normal(0,0.5), class="b", dpar="mu1"),
  prior(normal(-0.5, 0.25), class="Intercept", dpar="mu1"),
  prior(normal(0,1), class="sd", dpar="mu1"),
  prior(normal(0,0.5), class="b", dpar="mu2"),
  prior(normal(0.5, 0.25), class="Intercept", dpar="mu2"),
  prior(normal(0,1), class="sd", dpar="mu2"),
  prior(normal(0,0.5), class="b", dpar="theta2"),
  prior(beta(4,4), class="Intercept", dpar="theta2"),
  prior(lkj(2), class="cor")
)

model_fit <- brm(bf(y~ 
                        x+
                        (1+x|Subject) +
                        (1|Item),
                        theta2 ~
                         x+
                         (1+x|Subject) +
                         (1|Item)),
                    data = hc_clean,
                    family = skew_skew_mixture,
                    prior = skew_skew_prior,
                    cores = 4,
                    warmup = 4000,
                    iter = 6000,
                    save_pars = save_pars(all=TRUE),
                    control = list(adapt_delta=0.9999),
                    backend = "cmdstanr")

The (potential) issue I’ve been having, which I’m not sure is actually a problem, is that at the start of model fitting I get warnings like the following:

Chain 2 Rejecting initial value:
Chain 2 Error evaluating the log probability at the initial value.
Chain 2 Exception: beta_lpdf: Random variable is -0.293539, but must be in the interval [0, 1]

From what I understand from reading up on models, the priors on theta parameters in these finite mixture models are often made using a Dirichlet prior, but I should be able to use a beta because there are only two component distributions.

I understand that the beta(4,4) prior is contained to between 0 and 1, but if someone could help me understand why this error is coming up it would be greatly appreciated! Directing me to readings of chapters/papers would be awesome if it’s not a quick and easy explanation.

The initial values aren’t actually drawn from the prior - they are drawn (I believe, depending on the backend!) from N(0, 1). So this error is to be expected and shouldn’t be an issue, as rejected initial values are just tried again.

If you would like to constrain initial values, you can pass the “init” argument to the brm function. It expects a list of named lists, with a value for each parameter. But - you don’t need to do this unless this happens repeatedly and your chains fail.

An example of passing inits is in this post: Does the init argument work with cmdstanr? - #2 by jonah

1 Like

Thanks! I appreciate the help

1 Like