Skip to contents

Native greedy nearest-neighbour matching on the logit propensity score (Rosenbaum & Rubin 1985; caliper per Cochran & Rubin 1973). The propensity model is base stats::glm; no MatchIt at runtime. Returns the same morie_match_result shape as always; cross-validated against MatchIt in tests/cross/.

Usage

morie_matching_nearest_neighbor(
  data,
  treatment,
  covariates,
  n_neighbors = 1L,
  caliper = NULL,
  replace = FALSE,
  ps = NULL,
  alpha = 0.05
)

Arguments

data

Data frame.

treatment

Binary treatment column (0/1).

covariates

Character vector of covariates for the propensity model.

n_neighbors

Number of matches per treated unit (forwarded as ratio).

caliper

Maximum logit-propensity distance for a valid match, expressed in SD units of the logit (or NULL for no caliper).

replace

If TRUE, controls may be re-used.

ps

Optional pre-computed propensity scores (ignored; retained for back-compat).

alpha

Significance level (carried through to details).

Value

A list of class morie_match_result.

Examples

# \donttest{
set.seed(1)
df <- data.frame(y = rnorm(200), d = rbinom(200, 1, 0.4),
                 x1 = rnorm(200), x2 = rnorm(200))
res <- morie_matching_nearest_neighbor(df, "d", c("x1", "x2"),
                                       caliper = 0.2)
# }