[R-sig-ME] [External] Post hoc on glmer for specific hypotheses

Lenth, Russell V ru@@e||-|enth @end|ng |rom u|ow@@edu
Wed Mar 9 20:37:52 CET 2022

This would be straightforward using the emmeans package. Just do:

        EMM <- emmeans(m2, ~ item_type * time)
        EMM   # to list the estimates

Then, note the order of those four estimates, and set up the desired contrasts manually:

        CON <- list(c1 = c(...), c2 = c(...))
        contrast(EMM, CON)

where c1 and c2 consist of contrast coefficients of 1 and -1 corresponding to the stated contrasts.

I suppose it is possible to do this via some clever choice of contrast codings for the model such that the needed ones are estimated as the interaction coefficient infixef(m2). However, you would have to do it twice with two different codings, since both of the stated contrasts are interaction contrasts, and we can only estimate one such interaction per model. Generally, I think trying to estimate meaningful things via regression coefficients is overrated. Except in one-factor models, it is too easy to get things wrong.

Russ Lenth

-----Original Message-----
From: Timothy MacKenzie <fswfswt using gmail.com> 
Sent: Wednesday, March 9, 2022 11:59 AM
To: r-sig-mixed-models <r-sig-mixed-models using r-project.org>
Cc: Lenth, Russell V <russell-lenth using uiowa.edu>
Subject: [External] Post hoc on glmer for specific hypotheses

Hello All,

My glmer model below analyzes the performance of a single group of subjects on a test at two time points. The test has 4 item types.

Data and code are below.

Is there a way to test only the following two hypotheses?

1- ((Baseline multiple-choice_grammar) - (Post-test
multiple-choice_grammar)) - (Baseline production_grammar - (Post-test

2- ((Baseline multiple-choice_vocabulary) - (Post-test
multiple-choice_vocabulary)) - (Baseline production_vocabulary - (Post-test production_vocabulary))

dat <- read.csv("https://raw.githubusercontent.com/fpqq/w/main/d.csv")

form2 <- y ~ item_type*time + (1 | user_id)

m2 <- glmer(form2, family = binomial, data = dat,
            control =
              glmerControl(optimizer = "bobyqa"))

Tim M

More information about the R-sig-mixed-models mailing list