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
}
Related Posts with random treatment,50 times loop and store the estimate with p value for the variable of interest (POST) and display.
Treatment Variation PlotHello Statalist! I was wondering if it would be possible for Stata to plot this kind of variation f…
Create a matrix or data set from current variables in stataHi everyone! I have a dataset with three variables: province_code (11 province codes), newnsector (…
double-hurdle model not feasibleHi, I'm using a panel double-hurdle model using Code: xtdhreg command. But I get the following err…
How I find the wrong data?Dear Statalist, I have the note: multiple positive outcomes within groups encountered, followed by c…
Create Twoway Line Graph Forcing Gaps for Missing PeriodsHi all, My data: Code: input float(Datum_n total_unem_bymonth sum_newpositions_bymonth) 723 14824…
Subscribe to:
Post Comments (Atom)
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