[R-sig-ME] afex in missing data (when testing main effects in presence of interactions in factorial designs)

Thomas Deimel t.deimel at yahoo.de
Sun Jun 4 15:41:41 CEST 2017

Hi everyone,

I am using lmer (or mixed() from the afex package) to implement a linear mixed model of the form 

y~1+x1+x2+x1:x2+(by-subject random effects),

where x1 and x2 are both categorical variables/factors. The design is balanced but there are missing values for some x2 levels in some of the subjects.

I am interested in testing the main effect of say x1 in the presence of the interaction term x1:x2. In order to achieve this, I convert x2 to a numeric variable using sum contrasts - as summarized for example [here][1]. This gives the same results for inference (nearly identical p-values) as using mixed() from the afex package. This corresponds to a "type III test".

The linked summary, however, mentions that the main effect we test essentially corresponds to the effect of x1 averaged over all levels of x2 (which I assume corresponds to x2=0 when converted to numeric and using true contrasts). But, there are missing data for y for some of the levels of x2 in some of the subjects, so how does this affect the averaging.

My Qs: Given the above implementation of the model,...

1) ...do missing values lead to putting a stronger weight on x2 levels that do not have missing values when averaging over x2 levels to calculate the main effect of x1? OR is R aware of that distortion and calculates a weighted average of some sort (I don't see how)?

2) ...is this a problem? I assume it could lead to distorted estimation of main effect significance in smaller data sets or if there are a lot of missing values for certain levels of x2?

3) ...is there a way around it, like forcing R to weighting the average? Or would it be advisable to compare y~x2 to y~x1+x2, instead? I would certainly be inclined to use this if the interaction was insignificant (agreed?) but what if it is significant? Any other options?

Thanks for the help,


  [1]: https://arxiv.org/pdf/1405.2094.pdf "here"
	[[alternative HTML version deleted]]

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