manual_stratify: Manual Stratify

View source: R/manual_stratify.R

manual_stratifyR Documentation

Manual Stratify

Description

Stratifies a data set based on a set of blocking covariates specified by the user. Creates a manual_strata object, which can be passed to strata_match for stratified matching or unpacked by the user to be matched by some other means.

Usage

manual_stratify(data, strata_formula, force = FALSE)

Arguments

data

data.frame with observations as rows, features as columns

strata_formula

the formula to be used for stratification. (e.g. treat ~ X1) the variable on the left is taken to be the name of the treatment assignment column, and the variables on the left are taken to be the variables by which the data should be stratified

force

a boolean. If true, run even if a variable appears continuous. (default = FALSE)

Value

Returns a manual_strata object. This contains:

  • treat - a string giving the name of the column encoding treatment assignment

  • covariates - a character vector with the names of the categorical columns on which the data were stratified

  • analysis_set - the data set with strata assignments

  • call - the call to manual_stratify used to generate this object

  • issue_table - a table of each stratum and potential issues of size and treat:control balance. In small or imbalanced strata, it may be difficult or infeasible to find high-quality matches, while very large strata may be computationally intensive to match.

  • strata_table - a table of each stratum and the covariate bin to which it corresponds

See Also

auto_stratify, new_manual_strata

Examples

# make sample data set
dat <- make_sample_data(n = 75)

# stratify based on B1 and B2
m.strat <- manual_stratify(dat, treat ~ B1 + B2)

# diagnostic plot
plot(m.strat)

stratamatch documentation built on March 31, 2022, 9:07 a.m.