RCT helps you focus on the statistics of the randomized controltrials, rather than the heavy programming lifting. Any social scientistshould use RCT when conducting Field Experiments.
RCT helps you in the whole process of designing and evaluating aRCT.
Let the steps of the design be a RCT:
This library has a function calledsummary_statistics to know the distribution of allcovariates in data.
The functiontau_min calculates the minimumdetectable treatment effect given power, significance level, outcomevariable and number of observations. This function computes this for anyshare of control observations.
The functionN_min calculates the minimum populationneeded to identify a target tau_min
Prior to random assignment, one has to decide whichcategorical variables to build blocks. Hence, theblocks or strata are the group that combine every categorical variable.The cardinality of this groups are all the possible combinations of thechose categorical variables.
To build categorical variables in a powerful way, functionn_tile_label divides variables in the decided n groups,putting label of the range of each category to the variable.
Once we have the blocking variables, we need to assign treatmentstatuswithin each strata. Function treatment_assignperforms such random assignment for any given number of treatmentgroups. Furthermore, it handles misfits.
Misfits are defined as observations within each strata that are notreally randomly assigned because when dividing the size of each strataN_strata to each treatment share, there are some remainderobservations.
For instance, let the following example:
N_strata = 10 share_control =
First 3 units are assigned to control, second 3 units are assigned totreat 1 and the last 3 unit are assigned to treat 2. As you alreadynotice, the last observation is the remainder. This is a misfit. Misfitsalter the successful random assignment because they are not. In theexample, this observation is assigned to treat 2 non-randomly.
The functiontreatment_assign handles misfits inthree ways.
“NA” assigns the misfits to NAs, leaving the experiment with onlythe pure assigned observations.
“global” puts together the misfits of each strata into a singlegroup and then assigns them randomly
“strata” assigns misfits to treatment within each strata
After running a RCT, the social scientist wants to know the ATE forone or several variables and the distribution of this impact within theblocking variables to check for Heterogenous Treatment Effects.Additionally, if the experiment lasted for more than one period andpanel-data is available, one must cluster the standard errors by each iunit and control for period fixed effects. Finally, if by chance one omore covariates are not balance, one would like to control for them.
Functionimpact_eval does all this jobs in onesingle command. It runs all the ATE regressions for each endogenousvariable, all the combinations of endogenous variables*heterogenousvariables.
For each combination the model run is:
\[Y_i = \alpha + \tau treatment + \epsilon\]