Learn R Programming

cem (version 1.1.31)

pair: Produces a paired sample out of a CEM match solution

Description

Produces a paired sample out of a CEM match solution

Usage

pair(obj, data, method=NULL, mpower=2, verbose=1)

Value

obj

a list with the fields paired, full.paired, reservoir and reservoir2. The latter contain the indexes of the unmatched units.

Arguments

obj

an object as output from cem

data

the original data.frame used by cem

method

distance method to use in k2k matching. See Details.

mpower

power of the Minkowski distance. See Details.

verbose

controls level of verbosity. Default=0.

Author

Stefano Iacus, Gary King, and Giuseppe Porro

Details

This function returns a vector of paired matched units index.

The user can choose a method (between `euclidean', `maximum', `manhattan', `canberra', `binary' and `minkowski') for nearest neighbor matching inside each cem strata. By default method is set to `NULL', which means random matching inside cem strata. For the Minkowski distance the power can be specified via the argument mpower'. For more information on method != NULL, refer to dist help page.

References

Iacus, King, Porro (2011) tools:::Rd_expr_doi("10.1198/jasa.2011.tm09599")

Iacus, King, Porro (2012) tools:::Rd_expr_doi("10.1093/pan/mpr013")

Iacus, King, Porro (2019) tools:::Rd_expr_doi("10.1017/pan.2018.29")

Examples

Run this code
# \donttest{
data(LL)
set.seed(123)
# cem match: automatic bin choice
mat <- cem(data=LL, drop="re78")

# we want a set of paired units
psample <- pair(mat, data=LL)
table(psample$paired)
psample$paired[1:100]

table(psample$full.paired)
psample$full.paired[1:10]



# cem match: automatic bin choice, we drop one row from the data set
mat1 <- cem(data=LL[-1,], drop="re78")

# we want a set of paired units but we have an odd number of units in the data
psample <- pair(mat1, data=LL[-1,])
table(psample$full.paired)
# }

Run the code above in your browser using DataLab