Saves a trained glow_B_model object to an RDS file with a metadata envelope for validation on load. The metadata includes the package version (kept as provenance), save date, training size, and model selection information, and the envelope carries the serialization format (format_version), which load_B_model checks.

Also accepts a glow_B_estimate object (from get_B with return_full = TRUE), from which the nested $model is extracted and saved.

save_B_model(model, path, compress = TRUE)

Arguments

model

A glow_B_model object (from train_B_model) or a glow_B_estimate object (from get_B with return_full = TRUE). If a glow_B_estimate is provided, the nested $model (a glow_B_model) is extracted and saved.

path

Character. File path for the saved model (.rds extension).

compress

Logical (default TRUE). Use compression when saving.

Value

Invisible character: the path where the model was saved.

See also

load_B_model for loading saved models predict_B for applying loaded models to new data train_B_model for training B estimation models get_B for combined train + predict

Examples

if (FALSE) { # \dontrun{
# Save a trained model directly
b_model <- train_B_model(
  training_trait = "binary",
  training_MAF = known_snps$MAF,
  training_BETA = known_snps$BETA,
  method = "beta"
)
save_B_model(b_model, "B_model_als.rds")

# Or save from a full estimation result
B_result <- get_B(
  training_trait = "binary",
  training_MAF = known_snps$MAF,
  training_BETA = known_snps$BETA,
  target_MAF = seq(0.001, 0.3, length.out = 100),
  return_full = TRUE
)
save_B_model(B_result, "B_model_als.rds")
} # }