Compute the GFisher test statistics \(S = \sum_i w_i F^{-1}_{d_i}(1-P_i)\), based on a vector of p-values \(P_i\)'s, degrees of freedom \(d_i\)'s, and weights \(w_i\)'s. \(F^{-1}_{d_i}\) is the inverse CDF of the chi-square distribution with \(d_i\) degrees of freedom.
stat.GFisher(p, df = 2, w = 1)A numeric vector of input p-values for the GFisher test. Must be between 0 and 1.
Degrees of freedom for inverse chi-square transformation for each p-value.
It can be a vector of the same length as p, indicating each transformation function
might have a different df, or a single number, indicating the same degrees of freedom for all.
Default is 2 (standard Fisher's method).
A numeric vector of non-negative weights for each p-value. Default is 1 (equal weights). If a single value is provided, equal weights are used for all p-values. Note: Weights are automatically normalized to sum to 1 (i.e., \(w \leftarrow w/\sum(w)\)). This normalization improves numerical stability and is statistically equivalent to other normalizations such as \(\sum w_i = n\).
A numeric value representing the GFisher test statistic.
Compute the GFisher Test Statistic
The statistic is calculated based on normalized weights, i.e., \(w/\sum(w)\), ensuring that the weights always sum to 1.
When all degrees of freedom equal 2, the function uses a faster implementation equivalent to Fisher's combination method: \(-2\log(p)\).
The GFisher test generalizes Fisher's combination method by allowing:
Different degrees of freedom for each p-value transformation
Flexible weighting schemes
Handling of dependent test statistics through correlation structure (see p.GFisher)
Zhang, H., & Wu, Z. (2023). The generalized Fisher's combination and accurate p-value calculation under dependence. Biometrics, 79(2), 1159-1172.
# Example 1: Equal weights with df=2 (standard Fisher's method)
set.seed(123)
n <- 10
pval <- runif(n)
stat.GFisher(pval, df = 2, w = 1)
#> [1] 1.556849
# Example 2: Equal weights with explicit vectors
stat.GFisher(pval, df = rep(2, n), w = rep(1, n))
#> [1] 1.556849
# Example 3: Varying degrees of freedom and weights
stat.GFisher(pval, df = 1:n, w = 1:n)
#> [1] 6.159286
# Example 4: Small p-values (signal detection)
pval_signal <- c(0.001, 0.002, 0.05, runif(7))
stat.GFisher(pval_signal, df = 2, w = 1)
#> [1] 4.336296