any idea how i can reproduce multinomial logit model such as vglm() in Rstan or in rstanarm(no random effects).From my web search i only found ordinal regression.
It isn’t in rstanarm. Writing a Stan program to do it is not that hard once you pick the form of the likelihood you want to use (and priors).
For me is very difficult.I am not a computer scientist.Thanks a lot for your reply.I appreciate that.
You can do multinomial regression with
brms. There’s an example thread here; searching the boards for “brms multinomial” will turn up more examples.
thanks but when i run the code in the example page in R i take an error:Error: Argument ‘family’ is invalid. for multinomial()
syntax error is family = “multinomial”.Thanks
It would help to see
- the code you actually ran, and
- the exact error message.
You should copy-and-paste these in your posts, rather than just presenting an ambiguous or possibly misleading summary.
race = gl(2,2,labels = c("white","black"));race gender = gl(2,1,labels = c("female","male"));gender y1 = c(371,250,64,25) y2 = c(49,45,9,5) y3 = c(74,71,15,13) afterlife = data.frame(race,gender,y1,y2,y3) afterlife afterlife$size = with(afterlife, y1 + y2 + y3) afterlife$y = with(afterlife, cbind(y1, y2, y3)) prior <- prior(normal(0, 10), "b", dpar = muy2) + prior(cauchy(0, 1), "Intercept") + prior(normal(0, 2), "Intercept", dpar = muy3) fit <- brm(bf(y | trials(size) ~ 1, muy2 ~ race+gender), data = afterlife, family = "multinomial", prior = prior) print(fit) plot(fit) predict(fit)
But the output that i get its completely different.In brm
y | trials(size) ~ 1
what does it mean?that the first category is the reference?
race = gl(2,2,labels = c("white","black"));race gender = gl(2,1,labels = c("female","male"));gender y1 = c(371,250,64,25) y2 = c(49,45,9,5) y3 = c(74,71,15,13) afterlife = data.frame(race,gender,y1,y2,y3) fit2 <- vglm(cbind(y1,y2,y3) ~ gender + race, family=multinomial, data=afterlife) summary(fit2)
what the right modelling for these data?