Thursday, December 20, 2018

Randomly select control variables and perform 100 regressions?

I have a treatment group of 100 observations and a control group of 100,000 observations. I need to randomly draw 1,000 control observations and use those observations as controls in my regression. I need to repeat this 100 times and collect the beta and SEs for each. I've written the following code:

Code:
program define myprog
use "table.dta", clear
sample 1000 if treat == 0, count
logit y treat x2 x3 x4
end

set seed 1234
simulate _b[treat] _se[treat], reps(100): myprog

gen t_treat = _sim_1/_sim_2
gen p_treat = 2*(1-normal(abs(t_treat)))
The code appears to work, but is it doing what I want? I tested it by manually running myprog once myself (after I made sure to set seed 1234) and comparing it to the output of the first rep of simulate. Beta and SE don't match. Any idea what is going on?

No comments:

Post a Comment