Fits and compares all 8 candidate regression models for B estimation, returning a summary table with fit statistics. This helps users understand which transformations best capture the MAF-effect size relationship.
compare_B_models(
B_result,
which_method = "both",
criterion = "R2",
plot = TRUE,
verbose = 1
)Object of class "glow_B_estimate" (from
get_B with return_full = TRUE) or
"glow_B_model" (from train_B_model).
Character string specifying which method to analyze: "beta", "pvalue", or "both" (default)
Character string specifying selection criterion to highlight: "R2" (default), "adj_R2", or "CV_R2"
Logical. If TRUE (default), creates a visualization comparing models
Integer. Verbosity level: 0=silent, 1=warnings (default), 2=info messages
A data frame with one row per model containing:
model_name: Descriptive name (e.g., "Y ~ X", "log(Y) ~ log(X)")
formula: Model formula
R2: R-squared value
adj_R2: Adjusted R-squared
CV_R2: Cross-validated R-squared (if requested)
is_best: Logical indicating if this is the selected model (by criterion)
method: Which estimation method ("beta_method" or "pvalue_method")
The function fits all 8 candidate models:
Y ~ X
Y ~ f(X) where f(X) = X(1-X)
Y ~ log(X)
Y ~ log(f(X))
log(Y) ~ X
log(Y) ~ f(X)
log(Y) ~ log(X)
log(Y) ~ log(f(X))
For the beta method, Y = BETA^2. For the p-value method, Y = h^2.
Model Selection Criteria:
R^2: Proportion of variance explained. Higher is better. Preferred when sample size is large (>100).
Adjusted R^2: R^2 adjusted for number of predictors. Higher is better. Balances fit and parsimony. Good for small-medium samples.
CV_R2: Cross-validated R^2. Higher is better. Most robust against overfitting. Recommended for small samples.
O(8 * n) where n is the number of training variants
get_B for B estimation
train_B_model for training B estimation models
select_best_model for the internal model selection function
get_B_diagnostics for comprehensive diagnostics
if (FALSE) { # \dontrun{
# Run get_B with both methods
result <- get_B(
training_trait = "binary",
training_MAF = training_MAF,
training_BETA = training_BETA,
training_P = training_P,
training_N = training_N,
target_trait = "binary",
target_MAF = target_MAF,
target_case_prop = 0.1,
method = "both",
return_full = TRUE
)
# Compare all models
model_comparison <- compare_B_models(result, criterion = "R2", plot = TRUE)
# View results sorted by R^2
model_comparison[order(-model_comparison$R2), ]
# Also works with glow_B_model directly
b_model <- train_B_model(...)
compare_B_models(b_model, which_method = "beta", plot = TRUE)
} # }