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
)

Arguments

B_result

Object of class "glow_B_estimate" (from get_B with return_full = TRUE) or "glow_B_model" (from train_B_model).

which_method

Character string specifying which method to analyze: "beta", "pvalue", or "both" (default)

criterion

Character string specifying selection criterion to highlight: "R2" (default), "adj_R2", or "CV_R2"

plot

Logical. If TRUE (default), creates a visualization comparing models

verbose

Integer. Verbosity level: 0=silent, 1=warnings (default), 2=info messages

Value

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")

Details

The function fits all 8 candidate models:

  1. Y ~ X

  2. Y ~ f(X) where f(X) = X(1-X)

  3. Y ~ log(X)

  4. Y ~ log(f(X))

  5. log(Y) ~ X

  6. log(Y) ~ f(X)

  7. log(Y) ~ log(X)

  8. 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.

Computational Complexity

O(8 * n) where n is the number of training variants

See also

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

Examples

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)
} # }