strata_match: Strata Match

Description Usage Arguments Value Examples

View source: R/match_functions.R

Description

Match within strata in series using optmatch. Requires optmatch package to be installed.

Usage

1
strata_match(object, model = NULL, method = "prop", k = 1)

Arguments

object

a strata object

model

(optional) formula for matching. If left blank, all columns of the analysis set in object will be used as covariates in the propensity model or mahalanobis match (except outcome, treatment and stratum)

method

either "prop" for propensity score matching based on a glm fit with model model, or "mahal" for mahalanobis distance matching by the covariates in model.

k

the number of control individuals to be matched to each treated individual. If "k = full" is used, fullmatching is done instead of pairmatching

Value

a named factor with matching assignments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# make a sample data set
set.seed(1)
dat <- make_sample_data(n = 75)

# stratify with auto_stratify
a.strat <- auto_stratify(dat, "treat", outcome ~ X2, size = 25)

# 1:1 match based on propensity formula: treat ~ X1 + X2
strata_match(a.strat, model = treat ~ X1 + X2, k = 1)
# full match within strata based on mahalanobis distance.
strata_match(a.strat, model = treat ~ X1 + X2, method = "mahal", k = 1)

raikens1/stratamatch documentation built on May 27, 2021, 10:13 p.m.