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.
Pseudo R2 for logit and mlogit in multiple imputationHello, I am using multiple imputation and survey data with a logit model and would like to calculat…
Mediation Analysis using medsensHi everyone, I am currently doing an mediation analysis using medsens. I think it is a user-written…
merging datasets only if two variables matchHi all, I need to merge two datasets, but only if two variables from both dataset match. First data…
RD Plot with Evenly Spaced binsHi all, I am trying to run RDplot while choosing my number of evenly spaced bins. If I want to have …
Formatting dates correctly and calculating age from two datesHello, I'm sure someone has posted about this on the forum before but I can't find the exact answer…
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