Hi,
I want to randomly assign treatment and run the same regression in the loop for 50 times and then I want to see how many times my variable of interest (POST) is significant. It's better if I can store the estimate with the p-value (or in a star representation). I tried the following. Where am I going wrong? Any help is appreciated.
drop post
drop random
foreach i of numlist 1/50 {
generate random=uniform()
sort random
generate post=0
replace post=1 in 1/50
tsset id year
set matsize 800
set more off
reg agriculture post i.country_id i.year i.country#c.line_time_trend [aw=ypop], cluster( country_id )
est sto b_1
esttab b_1,keep( post ) se star(* 0.10 ** 0.05 *** 0.001)
est clear //estimates clear
matrix p = J(`post',1,.)
matrix rownames p = `y'
matrix colnames p = "p"
matlist p
// for the computation of the p-values
local i = 1
foreach var of local y {
reg `var' post
matrix p[`i++',1] = 2*ttail(e(df_r), abs(_b[post]/_se[post]))
}
//
matlist p
}
0 Response to random treatment,50 times loop and store the estimate with p value for the variable of interest (POST) and display.
Post a Comment