I am able to set response-specific sd and sigma priors for a multivariate model, but only if the name of the response column does not contain an underscore.
I first encountered this working with data I can’t share, but here’s a replicable example:
library(brms)
options(brms.backend = "cmdstanr")
options(mc.cores = parallel::detectCores())
n <- 200
fake_data <- tibble::tibble(
case_id = seq_along(1:n),
cohort = rep(c("valley", "mountain", "ocean", "plains"), each = 50),
x1 = rnorm(n, 0, 1),
x2 = rnorm(n, 0, 2),
y1 = rnorm(n, 0, 1),
y2 = rnorm(n, 0, 2),
# two identical y3 responses, but with different names
y3 = rnorm(n, 0, 3),
y_3 = y3
)
# First model works
fit1 <- brms::brm(
mvbind(y1, y2, y3) ~ (1 | cohort) + x1 + x2,
data = fake_data, chains = 4, cores = 4,
prior = c(
prior(normal(15, 20), class = Intercept),
prior(normal(0, 10), class = b),
prior(exponential(.1), class = sd, resp = "y3"),
prior(lkj(2), class = rescor))
)
# Second model throws error, but all that has changed is using y_3 instead of y.
fit2 <- brms::brm(
mvbind(y1, y2, y_3) ~ (1 | cohort) + x1 + x2,
data = fake_data, chains = 4, cores = 4,
prior = c(
prior(normal(15, 20), class = Intercept),
prior(normal(0, 10), class = b),
prior(exponential(1), class = sd, resp = "y_3"),
prior(lkj(2), class = rescor))
)
The second model throws the following error:
Error: The following priors do not correspond to any model parameter: sd_y_3 ~ exponential(1)
Not a big deal obviously because I can just rename my columns, but sent me into a confusion spiral for over an hour, so maybe worth flagging for others. Also possibly I’m being silly/missing something, so apologies in advance if that is the case.
- Operating System: Windows 10
- brms Version: 2.16.3