Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missings in the stratifying variables #4

Open
pumilumi opened this issue Oct 27, 2021 · 0 comments
Open

Missings in the stratifying variables #4

pumilumi opened this issue Oct 27, 2021 · 0 comments

Comments

@pumilumi
Copy link

I have been using randtreat to assign treatment in RCTs (thanks!) and have a question on how randtreat handles observations that have missings in some of the variables listed in strata().

I bumped into this conundrum: if one of the stratifying variables has some missings, randtreat assigns treatment to those observations (it looks like it pools all observations that have a missing in any of the stratifying variables in one strata and randomizes within). The problem is, although I stratified by sex, I end up getting a strata of missings that contains both women and men. In other words, it assigned treatment to observations that had missing in some of the stratifying variables.

A minimal working example:


//The problem is, although I stratified by sex, I have a strata that contains both women and men.

sysuse bpwide, clear

//In this example, I want to create agegrp-sex strata. I force some observations to have missing in the agregrp or sex.

* I set missing observations in the two stratifying variables

replace agegrp = . if agegrp == 1 & bp_before < 152

replace sex = . if bp_before == 149 

*assign treatment
randtreat, generate(treatment) replace strata(sex agegrp)

*create a strata variable so I can tabulate the stratifying variables against the groups
egen strata = group(sex agegrp)

tab sex treatment if strata == .

*I observe that the missing strata contains and has assigned treatment to both men and women

Any insight is highly appreciated! Pumi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant