I just started out with brms to tackle a multinomial mixed-effects model. The response variable can take one of three levels, there is one categorical fixed predictor and one categorical random intercept. I want to test the difference between response levels under different predictor values. I can do so after using fitted()
on the response scale, but am wondering about using hypothesis()
on either the model itself or the predictor-scale fitted values…
m1 <- brm(Levels123 ~ Factor1 + (1|ID), data = df, family="categorical", ...)
newdata <- expand.grid(Factor1 = unique(data$Factor1), ID = unique(data$Factor1))
pp <- fitted(m1, newdata = newdata, re_formula = NULL, scale = "response")
For the first Factor1 level:
k <- 1
temp.hypothesis <- data.frame(Level1 = pp[,,1][,k], Level2 = pp[,,2][,k], Level3 = pp[,,3][,k])
hypothesis(temp.hypothesis, c("Level1 - Level3 = 0", "Level2 - Level3 = 0"))
This works fine and I get predictions and uncertainty. However, when I try scale = “linear”, I get an error - Error in get_dpar(draws, dpar = "mu", ilink = FALSE) : !is.null(x) is not TRUE
. And I can’t figure out how to run hypothesis(m1)
while specifying Level123 values of interest.
OS: Windows 7 Enterprise, R 3.5.0, brms Version: 2.3.1