Overview
I want to access the intercepts and coefficients for each level in a multilevel ordinal response model using the ordinal::clmm
function in R
.
I can easily do this with multilevel linear models estimated using lme4::lmer
and calling the coef
function. I can't seem to figure out how to do so with the ordinal model.
Example
Replication dataset
Below is a randomly-generated replication dataset. I create an independent variable ("indv"), a dependent variable ("depv") and an ordinal version of the dependent variable ("depv2") as well as some levels ("level").
test <- data.frame(depv = sample(1:4, 250, replace = TRUE),
indv = runif(250),
level = sample(1:4, 250, replace = TRUE)) %>%
mutate(depv2 = factor(depv, levels = 1:4, labels = c("bad", "okay", "good", "great")),
level = factor(level, levels = 1:4, labels = c("USA", "France", "China", "Brazil")))
Running the models
First, I estimate the linear model:
test1 <- lmer(depv ~ indv + (1 + indv | level), data = test)
Now, I estimate the ordinal response model:
test2 <- clmm(depv2 ~ indv + (1 + indv | level), data = test)
How to access the level coefficients?
I can easily access the level intercepts and coefficients for the linear model:
> coef(test1)
$level
(Intercept) indv
USA 2.239171 0.6238428
France 2.766888 -0.4173206
China 1.910860 1.2715852
Brazil 2.839156 -0.5599012
Doing this on the ordinal response model does not produce the same result:
> coef(test2)
bad|okay okay|good good|great indv
-1.13105544 0.09101709 1.32240904 0.37157688