Learn R Programming

natstrat

Natural strata can be used in observational studies to balance the distributions of many covariates across any number of treatment groups and any number of comparisons. These strata have proportional amounts of units within each stratum across the treatments, allowing for simple interpretation and aggregation across strata. Within each stratum, the units are chosen using randomized rounding of a linear program that balances many covariates.

Installation

You can install the released version from CRAN with:

install.packages("natstrat")

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("kkbrum/natstrat", build_vignettes = TRUE)

Usage

To learn about how to use this package, please see the associated vignette with:

browseVignettes(package = "natstrat")

Copy Link

Version

Install

install.packages('natstrat')

Monthly Downloads

78

Version

2.0.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Katherine Brumberg

Last Published

February 3rd, 2026

Functions in natstrat (2.0.1)

verify_inputs_EMD

Verify the inputs to the earthmover's distance problem
verify_multi_comp_inputs

Verify the inputs for supplemental comparisons to optimize_controls()
create_balance_matrices

Create matrix of balance constraints for linear program
generate_qs

Calculate desired number of controls per stratum
create_dist_matrix

Create matrix of distances between strata
generate_constraints

Generate constraints to encourage covariate balance
check_balance

Check covariate balance of the control and treated groups
optimize_controls

Select control units that optimize covariate balance
stand

Standardize covariate vector for balance constraint
plot_stand_diffs

Plot standardized differences in means
get_stand_diffs

Calculate standardized differences
balance_LP

Linear program that selects which controls to use in order to optimize balance
nh0506_3groups

Homocysteine and smoking example data with multiple control groups
nh0506

Homocysteine and smoking example data
presolve_EMD

Solve the earthmover's distance problem
randomized_rounding_expectation

Sample integer solution from linear programming solution with sample sizes correct in expectation
parse_formula

Parse the nonstandard balance formulas
natstrat-package

natstrat: Obtain Unweighted Natural Strata that Balance Many Covariates
verify_inputs

Verify the inputs to optimize_controls()
process_qs

Process the desired sample sizes for optimize_controls()
randomized_rounding

Sample integer solution from linear programming solution with correct sample sizes