stratify: Stratify a Population Data Frame

Description Usage Arguments Details Value References Examples

View source: R/stratify.R

Description

This function takes as input any data frame that you want to stratify into clusters. Typically, the goal of such stratification is sampling for generalizability. This function, and the others in this package, are designed to mimic the website https://www.thegeneralizer.org/.

Usage

1
stratify(data, guided = TRUE, n_strata = NULL, variables = NULL, idnum = NULL)

Arguments

data

The R object containing your population data frame

guided

logical; defaults to TRUE. Whether the function should be guided (ask questions and behave interactively throughout) or not. If set to FALSE, must provide values for other arguments below

n_strata

defaults to NULL. If guided is set to FALSE, must provide a number of strata to cluster population into

variables

defaults to NULL. If guided is set to FALSE, must provide a character vector of the names of stratifying variables (from population data frame)

idnum

defaults to NULL. If guided is set to FALSE, must provide a character vector of the name of the ID variable (from population data frame)

Details

The list contains 11 components: x2, solution, n_strata, recruitment_lists, population_summary_stats2, summary_stats, summary_stats2, heat_data, heat_plot_final, idnum, and variables.

Value

The function returns a list of class "generalizer_output" that can be provided as input to recruit(). More information on the components of this list can be found above under "Details."

References

Tipton, E. (2014). Stratified sampling using cluster analysis: A sample selection strategy for improved generalizations from experiments. Evaluation Review, 37(2), 109-139.

Tipton, E. (2014). How generalizable is your experiment? An index for comparing experimental samples and populations. Journal of Educational and Behavioral Statistics, 39(6), 478-501.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# To get sample data; must first be installed using install_github("katiecoburn/generalizeRdata")
library(generalizeRdata)

# Guided:
stratify(ipeds)

# Not guided:
stratify(ipeds, guided = FALSE, n_strata = 4,
   variables = c("pct_female", "pct_white"), idnum = "unitid")

## End(Not run)

katiecoburn/generalizeR documentation built on Oct. 28, 2020, 4:43 a.m.