3
$\begingroup$

I have a data set with 20 users who were exposed to three levels and two variants (except the low level was only exposed to one variant). There are two measurements for each combination. Below are example data for one user:

enter image description here

I know the two measurements are correlated for the same user, level and variant (not in this example data) so I'm imposing an AR1 structure. Below is the lme model and estimation of interactions I'm interested in using the emmeans package.

enter image description here

enter image description here

Two questions:

  1. Am I specifying the correlation structure correctly given I expect scores within user, level, and variant to be correlated?
  2. How does the emmeans function produce an estimate for level = low and variant = B when that combination is not even in the data.

Full code for reproducibility:

library(tidyverse)
library(nlme)
library(emmeans)

NUM_USERS=20
save_list=list()

for(i in 1:NUM_USERS){
  
  user=paste0("ID_",i)
  save_list[[i]]=tibble(user,level=c(rep("high",4),rep('med',4),rep("low",2)),
                         variant=c(rep(c("A","B"),times=2,each=2),"A","A"),
             score_num=rep(c("one","two"),5),score=rnorm(10,20,5))
  
}

a1 = bind_rows(save_list) 

fit=lme(score~score_num*level+variant*score_num,random=~1|user,
         correlation=corAR1(form=~1|user/level/variant),data=a1)

emmeans(fit,pairwise~score_num|variant*level)
$\endgroup$

1 Answer 1

2
$\begingroup$

The answer to your second question is that those two factors do not interact in your model. Therefore the effects of those two factors are additive, meaning that we are assuming that the interaction effect between them is equal to zero. if your model had included the interaction between variant and level, then that missing combination would not have been estimable. Try it and see!

$\endgroup$
2
  • $\begingroup$ @RussThanks. I cannot estimate the model (Singularity) when I include the variant and level interaction and that make sense. However, I don't understand how I can get an estimate for the score one - two in level = low and variant = B. $\endgroup$
    – Glen
    Nov 5, 2021 at 11:44
  • $\begingroup$ The estimate for each factor combination is the overall mean plus the marginal effect for one factor plus the marginal effect of the other factor. You can estimate those marginal effects even when there are a few holes in the data. It's related to a method you could find in an old, old experimental design book for imputing a missing observation in a block experiment. $\endgroup$
    – Russ Lenth
    Nov 5, 2021 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.