MG: Matched Groups

Description Usage Arguments Details Value Examples

View source: R/post_matching.R

Description

MG returns the matched groups of the supplied units.

Usage

1
MG(units, ame_out, multiple = FALSE, id_only = FALSE, index_only)

Arguments

units

A vector of units whose matched groups are desired.

ame_out

An object of class ame.

multiple

A logical scalar. If FALSE (default), then MG will only return the main matched group for each unit. See below for details. Cannot be set to TRUE if ame_out was generated without replacement.

id_only

A logical scalar. If TRUE, then only the IDs of the units in each matched group are returned, and not their treatment, outcome, or covariate information.

index_only

Defunct. Use 'id_only' instead.

Details

The units argument refers to units with respect to rownames(ame_out$data). Typically, this will also correspond to the indexing of the data (i.e. passing units = 3 will return the matched group of the 3rd unit in the matching data). However, if a separate holdout set was not passed to the matching algorithm or if the original matching data had rownames other than 1:nrow(data), then this is not the case.

The multiple argument toggles whether only a unit's main matched group (MMG) or all matched groups a unit is part of should be returned. A unit's MMG contains its highest quality matches (that is, the units with which it first matched in the sequence of considered covariate sets). If the original call that generated ame_out specified replace = FALSE then units only are part of one matched group (which is also their MMG) and multiple must be set to FALSE.

Value

A list of length length(units), each entry of which corresponds to a different unit in units. For matched units, if multiple = FALSE, each entry is 1. a data frame containing the treatment and outcome information of members of the matched group, along with covariates they were matched on if id_only = FALSE or 2. a vector of the IDs of matched units if id_only = TRUE . If multiple = TRUE, each entry of the returned list is a list containing the previously described information, but with each entry corresponding to a different matched group. In either case, entries corresponding to unmatched units are NULL.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
data <- gen_data()
holdout <- gen_data()
FLAME_out <- FLAME(data = data, holdout = holdout, replace = TRUE)

# Only the main matched group of unit 1
MG(1, FLAME_out, multiple = F)

# All matched groups of unit 1
MG(1, FLAME_out, multiple = T)

## End(Not run)

FLAME documentation built on Dec. 11, 2021, 9:26 a.m.