Is it possible to use the non-linear syntax to fit a multinomial model? Here’s an example of a simple intercepts-only model for a 3-category response variable that works fine with conventional brms syntax.
library(brms)
dat <- data.frame(y = rep(letters[1:3], times = 100))
fit_1 <-
brm(data = dat,
family = categorical(link = logit),
y ~ 1,
prior = c(prior(normal(0, 1), class = Intercept, dpar = mub),
prior(normal(0, 1), class = Intercept, dpar = muc)))
I’d like to fit to fit the same model using the nonlinear syntax. My first naïve attempt is incorrect in that it returns a single intercept.
fit_2 <-
brm(data = dat,
family = categorical(link = logit),
bf(y ~ a,
a ~ 1,
nl = TRUE),
prior(normal(0, 1), class = b, nlpar = a))
My second naïve attempt is rejected by brms out of hand.
fit_3 <-
brm(data = dat,
family = categorical(link = logit),
bf(y ~ a,
a ~ 1,
nl = TRUE),
prior = c(prior(normal(0, 1), class = b, dpar = mub, nlpar = a),
prior(normal(0, 1), class = b, dpar = muc, nlpar = a)))
All I get from this is an error:
Error: The following priors do not correspond to any model parameter:
b_mub_a ~ normal(0, 1)
b_muc_a ~ normal(0, 1)
Function 'get_prior' might be helpful to you.
Is there a way to mix the nonlinear syntax with family = categorical
?