Learn R Programming

vecmatch (version 1.3.0)

run_selected_matching: Rerun GPS Estimation and Matching for a Selected Configuration

Description

Rerun GPS Estimation and Matching for a Selected Configuration

Usage

run_selected_matching(x, data, formula, smd_group = NULL, row = 1L, ...)

Value

The result of match_gps().

Arguments

x

A select_result object returned by select_opt().

data

Data frame used in the original optimization (pass it the same way as in your original analysis, e.g. data = cancer).

formula

Model formula used for GPS estimation (e.g. formula_cancer).

smd_group

Optional SMD bin to filter on (e.g. "0.10-0.15"). If NULL, no filtering is applied.

row

Integer index of the row (after optional filtering by smd_group) to use. Defaults to 1.

...

Extra args forwarded to match_gps().

Examples

Run this code
# \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