R/weights.matrix.R

Defines functions weights.matrix

weights.matrix <- function(match.matrix, treat) {

  weights <- weights_matrix(match.matrix, treat)

  if (sum(weights)==0)
    stop("No units were matched.", call. = FALSE)
  else if (sum(weights[treat == 1])==0)
    stop("No treated units were matched.", call. = FALSE)
  else if (sum(weights[treat == 0])==0)
    stop("No control units were matched.", call. = FALSE)

  return(setNames(weights, 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 Nov. 27, 2020, 9:07 a.m.