Difference between revisions of "Randomization in Stata"
Mrijanrimal (talk | contribs) |
Mrijanrimal (talk | contribs) |
||
Line 19: | Line 19: | ||
The end goal is to have a CSV format file containing the ID variable used for randomization and the categorical variables created from the random numbers generated. This dataset will be preloaded into SurveyCTO, so that after an enumerator enters the respondent ID at the start of a survey, the result of the randomization will be loaded for the form and can be used for various sections of the survey. | The end goal is to have a CSV format file containing the ID variable used for randomization and the categorical variables created from the random numbers generated. This dataset will be preloaded into SurveyCTO, so that after an enumerator enters the respondent ID at the start of a survey, the result of the randomization will be loaded for the form and can be used for various sections of the survey. | ||
== Randomization with Stratification in Stata == | |||
The steps to randomize in Stata with stratification is as follows: | |||
== Back to Parent == | == Back to Parent == |
Revision as of 20:24, 31 January 2017
Randomization using Stata is usually the more preferred option compared to randomizing using Excel or the CAPI software itself.
Why use Stata to randomize
Using Stata to randomize and then preloading the generated data file into the survey software is the better option among the two. The main advantages of using Stata during randomization are as follows:
- Randomization in Stata is transparent and reproducible which is important for publishing research.
- Randomization in Stata is done before the survey takes place. This provides an opportunity to double check the result of a randomization and fix bugs before using the software in the field.
- Randomization in Stata provides the option of ensuring balance in the dataset i.e. it helps the researcher randomize while preserving the overall demographic/characteristic balances.
Steps needed for replicability when randomizing in Stata
Here are a few steps that should be followed to create a reproducible randomization using Stata:
- Use a dataset which has a unique ID [respondent ID, household number, etc.]
- While writing a do-file, pay close attention to the following things:
- Set version. Setting Stata's version in a do file ensures that the randomization algorithm is the same, as the alrogirthm sometimes changes between Stata versions.
For example -version 12.0
- Set seed. This makes sure that the same random number is generated for the first observation, for the second observation, and so on, for every time the code is run.
For example -set seed 12345
- Properly sorting the data. The data should be sorted such that observations are in the same order every time the code is run. The most optimal situation is sorting using an ID variable which uniquely and fully identifies each observation.
- Set version. Setting Stata's version in a do file ensures that the randomization algorithm is the same, as the alrogirthm sometimes changes between Stata versions.
- Convert the random numbers into categorical variables or dummy variables. This helps you check if the data is balanced.
The end goal is to have a CSV format file containing the ID variable used for randomization and the categorical variables created from the random numbers generated. This dataset will be preloaded into SurveyCTO, so that after an enumerator enters the respondent ID at the start of a survey, the result of the randomization will be loaded for the form and can be used for various sections of the survey.
Randomization with Stratification in Stata
The steps to randomize in Stata with stratification is as follows:
Back to Parent
This article is part of the topic Randomized Control Trials