I ran this multilevel ordinal regression using clmm
from the ordinal
package
library(ordinal)
set.seed(1)
dat <- data.frame(day=rep(seq(1,10,1),times=20), product=rep(c("A","B"),each=100),id=rep(seq(1,10,1),each=10), rating=factor(round(runif(200, 1,4)),ordered=T))
fm <- clmm(rating ~ product*day + (day:product|id), data=dat)
summary(fm)
Random effects:
Groups Name Variance Std.Dev. Corr
id (Intercept) 0.0019106 0.04371
day:productA 0.0007965 0.02822 -0.580
day:productB 0.0055626 0.07458 -0.991 0.464
Number of groups: id 10
Coefficients:
Estimate Std. Error z value Pr(>|z|)
productB 0.28707 0.55624 0.516 0.606
day 0.01589 0.06492 0.245 0.807
productB:day -0.01343 0.09268 -0.145 0.885
Threshold coefficients:
Estimate Std. Error z value
1|2 -1.9412 0.4311 -4.503
2|3 0.1489 0.3947 0.377
3|4 1.8952 0.4273 4.435
I'd like to extract the slope for day
:product
for every id
in my dataset.
Because this is ordinal regression, I would do that for every level of rating
, for example, the day:productA
slope for id==1
when rating==1
.
I found a way to extract coefficients for each level in an ordinal CLMM model
coef_ordinal(fm)
$id
(Intercept) day:productA day:productB productB day productB:day
1 -0.004659666 0.0067145191 0.0056847187 0.2870686 0.01588863 -0.01342732
2 0.032079220 -0.0050521232 -0.0573035325 0.2870686 0.01588863 -0.01342732
3 0.016246292 -0.0109719382 -0.0253086809 0.2870686 0.01588863 -0.01342732
4 -0.032606795 0.0077477424 0.0570931971 0.2870686 0.01588863 -0.01342732
5 0.007568091 0.0005502529 -0.0142876818 0.2870686 0.01588863 -0.01342732
6 0.035569405 -0.0161443049 -0.0588863315 0.2870686 0.01588863 -0.01342732
7 0.018484504 -0.0064397257 -0.0314621503 0.2870686 0.01588863 -0.01342732
8 -0.044520743 0.0217841351 0.0730097460 0.2870686 0.01588863 -0.01342732
9 -0.028428558 -0.0021273246 0.0536964704 0.2870686 0.01588863 -0.01342732
10 -0.001054051 0.0043805578 0.0000232408 0.2870686 0.01588863 -0.01342732
However, I'm not sure how to combine the different values above to get specific coefficients. For example, how can I extract the slope for day:productA
when the rating==1
and id==1
?
I feel I should make use of these coefficients:
Threshold coefficients:
Estimate Std. Error z value
1|2 -1.9412 0.4311 -4.503
2|3 0.1489 0.3947 0.377
3|4 1.8952 0.4273 4.435
but coef_ordinal
does not include rating-specific intercepts for each id
, only a general (Intercept)
which I'm not sure how to interpret...