help stratarandVersion 0.2.0

Title

stratarand -- This function performs stratified random assignment for equal and unequally sized treatment groups.

Syntax

stratarand ,
gentreat(treatvar)
strata(strata)
[conditionsnumber(num)
replace
group_percentages(num)
exact]

Description

stratarand -- This function randomly assigns observations to experimental groups for each stratum. Within each stratum, this function
first randomly selects which experimental group to start the random assignment. Then, if the treatment groups are equally-sized, the random assignment
alternates through all possible treatment groups. If the treatments groups are not equally sized, the function assigns blocks of observations to a
given treatment condition based on the percentage of observations.

NOTE: This function will re-sort your dataset. Please set seed and set sortseed before this
function is run to ensure replicability.

Options

gentreat(treatvar) what the resulting treatment variable should be called

replace if a variable with the same name as treatvar already exists, it should be dropped and replaced with treatvar

strata(strata) name of the strata variable

conditionsnumber(num) number of conditions of equally sized treatment groups; either this option or group_percentages(num) must be specified

group_percentages(num) the percentage of observations assigned to each treatment condition (e.g., .1 .4 .5); either this option or conditionsnumber(num) must be specified

exact this option is only relevant when group_percentages(num) is specified. Since percentages of observations may result in a rounding error, exact specifies that observations that
did not receive a treatment assignment due to rounding error are randomly assigned to one of the remaining treatment conditions. This option is only useful when there is a large number of strata.

Examples

. stratarand, gentreat(condition) strata(congressionaldistrict) group_percentages(.2 .3 .5)

. stratarand, gentreat(condition) strata(congressionaldistrict) group_percentages(.2 .3 .5) exact replace

. stratarand, gentreat(condition) strata(congressionaldistrict) conditionsnumber(3)

Author

John Ternovski

S3 Lab

Harvard University

john_ternovski@hks.harvard.edu