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)) {
    .err("no units were matched")
  }

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

  if (all_equal_to(w[treat == 0], 0)) {
    .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 June 8, 2025, 11:01 a.m.