- Operating System: Windows 10
- brms Version: 2.13.0
I have a multivariate mixed effects logistic regression model that includes monotonic effects for several six-category ordinal predictors. This model converges well and looks fine.
# Good
fit <- brm(
formula =
mvbind(y1, y2, y3) ~
1 + Gender + mo(x1) + mo(x2) + mo(x3) + mo(x4) +
(1 + mo(x1) + mo(x2) + mo(x3) + mo(x4) | Subject),
prior = c(
set_prior("lkj(1)", class = "cor"),
set_prior("student_t(3, 0, 1)", class = "Intercept", resp = "y1"),
set_prior("student_t(3, 0, 1)", class = "Intercept", resp = "y2"),
set_prior("student_t(3, 0, 1)", class = "Intercept", resp = "y3"),
set_prior("normal(0, 1)", class = "b", resp = "y1"),
set_prior("normal(0, 1)", class = "b", resp = "y2"),
set_prior("normal(0, 1)", class = "b", resp = "y3"),
set_prior("student_t(3, 0, 2.5)", class = "sd", resp = "y1"),
set_prior("student_t(3, 0, 2.5)", class = "sd", resp = "y2"),
set_prior("student_t(3, 0, 2.5)", class = "sd", resp = "y3"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox11", resp = "y1"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox21", resp = "y1"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox31", resp = "y1"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox41", resp = "y1"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox11", resp = "y2"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox21", resp = "y2"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox31", resp = "y2"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox41", resp = "y2"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox11", resp = "y3"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox21", resp = "y3"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox31", resp = "y3"),
set_prior("dirichlet(1, 1, 1, 1, 1)", class = "simo", coef = "mox41", resp = "y3")
),
family = bernoulli,
data = dat,
chains = 8,
cores = 8
)
However, I want to compare this model to one in which the monotonic assumption is relaxed (via loo_compare()
). So I rescaled the variables to be unordered factors and reestimated the model without monotonic effects.
# Error
dat_cat <- dat %>%
mutate_at(vars(x1, x2, x3, x4), factor, ordered = FALSE)
fit_cat <- brm(
formula =
mvbind(y1, y2, y3) ~
1 + Gender + x1 + x2 + x3 + x4 +
(1 + x1 + x2 + x3 + x4 | Subject),
prior = c(
set_prior("lkj(1)", class = "cor"),
set_prior("student_t(3, 0, 1)", class = "Intercept", resp = "y1"),
set_prior("student_t(3, 0, 1)", class = "Intercept", resp = "y2"),
set_prior("student_t(3, 0, 1)", class = "Intercept", resp = "y3"),
set_prior("normal(0, 1)", class = "b", resp = "y1"),
set_prior("normal(0, 1)", class = "b", resp = "y2"),
set_prior("normal(0, 1)", class = "b", resp = "y3"),
set_prior("student_t(3, 0, 2.5)", class = "sd", resp = "y1"),
set_prior("student_t(3, 0, 2.5)", class = "sd", resp = "y2"),
set_prior("student_t(3, 0, 2.5)", class = "sd", resp = "y3")
),
family = bernoulli,
data = dat_cat,
chains = 8,
cores = 8
)
However, this model returns the following error:
Exception: validate transformed params: y is not positive definite.
Does this have to do with the sparsity of some categories, or did I mess up my priors somehow?
Thanks in advance for any advice.