matching_group: Enumerates potential matches

Description Usage Arguments Details Value Examples

View source: R/matching_group.r

Description

Given a variable Treat, matching_group enumerates the individuals towards each observation can be matched against. If exact is specified, then it performes exact match (see examples).

Usage

1
matching_group(Treat, exact = NULL)

Arguments

Treat

Integer vector of size n. Group indicator. Can be either -1 (no group), 0 (control) or 1 (treatment).

exact

Numeric matrix with n rows. When specified, exact matching is performed on those variables (see matching_group).

Details

In the most common case Treat will be either of 0 or 1, in which case individuals will be matched against their opposite group. If Treat == -1, then the group constraint will be void.

Value

A list of length n specifying for each i to which individuals each j != i will be matched.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Asigning matching groups for lalonde --------------------------------------

data(lalonde, package = "MatchIt")
dat <- lalonde

# Match (no exact)
m_noexact <- matching_group(dat$treat)

# How many matches?
table(sapply(m_noexact, length))
table(dat$treat)

# What if we ask exact match on black ---------------------------------------

m_exact <- matching_group(dat$treat, dat$black)

table(sapply(m_exact, length))
with(dat, table(treat, black))

gvegayon/blopmatch documentation built on Dec. 2, 2019, 6:27 a.m.