Thanks to Rijmen et al.(2003), we can fit GRM to the data with lme4::glmer
.
I think Rasch model is straightforward, with data.frame
with columns like this
response person item
0 1 1
0 1 2
1 1 3
...
1 2 1
0 2 2
we can fit Rasch model like this
glmer(response ~ -1 + item + (1|person), data= , family="binomial")
But how about GRM? The data would be like this
response person item
2 1 1
4 1 2
3 1 3
...
1 2 1
4 2 2
...
For a Likert scale (1 to 5). I thought converting the data like this
response person item category
1 1 1 2
0 1 1 3
1 1 2 4
0 1 2 5
Because for person1
, item1
, the response is 2, which means that for response 2, it's yes and for response 3, it's no.
The model would be
response ~ item:category + (1|person)
But I am not quite sure this is the right way to do…
Note: person, item, category variables are all factors
According to De Boeck et al. (2011), GRM cannot be fitted with lmer
which is rather in contrast to Rijmen et al(2003).
=== ADDED
Now I think I am pretty sure it will work, at least for GRM with no slope parameter.
Data should be coded like this.
response person item category
0 1 1 1
1 1 1 2
1 1 1 3
1 1 1 4
1 1 1 5 (which is always true so should be omitted.)
for 1-5 category(ordinal) answer.
Main benefit of using GLMM for IRT model is you can put other covariates
(person, item, person-item) into the model.
And for GRM, you can set the difference between the ordinal response is the same,
which can't be handled by ordinary GRM function, for example, ltm::grm.
(Oh, I see ordinal::clmm can handle this, but I doubt it can be useful for a model like this)
response ~ item + (1 + category|person)
or this
response ~ item + (-1 + category|item) + (1|person)
in this case, category is integer and would be better if coded as -2, -1, 0, 1, 2.
References
Rijmen, F., Tuerlinckx, F., De Boeck, P., & Kuppens, P. (2003). A nonlinear mixed model framework for item response theory. Psychological methods, 8(2), 185.
De Boeck, P., Bakker, M., Zwitser, R., Nivard, M., Hofman, A., Tuerlinckx, F., & Partchev, I. (2011). The estimation of item response models with the lmer function from the lme4 package in R. Journal of Statistical Software, 39(12), 1-28.
====
Here's my source.
library(ltm)
#Science[c(1,3,4,7)]
Sci.df <- Science[c(1,3,4,7)] # Comfort, Work, Future, Benefit
Sci.df$id = 1:nrow(Sci.df)
Sci.long <- reshape(Sci.df, varying=colnames(Sci.df[-5]),
v.names="Response", timevar="item", idvar=c("id"), direction="long")
Sci.long$id <- as.factor(Sci.long$id)
Sci.long$item <- as.factor(Sci.long$item)
library(ordinal)
Sci.long.clmm <- clmm(Response ~ (1|id)+item, data=Sci.long, threshold="flexible", nAGQ=-21)
summary(Sci.long.clmm)
Positive1=as.integer(Sci.long$Response)<=1
Positive2=as.integer(Sci.long$Response)<=2
Positive3=as.integer(Sci.long$Response)<=3
Sci.long.sep1=Sci.long
Sci.long.sep1$Response=1; Sci.long.sep1$Positive=Positive1
Sci.long.sep2=Sci.long
Sci.long.sep2$Response=2; Sci.long.sep2$Positive=Positive2
Sci.long.sep3=Sci.long
Sci.long.sep3$Response=3; Sci.long.sep3$Positive=Positive3
Sci.long.sep = rbind(Sci.long.sep1, Sci.long.sep2, Sci.long.sep3)
Sci.long.sep$Response=as.factor(Sci.long.sep$Response)
Sci.long.sep.glmm <- glmer(Positive ~ -1 + Response + item + (1|id), data=Sci.long.sep, family=binomial,
nAGQ=21, control=glmerControl(optimizer="optimx",
optCtrl=list(method="nlminb"), check.conv.grad= .makeCC("warning", tol = 1e-4, relTol = NULL) ))
summary(Sci.long.sep.glmm)
I tried my best to make it same for clmm and glmer… but the log likelihood is different.
logLik = -1730.6 for glmer
logLik = -1633.5 for clmm
and the parameters r not the same but similar.
Does anyone know why the log likehoods are different?
Best Answer
For anyone who might be curious about the same thing, clmm can fit GRM with slope 1... but I don't think clmm can allow different slopes for different items.
Here's the code.
So the results are identical, one thing to give heed to is that mixed model allows free random effect variance, but IRT model assumes variance of theta = 1.
And one way to use glmer to fit GRM is mention as "An approximate ML estimation method for CLMs" in https://cran.r-project.org/web/packages/ordinal/vignettes/clm_intro.pdf