metafor (version 3.0-2)

rcalc: Calculate the Variance-Covariance of Correlation Coefficients

Description

The function can be used to calculate the variance-covariance matrix of correlation coefficients computed based on the same sample of subjects.

Usage

rcalc(x, ni, data, rtoz=FALSE, nfun="min", sparse=FALSE, …)

Arguments

x

a formula of the form ri ~ var1 + var2 | study. See ‘Details’.

ni

vector to specify the sample sizes based on which the correlations were computed.

data

data frame containing the variables specified via the formula (and the sample sizes).

rtoz

logical to specify whether to transform the correlations via Fisher's r-to-z transformation (the default is FALSE).

nfun

a character string to specify how the ‘common’ sample size within each study should be computed. Possible options are "min" (for the minimum), "harmonic" (for the harmonic mean), or "mean" (for the arithmetic mean). Can also be a function. See ‘Details’.

sparse

logical to specify whether the variance-covariance matrix should be returned as a sparse matrix (the default is FALSE).

other arguments.

Value

A list containing the following components:

dat

a data frame with the study identifier, the two variable identifiers, a variable pair identifier, the correlation coefficients (possibly transformed with Fisher's r-to-z transformation), and the (common) sample sizes.

V

corresponding variance-covariance matrix (given as a sparse matrix when sparse=TRUE).

Note that a particular covariance can only be computed when all of the correlation coefficients involved in the covariance equation are included in the dataset. If one or more coefficients needed for the computation are missing, then the resulting covariance will also be missing (i.e., NA).

Details

A meta-analysis of correlation coefficients may involve multiple correlation coefficients extracted from the same study. When these correlations are computed based on the same sample of subjects, then they are typically not independent. The rcalc function can be used to create a dataset with the correlation coefficients (possibly transformed with Fisher's r-to-z transformation) and the corresponding variance-covariance matrix. The dataset and variance-covariance matrix can then be further meta-analyzed using the rma.mv function.

When computing the covariance between two correlation coefficients, we can distinguish two cases. In the first case, one of the variables involved in the two correlation coefficients is the same. For example, in r_12 and r_13, variable 1 is common to both correlation coefficients. This is sometimes called the (partially) ‘overlapping’ case. The covariance between the two correlation coefficients, Cov[r_12, r_13]Cov[r_12, r_13], then depends on the degree of correlation between variables 2 and 3 (i.e., r_23).

In the second case, none of the variables are common to both correlation coefficients. For example, this would be the case if we have correlations r_12 and r_34 based on 4 variables. This sometimes called the ‘non-overlapping’ case. The covariance between the two correlation coefficients, Cov[r_12, r_34]Cov[r_12, r_34], then depends on r_13, r_14, r_23, and r_24.

Equations for these covariances can be found, for example, in Steiger (1980) and Olkin and Finn (1990).

To use the rcalc function, one needs to construct a data frame that contains a study identifier (say study), two variable identifiers (say var1 and var2), the corresponding correlation coefficient (say ri), and the sample size based on which the correlation coefficient was computed (say ni). Then the first argument should be a formula of the form ri ~ var1 + var2 | study, argument ni is set equal to the variable name containing the sample sizes, and the data frame containing these variables is specified via the data argument. When using the function for a single study, one can leave out the study identifier from the formula.

When argument rtoz is set to TRUE, then the correlations are transformed with Fisher's r-to-z transformation and the variance-covariance matrix is computed for the transformed values.

In some cases, the sample size may not be identical within a study (e.g., r_12 may have been computed based on 120 subjects while r_13 was computed based on 118 subjects due to 2 missing values in variable 3). For constructing the variance-covariance matrix, we need to assume a ‘common’ sample size for all correlation coefficients within the study. Argument nfun provides some options for how the common sample size should be computed. Possible options are "min" (for using the minimum sample size within a study as the common sample size), "harmonic" (for using the harmonic mean), or "mean" (for using the arithmetic mean). The default is "min", which is a conservative choice (i.e., it will overestimate the sampling variances of coefficients that were computed based on a sample size that was actually larger than the minimum sample size). One can also specify a function via the nfun argument (which should take a numeric vector as input and return a single value).

References

Olkin, I., & Finn, J. D. (1990). Testing correlated correlations. Psychological Bulletin, 108(2), 330--333. https://doi.org/10.1037/0033-2909.108.2.330

Steiger, J. H. (1980). Tests for comparing elements of a correlation matrix. Psychological Bulletin, 87(2), 245--251. https://doi.org/10.1037/0033-2909.87.2.245

See Also

rma.mv, dat.craft2003

Examples

Run this code
# NOT RUN {
### copy data into 'dat'
dat <- dat.craft2003

### construct dataset and var-cov matrix of the correlations
tmp <- rcalc(ri ~ var1 + var2 | study, ni=ni, data=dat)
V <- tmp$V
dat <- tmp$dat

### examine data for study 1
dat[dat$study == 1,]
V[dat$study == 1, dat$study == 1]

### examine data for study 6
dat[dat$study == 6,]
V[dat$study == 6, dat$study == 6]

### examine data for study 17
dat[dat$study == 17,]
V[dat$study == 17, dat$study == 17]
# }

Run the code above in your browser using DataLab