Message-ID: <1501915270.11496.2.camel@mpi.nl>
Date: 2017-08-05T06:41:11Z
From: Alday, Phillip
Subject: Residuals look "mirrored" when using lmer with imputed data
In-Reply-To: <20170804085209.Horde.HEi79TkP3mTQ_uSGcFb1Hsb@webmail.uni-tuebingen.de>
You're fitting a normal/Gaussian LMM to data bounded on [0, 1]. The
model assumptions about the residuals simply won't hold for bounded,
binomial-like values.?
Why not fit a binomial model to the data and then use fitted(model) to
compute AUC of the entire model??
Phillip ?
On Fri, 2017-08-04 at 08:52 +0200, Jo?o C P Santiago wrote:
> 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:
>
> library(dplyr)
> library(lme4)
> library(mice)
> library(zoo)
>
> ## 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
> qqnorm(resid(fit))
>
>
>
> 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?
>
> Best
> Santiago
>
>
>
>