[R-sig-ME] Multi-level Rasch Model Per Douglas Bates' paper
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Wed May 13 19:32:37 CEST 2020
Apologies for not looking this over in great detail, but not sure
why you're mixing lme4 and glmmTMB here?? Isn't item easiness just
lme4::coef(fm2)$item ?
easiness <-
lme4::ranef(fm2)$item[[1]] +
glmmTMB::fixef(fm2)[imap$itype])
On 5/13/20 1:25 PM, Rasmus Liland wrote:
> On 2020-05-13 18:50 +0200, Rasmus Liland wrote:
>> Indeed it does work now! Thanks!
> Right, so this code reproduces code until the
> easiness variable on page 15. Perhaps this
> is useful?
>
> data("lq2002", package="multilevel")
> wrk <- lq2002
> # wrk[1:5,]
> for (i in 3:16) wrk[[i]] <- ordered(wrk[[i]])
> for (i in 17:21) wrk[[i]] <- ordered(5 - wrk[[i]])
> lql <- reshape(wrk,
> varying = list(names(lq2002)[3:21]),
> v.names = "fivelev",
> idvar = "subj",
> timevar = "item",
> drop = names(lq2002)[c(2, 22:27)],
> direction = "long")
> lql$itype <-
> with(lql, factor(ifelse(item < 12, "Leadership",
> ifelse(item < 15, "Task Sig.", "Hostility")
> )))
> for (i in c(1, 2, 4, 5)) lql[[i]] <- factor(lql[[i]])
> lql$dichot <- factor(ifelse(lql$fivelev < 4, 0, 1))
> # str(lql)
> # summary(lql)
>
> ## 3.2 Fitting an initial multilevel Rasch model
> (fm1 <- lme4::glmer(
> dichot ~ 0 + itype + (1 | subj) +
> (1 | COMPID) +
> (1 | item),
> lql,
> binomial))
> rr <- lme4::ranef(fm1, condVar = TRUE)
> str(rr$COMPID)
> head(rr$COMPID)
>
> qq <- lattice::qqmath(rr)
> print(qq$subj)
>
> ## 3.3 Allowing for interactions of company and item type
> (fm2 <- lme4::glmer(
> dichot ~ 0 + itype + (1 | subj) +
> (0 + itype | COMPID) +
> (1 | item),
> lql,
> binomial))
>
> (fm3 <- lme4::glmer(
> dichot ~ 0 + itype + (1 | subj) +
> (1 | COMPID:itype) +
> (1 | item),
> lql,
> binomial))
>
> (fm3a <- lme4::glmer(
> dichot ~ 0 + itype + (1 | subj) +
> (1 | COMPID:itype) +
> (1 | COMPID) +
> (1 | item),
> lql,
> binomial))
>
> anova(fm3, fm3a, fm2)
>
> str(imap <- unique(lql[, c("itype", "item")]))
>
> (easiness <-
> lme4::ranef(fm2)$item[[1]] +
> glmmTMB::fixef(fm2)[imap$itype])
>
> Best,
> Rasmus
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list