Thanks for the nudge, @paul.buerkner. I think I have it. For the sake of continuity, I’m going to switch to the Fishing
data used in GitHub issue #560. For anyone else following, that example was based on a conditional logistic model, which I’m not totally up on but I believe is an alternative parameterization of what I’m calling the multinomial model. Anyway, the code below fits an intercepts-only multinomial model for the 4-category response variable mode
. In this example, the reference category will be "boat"
. I’ll show how to fit the model with three styles of syntax, what I’m going to call
- the conventional syntax (
fish1a
), - the verbose syntax (
fish1b
), and - the nonlinear syntax (
fish1c
).
library(brms)
data("Fishing", package = "mlogit")
# conventional syntax
fish1a <-
brm(data = Fishing,
family = categorical(link = logit, refcat = "boat"),
mode ~ 1,
prior = c(prior(normal(0, 1), class = Intercept, dpar = mubeach),
prior(normal(0, 1), class = Intercept, dpar = mucharter),
prior(normal(0, 1), class = Intercept, dpar = mupier)))
# verbose syntax
fish1b <-
brm(data = Fishing,
family = categorical(link = logit, refcat = "boat"),
bf(mode ~ 1,
mubeach ~ 1,
mucharter ~ 1,
mupier ~ 1),
prior = c(prior(normal(0, 1), class = Intercept, dpar = mubeach),
prior(normal(0, 1), class = Intercept, dpar = mucharter),
prior(normal(0, 1), class = Intercept, dpar = mupier)))
# nonlinear syntax
fish1c <-
brm(data = Fishing,
family = categorical(link = logit, refcat = "boat"),
bf(mode ~ 1,
nlf(mubeach ~ abeach),
nlf(mucharter ~ acharter),
nlf(mupier ~ apier),
abeach + acharter + apier ~ 1),
prior = c(prior(normal(0, 1), class = b, nlpar = abeach),
prior(normal(0, 1), class = b, nlpar = acharter),
prior(normal(0, 1), class = b, nlpar = apier)))
The results are the same for all.
Estimate Est.Error Q2.5 Q97.5
mubeach_Intercept -1.13 0.10 -1.32 -0.94
mupier_Intercept -0.85 0.09 -1.02 -0.67
mucharter_Intercept 0.08 0.07 -0.05 0.21
Estimate Est.Error Q2.5 Q97.5
mubeach_Intercept -1.13 0.10 -1.32 -0.94
mupier_Intercept -0.85 0.09 -1.02 -0.67
mucharter_Intercept 0.08 0.07 -0.05 0.21
Estimate Est.Error Q2.5 Q97.5
abeach_Intercept -1.13 0.10 -1.33 -0.94
acharter_Intercept 0.08 0.07 -0.04 0.22
apier_Intercept -0.85 0.09 -1.02 -0.68