Discussion:
[R-sig-ME] [FORGED] Types of residuals in lme4
Rolf Turner
2018-07-06 00:40:03 UTC
Permalink
Dear All,
test = lmer(continuousOutcome ~ age + sex + (1|DBID) + (1|familyID), data, na.action = na.exclude)
I’ve tried extracting all of the following types of residuals, but the only differences I observe between these approaches are due to scaling; i.e., residuals do not differ by residual type.
resids = as.data.table(residuals(test,type = "pearson", scaled = TRUE))
resids = as.data.table(residuals(test,type = "working", scaled = TRUE))
resids = as.data.table(residuals(test,type = "response", scaled = TRUE))
resids = as.data.table(residuals(test,type = "deviance", scaled = TRUE))
resids = as.data.table(residuals(test,type = "pearson"))
resids = as.data.table(residuals(test,type = "working"))
resids = as.data.table(residuals(test,type = "response"))
resids = as.data.table(residuals(test,type = "deviance"))
Is this an expected result when using lme4 to obtain residuals from mixed models? I want to ensure that the residuals I am obtaining are observation level (which they appear to be) and that they account for the two random intercepts (which I believe they do, since they differ if I exclude one of the random intercepts). Also, is it possible to get higher level residuals from lme4, such as individual or family level residuals (which are the two random intercepts included in my model)?
I would greatly appreciate any help!
I am no expert --- and younger and wiser heads may correct me --- but it
is my understanding that "types" of residuals are relevant only in the
context of *generalised* linear models (mixed or "straight"). For
linear models (mixed or "straight") a residual is a residual is a
residual. (And a caterpillar is a tractor. :-) )

cheers,

Rolf Turner
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
James Uanhoro
2018-07-06 01:39:50 UTC
Permalink
In addition to Rolf Turner's point, you can get the random effects using
the ranef() function.

ranef(test)$DBID and ranef(test)$familyID should do it.

James
Post by Rolf Turner
Dear All,
I am using lme4 to get residuals from a model that has two random
test = lmer(continuousOutcome ~ age + sex + (1|DBID) + (1|familyID),
data, na.action = na.exclude)
I’ve tried extracting all of the following types of residuals, but
the only differences I observe between these approaches are due to
scaling; i.e., residuals do not differ by residual type.
resids = as.data.table(residuals(test,type = "pearson", scaled = TRUE))
resids = as.data.table(residuals(test,type = "working", scaled = TRUE))
resids = as.data.table(residuals(test,type = "response", scaled = TRUE))
resids = as.data.table(residuals(test,type = "deviance", scaled = TRUE))
resids = as.data.table(residuals(test,type = "pearson"))
resids = as.data.table(residuals(test,type = "working"))
resids = as.data.table(residuals(test,type = "response"))
resids = as.data.table(residuals(test,type = "deviance"))
Is this an expected result when using lme4 to obtain residuals from
mixed models? I want to ensure that the residuals I am obtaining are
observation level (which they appear to be) and that they account for
the two random intercepts (which I believe they do, since they differ
if I exclude one of the random intercepts). Also, is it possible to
get higher level residuals from lme4, such as individual or family
level residuals (which are the two random intercepts included in my
model)?
I would greatly appreciate any help!
I am no expert --- and younger and wiser heads may correct me --- but
it is my understanding that "types" of residuals are relevant only in
the context of *generalised* linear models (mixed or "straight").  For
linear models (mixed or "straight") a residual is a residual is a
residual.  (And a caterpillar is a tractor. :-) )
cheers,
Rolf Turner
Loading...