R/get_weights_from_mm.R

Defines functions get_weights_from_mm

get_weights_from_mm <- function(match.matrix, treat, focal = NULL) {

  if (!is.integer(match.matrix)) {
    match.matrix <- charmm2nummm(match.matrix, treat)
  }

  w <- weights_matrixC(match.matrix, treat, focal)

  if (all_equal_to(w, 0)) {
    arg::err("no units were matched")
  }

  if (all_equal_to(w[treat == 1], 0)) {
    arg::err("no treated units were matched")
  }

  if (all_equal_to(w[treat == 0], 0)) {
    arg::err("no control units were matched")
  }

  setNames(w, names(treat))
}

Try the MatchIt package in your browser

Any scripts or data that you put into this service are public.

MatchIt documentation built on Sept. 17, 2026, 1:07 a.m.