R/GFisher-helpers.R
getGFishercov.RdCalculate the covariance between two GFisher statistics with potentially different degrees of freedom and weights.
getGFishercov(D1, D2, W1, W2, M, p.type = "two", var.correct = TRUE)A vector of degrees of freedom for the first GFisher statistic.
A vector of degrees of freedom for the second GFisher statistic.
A vector of weights for the first GFisher statistic.
A vector of weights for the second GFisher statistic.
Correlation matrix of the input Z-scores from which the input p-values were obtained.
Character string: "two" for two-sided (default), "one" for one-sided input p-values.
Logical, default TRUE. If TRUE, ensures exact variance is used
by applying a variance correction factor.
A numeric value representing the covariance between the two GFisher statistics \(T^{(l)}\) and \(T^{(r)}\).
Compute Covariance Between Two GFisher Statistics
This function implements Corollary 2 from the GFisher paper, which provides a formula for computing the covariance between two GFisher statistics:
$$\text{Cov}(T^{(l)}, T^{(r)}) = \sum_{i,j} w_i^{(l)} w_j^{(r)} \text{Cov}(T_i^{(l)}, T_j^{(r)})$$
The component covariances are approximated using Hermite polynomial expansions based on
the correlation structure M.
For two-sided p-values:
The cross-covariance matrix is computed as: $$GM_{ij} = \sum_{k=1}^{4} \frac{\rho_{ij}^{2k}}{(2k)!} I_i^{(l)}(2k) I_j^{(r)}(2k)$$
For one-sided p-values:
A similar formula is used but with odd-order terms included.
If var.correct = TRUE, the function rescales the covariance to ensure exact marginal variances.
This includes Corollary 1 as a special case (when \(l = r\)).
Zhang, H., & Wu, Z. (2023). The generalized Fisher's combination and accurate p-value calculation under dependence. Biometrics, 79(2), 1159-1172. See Corollary 2.