Dispatches to the appropriate score statistic function based on trait type and SPA preference. For binary traits, defaults to SPA-corrected statistics. For continuous traits, uses standard score statistics.

compute_score_stats(G, null_model, use_spa = NULL, verbose = 1)

Arguments

G

Numeric matrix (n_samples x p_variants). Processed genotype matrix. Must not contain NA values.

null_model

A glow_null_model object from fit_null_model.

use_spa

Logical or NULL (default NULL). NULL = auto-detect (SPA for binary traits, standard for continuous). TRUE = force SPA (binary only). FALSE = force standard (any trait).

verbose

Integer. Verbosity level (default 1). Set to 0 to suppress messages.

Value

A list with components:

Zscores

Numeric vector (length p) of standardized marginal score statistics.

M_Z

Numeric matrix (p x p) correlation matrix of Z-scores.

M_s

Numeric matrix (p x p) covariance matrix of score statistics.

s0

Numeric scalar. Dispersion parameter (1 for binary traits).

Details

This is a thin dispatcher that unifies the API for score statistic computation. It selects between getZ_marg_score and getZ_marg_score_binary_SPA based on trait type (extracted from the null model) and the use_spa parameter.

The default behavior (use_spa = NULL) auto-detects: SPA for binary traits (recommended for rare variants and unbalanced case-control), standard for continuous traits. Users can override with explicit TRUE or FALSE.

All computation is delegated to the underlying functions; this function performs only input validation and dispatch logic.

References

Zhang, H., Liu, M., Landers, J. E., and Wu, Z. (2026). Integrated weighted association test with application to genetic association studies. The Annals of Applied Statistics, 20(3), 2074-2097. doi:10.1214/26-AOAS2223

Dey, R., Schmidt, E. M., Abecasis, G. R., and Lee, S. (2017). A fast and accurate algorithm to test for binary phenotypes and its application to PheWAS. American Journal of Human Genetics, 101(1), 37-49. doi:10.1016/j.ajhg.2017.05.014

See also

getZ_marg_score for standard score statistics, getZ_marg_score_binary_SPA for SPA-corrected statistics, fit_null_model for null model fitting.

Examples

# Binary trait (auto-selects SPA)
set.seed(42)
n <- 200; p <- 5
G <- matrix(rbinom(n * p, 2, 0.1), n, p)
X <- cbind(1, rnorm(n))
Y <- rbinom(n, 1, 0.3)
nm <- fit_null_model(X, Y, trait = "binary")
res <- compute_score_stats(G, nm)
#> Score stats: trait=binary, SPA=TRUE, p=5

# Continuous trait (auto-selects standard)
Y_cont <- rnorm(n)
nm_cont <- fit_null_model(X, Y_cont, trait = "continuous")
res_cont <- compute_score_stats(G, nm_cont)
#> Score stats: trait=continuous, SPA=FALSE, p=5