# \donttest{
# Define formula and set up optimization
formula_cancer <- formula(status ~ age * sex)
opt_args <- make_opt_args(cancer, formula_cancer, gps_method = "m1")
withr::with_seed(8252, {
opt_results <- optimize_gps(
data = cancer,
formula = formula_cancer,
opt_args = opt_args,
n_iter = 2000
)
})
# Select optimal combinations prioritizing SMD balance and matching in key
# groups
select_results <- select_opt(
x = opt_results,
smd_groups = list(
c("adenoma", "control"),
c("control", "crc_benign"),
c("crc_malignant", "control")
),
smd_variables = "age",
smd_type = "max",
perc_matched = c("adenoma", "crc_malignant")
)
# Extract the parameter grid from select_results for smd_group = "0.05-0.10"
get_select_params(select_results, smd_group = "0.05-0.10")
# Rerun the analysis
# }
Run the code above in your browser using DataLab