`rcalc.Rd`

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

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

- 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.

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, \(\mbox{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, \(\mbox{Cov}[r_{12}, r_{34}]\), then depends on \(r_{13}\), \(r_{14}\), \(r_{23}\), and \(r_{24}\).

Equations to compute 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 coefficients (say `ri`

), and the sample sizes based on which the correlation coefficients were 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 (Fisher, 1921) 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).

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`

).

For raw correlation coefficients, the variance-covariance matrix is computed with \(n-1\) in the denominator (instead of \(n\) as suggested in Steiger, 1980, and Olkin & Finn, 1990). This is more consistent with the usual equation for computing the sampling variance of a correlation coefficient (with \(n-1\) in the denominator).

For raw and r-to-z transformed coefficients, the variance-covariance matrix will only be computed when the (common) sample size for a study is at least 5.

Fisher, R. A. (1921). On the “probable error” of a coefficient of correlation deduced from a small sample. *Metron*, **1**, 1–32. http://hdl.handle.net/2440/15169

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

`rma.mv`

for a model fitting function that can be used to meta-analyze dependent correlation coefficients.

`dat.craft2003`

for an illustrative example.

```
### 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,]
#> study var1 var2 var1.var2 yi ni
#> 1 1 acog perf acog.perf -0.55 142
#> 2 1 asom perf asom.perf -0.48 142
#> 3 1 conf perf conf.perf 0.66 142
#> 4 1 acog asom acog.asom 0.47 142
#> 5 1 acog conf acog.conf -0.38 142
#> 6 1 asom conf asom.conf -0.46 142
blsplit(V, dat$study)$`6`
#> acog.perf asom.perf conf.perf acog.asom acog.conf asom.conf
#> acog.perf 0.043352064 0.025583395 NA 0.009529623 NA NA
#> asom.perf 0.025583395 0.041438304 NA 0.008459787 NA NA
#> conf.perf NA NA NA NA NA NA
#> acog.asom 0.009529623 0.008459787 NA 0.020247414 NA NA
#> acog.conf NA NA NA NA NA NA
#> asom.conf NA NA NA NA NA NA
### examine data for study 6
dat[dat$study == 6,]
#> study var1 var2 var1.var2 yi ni
#> 13 6 acog perf acog.perf 0.44 16
#> 14 6 asom perf asom.perf 0.46 16
#> 15 6 conf perf conf.perf NA 16
#> 16 6 acog asom acog.asom 0.67 16
#> 17 6 acog conf acog.conf NA 16
#> 18 6 asom conf asom.conf NA 16
blsplit(V, dat$study)$`6`
#> acog.perf asom.perf conf.perf acog.asom acog.conf asom.conf
#> acog.perf 0.043352064 0.025583395 NA 0.009529623 NA NA
#> asom.perf 0.025583395 0.041438304 NA 0.008459787 NA NA
#> conf.perf NA NA NA NA NA NA
#> acog.asom 0.009529623 0.008459787 NA 0.020247414 NA NA
#> acog.conf NA NA NA NA NA NA
#> asom.conf NA NA NA NA NA NA
### examine data for study 17
dat[dat$study == 17,]
#> study var1 var2 var1.var2 yi ni
#> 25 17 acog perf acog.perf 0.10 45
#> 26 17 asom perf asom.perf 0.31 45
#> 27 17 conf perf conf.perf -0.17 45
#> 28 17 acog asom acog.asom NA 45
#> 29 17 acog conf acog.conf NA 45
#> 30 17 asom conf asom.conf NA 45
blsplit(V, dat$study)$`17`
#> acog.perf asom.perf conf.perf acog.asom acog.conf asom.conf
#> acog.perf 0.022275 NA NA NA NA NA
#> asom.perf NA 0.01856898 NA NA NA NA
#> conf.perf NA NA 0.02143262 NA NA NA
#> acog.asom NA NA NA NA NA NA
#> acog.conf NA NA NA NA NA NA
#> asom.conf NA NA NA NA NA NA
```