[R-sig-ME] Residuals look "mirrored" when using lmer with imputed data

João C P Santiago joao.santiago at uni-tuebingen.de
Fri Aug 4 08:52:09 CEST 2017

I'm trying to assess if a treatment had any effect on the levels of a  
hormone. To do this I need to calculate the area under the curve and  
then adjust it for sex (a known confounder) and smoking status (not  
included in the demo data below to keep things simpler).

Here's a dput of the data: https://pastebin.com/VYcQGkwb

There's some missing values, so first step is to impute them using the  
mice package, then calculate AUC and finally fit the model:


## Impute missing values
dfMids <- mice(df, m = 10, maxit = 15, seed = 2535)
dfImp  <- complete(dfMids)

## Calculate AUC
dfImpAUC <- dfImp %>%
   arrange(sampleNum) %>%
   group_by(ID, treatment) %>%
   mutate(AUC = sum(diff(sampleNum)*rollmean(value,2)))

## Fit model
fit <- lmer(AUC ~ sex * treatment + (1|ID), data = dfImpAUC)

## Plot residuals
plot(fit)  # output: https://imgur.com/a/vfL1R

I know it's possible to fit a model to each iteration of mids model,  
but then I can't calculate the AUC, which is what I actually need. Any  
ideas why the residuals look like that?


João C. P. Santiago
Institute for Medical Psychology & Behavioral Neurobiology
Center of Integrative Neuroscience
University of Tuebingen
Otfried-Mueller-Str. 25
72076 Tuebingen, Germany

Phone: +49 7071 29 88981
Fax: +49 7071 29 25016

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