Calculate the p-value of a GFisher test statistic under dependence, using moment matching methods to account for correlation structure among input statistics.

p.GFisher(
  q,
  df,
  w,
  M,
  p.type = "two",
  method = "HYB",
  nsim = NULL,
  seed = NULL,
  use.cpp = TRUE
)

Arguments

q

Numeric value of the observed GFisher statistic (typically from stat.GFisher).

df

Vector of degrees of freedom for inverse chi-square transformation for each p-value. If all dfs are equal, it can be defined by a single constant.

w

Vector of non-negative weights. If a single value, equal weights are used. Note: Weights are automatically normalized to sum to 1.

M

Correlation matrix of the Z-scores from which the input p-values were obtained. Must be a square matrix with dimension equal to the length of df.

p.type

Character string specifying p-value type:

  • "two": Two-sided input p-values (default)

  • "one": One-sided input p-values

method

Character string specifying the calculation method:

  • "MR": Simulation-assisted moment ratio matching (recommended for tail probabilities)

  • "HYB": Moment ratio matching by quadratic approximation (default, faster but only for two-sided p-values)

  • "GB": Brown's method with calculated variance

nsim

Number of simulations used in the "MR" method. Default is 5e4. Larger values provide more accurate estimates but take longer to compute.

seed

Optional seed for random number generation in simulation-based methods. Default is NULL (no seed set).

use.cpp

Logical indicating whether to use C++ implementation for method="MR". Default is TRUE. Set to FALSE to use pure R implementation.

Value

A numeric value representing the p-value of the GFisher test.

Details

Compute the P-Value of a GFisher Test

This function calculates the p-value for a GFisher test statistic under dependence by approximating the null distribution using moment matching.

Method Selection:

  • HYB (Hybrid): Uses quadratic approximation based on the first four moments. Faster but only works for two-sided p-values. Best for moderate test statistics.

  • MR (Moment Ratio): Uses simulation to estimate moments, then applies moment matching. More accurate for extreme tail probabilities and works for both one-sided and two-sided p-values.

  • GB (Generalized Brown): Uses Brown's method with calculated variance. Simplest approximation but may be less accurate.

The function automatically handles near-singular correlation matrices by finding the nearest positive definite matrix when necessary.

Weights are automatically normalized to sum to 1.

References

Zhang, H., & Wu, Z. (2023). The generalized Fisher's combination and accurate p-value calculation under dependence. Biometrics, 79(2), 1159-1172.

Author

Hong Zhang, Zheyang Wu

Examples

# Example 1: Simple case with equal correlation
set.seed(123)
n <- 10
M <- matrix(0.3, n, n) + diag(0.7, n, n)  # Correlation matrix
zscore <- matrix(rnorm(n), nrow = 1) %*% chol(M)
pval <- 2 * (1 - pnorm(abs(zscore)))  # Two-sided p-values

# Calculate statistic and p-value with df=2
gf1 <- stat.GFisher(pval, df = 2, w = 1)
p.GFisher(gf1, df = 2, w = 1, M = M, method = "HYB")
#> [1] 0.7298643
p.GFisher(gf1, df = 2, w = 1, M = M, method = "MR", nsim = 5e4)
#> [1] 0.741206

# Example 2: Varying df and weights
gf2 <- stat.GFisher(pval, df = 1:n, w = 1:n)
p.GFisher(gf2, df = 1:n, w = 1:n, M = M, method = "HYB")
#> [1] 0.733471
p.GFisher(gf2, df = 1:n, w = 1:n, M = M, method = "MR", nsim = 5e4)
#> [1] 0.7234016