View source: R/matching_path.R
| match_path | R Documentation |
Solves the matching once for each value of one argument and returns what happened at each: how many units were matched, at what total distance, how balanced the matched sample is, and the certificate saying the matching is optimal for that value. The points are solved as one sequence rather than one at a time, each starting from the matching the previous value found.
match_path(
left,
right,
vars,
left_id = NULL,
right_id = NULL,
vary = "max_distance",
values,
distance = "euclidean",
weights = NULL,
scale = FALSE,
auto_scale = FALSE,
calipers = NULL,
sigma = NULL,
certify = TRUE,
keep_per_row = .implicit_defaults()$keep_per_row,
width = .implicit_defaults()$width,
tol = .implicit_defaults()$tol,
max_rounds = .implicit_defaults()$max_rounds
)
left, right |
Data frames to match. Both are required. |
vars |
Character vector of matching variables, present in both. |
left_id, right_id |
Name of the column holding the unit identifier, or
NULL (default) to use a column called |
vary |
The argument to sweep. |
values |
The values to sweep it through, ascending. |
distance |
Distance metric, as in |
weights, scale, auto_scale, sigma |
Distance construction, as in
|
calipers |
Per-variable calipers held fixed across the path, as in
|
certify |
Whether each point carries a checked certificate. |
keep_per_row, width, tol, max_rounds |
The edge-generation loop's search
knobs, shared with |
values must ascend. Each point is solved from the point before it, which
works because a wider value only ever adds pairs to choose from; a descending
sweep takes pairs away from a matching already using them, and is refused
rather than reordered.
An object of class couplr_path: $path, one row per point,
$balance, one row per point per variable, and the match vector,
certificate, round record and Hall witness for each of them.
set.seed(1)
left <- data.frame(id = 1:20, x = rnorm(20), y = rnorm(20))
right <- data.frame(id = 1:60, x = rnorm(60), y = rnorm(60))
path <- match_path(left, right, vars = c("x", "y"),
vary = "max_distance", values = c(0.5, 1, 2, Inf))
path$path
path$balance
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.