The residuals
, rstandard
, and rstudent
functions compute residuals, corresponding standard errors, and standardized residuals for models fitted with the rma.uni
, rma.mh
, rma.peto
, and rma.mv
functions.
# S3 method for rma
residuals(object, type="response", …)# S3 method for rma.uni
rstandard(model, digits, type="marginal", …)
# S3 method for rma.mh
rstandard(model, digits, …)
# S3 method for rma.peto
rstandard(model, digits, …)
# S3 method for rma.mv
rstandard(model, digits, cluster, …)
# S3 method for rma.uni
rstudent(model, digits, progbar=FALSE, …)
# S3 method for rma.mh
rstudent(model, digits, progbar=FALSE, …)
# S3 method for rma.peto
rstudent(model, digits, progbar=FALSE, …)
# S3 method for rma.mv
rstudent(model, digits, progbar=FALSE, cluster,
reestimate=TRUE, parallel="no", ncpus=1, cl=NULL, …)
an object of class "rma"
(for residuals
).
the type of residuals which should be returned. For residuals
, the alternatives are: "response"
(default), "rstandard"
, "rstudent"
, and "pearson"
. For rstandard.rma.uni
, the alternatives are: "marginal"
(default) and "conditional"
. See ‘Details’.
an object of class "rma"
(for residuals
) or an object of class "rma.uni"
, "rma.mh"
, "rma.peto"
, or "rma.mv"
(for rstandard
and rstudent
).
optional vector to specify a clustering variable to use for computing cluster-level multivariate standardized residuals (only for "rma.mv"
objects).
logical to specify whether variance/correlation components should be re-estimated after deletion of the ith case when computing externally standardized residuals for "rma.mv"
objects (the default is TRUE
).
character string to specify whether parallel processing should be used (the default is "no"
). For parallel processing, set to either "snow"
or "multicore"
. See ‘Details’.
integer to specify the number of processes to use in the parallel processing.
optional cluster to use if parallel="snow"
. If not supplied, a cluster on the local machine is created for the duration of the call.
integer to specify the number of decimal places to which the printed results should be rounded. If unspecified, the default is to take the value from the object.
logical to specify whether a progress bar should be shown (only for rstudent
) (the default is FALSE
).
other arguments.
Either a vector with the residuals of the requested type (for residuals
) or an object of class "list.rma"
, which is a list containing the following components:
observed residuals (for rstandard
) or deleted residuals (for rstudent
).
corresponding standard errors.
standardized residuals (internally standardized for rstandard
or externally standardized for rstudent
).
When a clustering variable is specified for "rma.mv" objects, the returned object is a list with the first element (named obs) as described above and a second element (named cluster of class "list.rma" with:
cluster-level multivariate standardized residuals.
number of observed effect sizes or outcomes within the clusters.
The object is formatted and printed with print.list.rma.
The observed residuals (obtained with residuals
) are simply equal to the ‘observed - fitted’ values. These can be obtained with residuals(object)
(using the default type="response"
).
Dividing the observed residuals by the model-implied standard errors of the observed effect sizes or outcomes yields Pearson (or semi-standardized) residuals. These can be obtained with residuals(object, type="pearson")
.
Dividing the observed residuals by their corresponding standard errors yields (internally) standardized residuals. These can be obtained with rstandard(model)
or residuals(object, type="rstandard")
.
With rstudent(model)
(or residuals(object, type="rstudent")
), one can obtain the externally standardized residuals (also called standardized deleted residuals or (externally) studentized residuals). The externally standardized residual for the ith case is obtained by deleting the ith case from the dataset, fitting the model based on the remaining cases, calculating the predicted value for the ith case based on the fitted model, taking the difference between the observed and the predicted value for the ith case (which yields the deleted residual), and then standardizing the deleted residual based on its standard error.
If a particular case fits the model, its standardized residual follows (asymptotically) a standard normal distribution. A large standardized residual for a case therefore may suggest that the case does not fit the assumed model (i.e., it may be an outlier).
For "rma.uni"
objects, rstandard(model, type="conditional")
computes conditional residuals, which are the deviations of the observed effect sizes or outcomes from the best linear unbiased predictions (BLUPs) of the study-specific true effect sizes or outcomes (see blup.rma.uni
).
For "rma.mv"
objects, one can specify a clustering variable (via the cluster
argument). If specified, rstandard(model)
and rstudent(model)
also compute cluster-level multivariate (internally or externally) standardized residuals. If all outcomes within a cluster fit the model, then the multivariate standardized residual for the cluster follows (asymptotically) a chi-square distribution with k_i degrees of freedom (where k_i denotes the number of outcomes within the cluster).
See also influence.rma.uni
and influence.rma.mv
for other leave-one-out diagnostics that are useful for detecting influential cases in models fitted with the rma.uni
and rma.mv
functions.
Hedges, L. V., & Olkin, I. (1985). Statistical methods for meta-analysis. San Diego, CA: Academic Press.
Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1--48. https://doi.org/10.18637/jss.v036.i03
Viechtbauer, W., & Cheung, M. W.-L. (2010). Outlier and influence diagnostics for meta-analysis. Research Synthesis Methods, 1(2), 112--125. https://doi.org/10.1002/jrsm.11
rma.uni
, rma.mh
, rma.peto
, rma.glmm
, rma.mv
, influence.rma.uni
, influence.rma.mv
# NOT RUN {
### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
### fit random-effects model
res <- rma(yi, vi, data=dat)
### compute the studentized residuals
rstudent(res)
### fit mixed-effects model with absolute latitude as moderator
res <- rma(yi, vi, mods = ~ ablat, data=dat)
### compute the studentized residuals
rstudent(res)
# }
Run the code above in your browser using DataCamp Workspace