rstudent functions compute residuals, corresponding standard errors, and standardized residuals for models fitted with the
# 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
the type of residuals which should be returned. For
an object of class
optional vector to specify a clustering variable to use for computing cluster-level multivariate standardized residuals (only for
logical to specify whether variance/correlation components should be re-estimated after deletion of the \(i\)th case when computing externally standardized residuals for
character string to specify whether parallel processing should be used (the default is
integer to specify the number of processes to use in the parallel processing.
optional cluster to use if
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
The observed residuals (obtained with
residuals) are simply equal to the ‘observed - fitted’ values. These can be obtained with
residuals(object) (using the default
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
Dividing the observed residuals by their corresponding standard errors yields (internally) standardized residuals. These can be obtained with
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 \(i\)th case is obtained by deleting the \(i\)th case from the dataset, fitting the model based on the remaining cases, calculating the predicted value for the \(i\)th case based on the fitted model, taking the difference between the observed and the predicted value for the \(i\)th 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).
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
"rma.mv" objects, one can specify a clustering variable (via the
cluster argument). If specified,
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).
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
corresponding standard errors.
standardized residuals (internally standardized for
rstandard or externally standardized for
cluster-level multivariate standardized residuals.
number of observed effect sizes or outcomes within the clusters.
Right now, the externally standardized residuals (obtained with
rstudent) are calculated by refitting the model \(k\) times (where \(k\) is the number of cases). Depending on how large \(k\) is, it may take a few moments to finish the calculations. For complex models fitted with
rma.mv, this can become computationally expensive.
On machines with multiple cores, one can usually speed things up by delegating the model fitting to separate worker processes, that is, by setting
ncpus to some value larger than 1 (only for objects of class
"rma.mv"). Parallel processing makes use of the
parallel package, using the
parLapply functions when
parallel="snow" or using
parallel="multicore" (the latter only works on Unix/Linux-alikes). With
parallel::detectCores(), one can check on the number of available cores on the local machine.
Alternatively (or in addition to using parallel processing), one can also set
reestimate=FALSE, in which case any variance/correlation components in the model are not re-estimated after deleting the \(i\)th case from the dataset. Doing so only yields an approximation to the externally standardized residuals (and the cluster-level multivariate standardized residuals) that ignores the influence of the \(i\)th case on the variance/correlation components, but is considerably faster (and often yields similar results).
It may not be possible to fit the model after deletion of the \(i\)th case from the dataset. This will result in
NA values for that case when calling
"rma.mv" objects with a clustering variable specified, it may not be possible to compute the cluster-level multivariate standardized residual for a particular cluster (if the var-cov matrix of the residuals within a cluster is not of full rank). This will result in
NA for that cluster.
For objects of class
rstandard actually computes Pearson (or semi-standardized) residuals.
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
### 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)#> #> resid se z #> 1 -0.1822 0.8354 -0.2181 #> 2 -0.9314 0.7210 -1.2918 #> 3 -0.6625 0.8778 -0.7547 #> 4 -0.8131 0.5603 -1.4512 #> 5 0.5466 0.6448 0.8477 #> 6 -0.0752 0.6376 -0.1180 #> 7 -0.9657 0.7407 -1.3037 #> 8 0.8067 0.5563 1.4501 #> 9 0.2718 0.6668 0.4076 #> 10 -0.7183 0.6369 -1.1277 #> 11 0.4185 0.6255 0.6691 #> 12 1.2057 0.9348 1.2898 #> 13 0.7602 0.6400 1.1879 #>### fit mixed-effects model with absolute latitude as moderator res <- rma(yi, vi, mods = ~ ablat, data=dat) ### compute the studentized residuals rstudent(res)#> #> resid se z #> 1 0.1488 0.6587 0.2259 #> 2 -0.2801 0.5811 -0.4819 #> 3 -0.3906 0.7177 -0.5442 #> 4 -0.2709 0.4078 -0.6644 #> 5 -0.1044 0.4489 -0.2325 #> 6 0.3183 0.3296 0.9657 #> 7 -1.4026 0.5256 -2.6687 #> 8 0.2270 0.4082 0.5560 #> 9 0.0804 0.4226 0.1903 #> 10 -0.4538 0.4002 -1.1338 #> 11 -0.0704 0.3993 -0.1764 #> 12 1.1763 0.7867 1.4954 #> 13 0.7315 0.3529 2.0730 #>