Function to convert a matrix with the correlations among multivariate normal test statistics to a matrix with the covariances among various target statistics.

mvnconv(R, side = 2, target, cov2cor = FALSE)

Arguments

R

a \(k \times k\) symmetric matrix that contains the correlations among the test statistics.

side

scalar to specify the sidedness of the \(p\)-values that are obtained from the test statistics (2, by default, for two-sided tests; 1 for one-sided tests).

target

the target statistic for which the covariances are calculated (either "p", "m2lp", "chisq1", or "z"). See ‘Details’.

cov2cor

logical to indicate whether to convert the covariance matrix to a correlation matrix (default is FALSE).

Details

The function converts a matrix with the correlations among multivariate normal test statistics to a matrix with the covariances among various target statistics. In particular, assume \[\begin{bmatrix} t_i \\ t_j \end{bmatrix} \sim \mbox{MVN} \left(\begin{bmatrix} 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 1 & \rho_{ij} \\ \rho_{ij} & 1 \end{bmatrix} \right)\] is the joint distribution for test statistics \(t_i\) and \(t_j\). For side = 1, let \(p_i = 1 - \Phi(t_i)\) and \(p_j = 1 - \Phi(t_j)\) where \(\Phi(\cdot)\) denotes the cumulative distribution function of a standard normal distribution. For side = 2, let \(p_i = 2(1 - \Phi(|t_i|))\) and \(p_j = 2(1 - \Phi(|t_j|))\). These are simply the one- and two-sided \(p\)-values corresponding to \(t_i\) and \(t_j\).

If target = "p", the function computes \(\mbox{Cov}[p_i, p_j]\).

If target = "m2lp", the function computes \(\mbox{Cov}[-2 \ln(p_i), -2 \ln(p_j)]\).

If target = "chisq1", the function computes \(\mbox{Cov}[F^{-1}(1 - p_i, 1), F^{-1}(1 - p_j, 1)]\), where \(F^{-1}(\cdot,1)\) denotes the inverse of the cumulative distribution function of a chi-square distribution with one degree of freedom.

If target = "z", the function computes \(\mbox{Cov}[\Phi^{-1}(1 - p_i), \Phi^{-1}(1 - p_j)]\), where \(\Phi^{-1}(\cdot)\) denotes the inverse of the cumulative distribution function of a standard normal distribution.

Value

The function returns the covariance matrix (or the correlation matrix if cov2cor = TRUE).

Note

Since computation of the covariances requires numerical integration, the function doesn't actually compute these covariances on the fly. Instead, it uses the mvnlookup lookup table, which contains the covariances.

Author

Ozan Cinar ozancinar86@gmail.com
Wolfgang Viechtbauer wvb@wvbauer.com

References

Cinar, O. & Viechtbauer, W. (2022). The poolr package for combining independent and dependent p values. Journal of Statistical Software, 101(1), 1--42. https://doi.org/10.18637/jss.v101.i01

Examples

# illustrative correlation matrix
R <- matrix(c(   1,  0.8,  0.5,  0.3,
               0.8,    1,  0.2,  0.4,
               0.5,  0.2,    1,  0.7,
               0.3,  0.4,  0.7,    1), nrow = 4, ncol = 4)

# convert R into covariance matrices for the chosen targets
mvnconv(R, target = "p")
#>        [,1]   [,2]   [,3]   [,4]
#> [1,] 0.0833 0.0420 0.0138 0.0047
#> [2,] 0.0420 0.0833 0.0020 0.0086
#> [3,] 0.0138 0.0020 0.0833 0.0299
#> [4,] 0.0047 0.0086 0.0299 0.0833
mvnconv(R, target = "m2lp")
#>        [,1]   [,2]   [,3]   [,4]
#> [1,] 4.0000 2.5272 0.9799 0.3519
#> [2,] 2.5272 4.0000 0.1563 0.6262
#> [3,] 0.9799 0.1563 4.0000 1.9286
#> [4,] 0.3519 0.6262 1.9286 4.0000
mvnconv(R, target = "chisq1")
#>        [,1]   [,2]   [,3]   [,4]
#> [1,] 2.0000 1.2795 0.4998 0.1799
#> [2,] 1.2795 2.0000 0.0799 0.3198
#> [3,] 0.4998 0.0799 2.0000 0.9796
#> [4,] 0.1799 0.3198 0.9796 2.0000
mvnconv(R, target = "z")
#>        [,1]   [,2]   [,3]   [,4]
#> [1,] 1.0000 0.5081 0.1806 0.0632
#> [2,] 0.5081 1.0000 0.0278 0.1137
#> [3,] 0.1806 0.0278 1.0000 0.3731
#> [4,] 0.0632 0.1137 0.3731 1.0000

# convert R into correlation matrices for the chosen targets
mvnconv(R, target = "p",      cov2cor = TRUE)
#>            [,1]      [,2]      [,3]       [,4]
#> [1,] 1.00000000 0.5042017 0.1656663 0.05642257
#> [2,] 0.50420168 1.0000000 0.0240096 0.10324130
#> [3,] 0.16566627 0.0240096 1.0000000 0.35894358
#> [4,] 0.05642257 0.1032413 0.3589436 1.00000000
mvnconv(R, target = "m2lp",   cov2cor = TRUE)
#>          [,1]     [,2]     [,3]     [,4]
#> [1,] 1.000000 0.631800 0.244975 0.087975
#> [2,] 0.631800 1.000000 0.039075 0.156550
#> [3,] 0.244975 0.039075 1.000000 0.482150
#> [4,] 0.087975 0.156550 0.482150 1.000000
mvnconv(R, target = "chisq1", cov2cor = TRUE)
#>         [,1]    [,2]    [,3]    [,4]
#> [1,] 1.00000 0.63975 0.24990 0.08995
#> [2,] 0.63975 1.00000 0.03995 0.15990
#> [3,] 0.24990 0.03995 1.00000 0.48980
#> [4,] 0.08995 0.15990 0.48980 1.00000
mvnconv(R, target = "z",      cov2cor = TRUE)
#>        [,1]   [,2]   [,3]   [,4]
#> [1,] 1.0000 0.5081 0.1806 0.0632
#> [2,] 0.5081 1.0000 0.0278 0.1137
#> [3,] 0.1806 0.0278 1.0000 0.3731
#> [4,] 0.0632 0.1137 0.3731 1.0000