clear clear mata set mem 100000 set more 1 program drop _all cap log close log using two_side_validate.log, replace program simpan, rclass version 10.1 drop _all set obs 5000 *generate three standard normal local i= 1 while `i'<=4 { gen x`i'=invnorm(uniform())*0.5 local i = `i'+1 } gen e= invnorm(uniform()) *generate outcome gen y=0.4+1*x1+0.6*e replace y=y*(y>0) replace y=y*(y<1)+(y>=1) drop e gen tren=int(_n/4+0.8) gen z1=x1*x2 gen country =round(_n*uniform()/4)+1 two_side y x1-x4 z1 country test x1=1, notest test x2=0, accumulate notest test x3=0, accumulate notest test x4=0, accumulate notest test z1=0, accumulate return scalar c1=r(chi2) return scalar p1=r(p) test x1=1, notest test x2=-0.05, accumulate notest test x3=0, accumulate notest test x4=0, accumulate notest test z1=0, accumulate return scalar c2=r(chi2) return scalar p2=r(p) test x1=1.05, notest test x2=-0.05, accumulate notest test x3=0.05, accumulate notest test x4=0.05, accumulate notest test z1=0.05, accumulate return scalar c3=r(chi2) return scalar p3=r(p) end set seed 3394873 timer clear 1 timer on 1 simulate c1=r(c1) p1=r(p1) c2=r(c2) p2=r(p2) c3=r(c3) p3=r(p3) , reps(100) nodots saving(simres, replace): simpan timer off 1 timer list 1 summ qchi c1, df(5) graph export c1.wmf, as(wmf) replace quantile p1 graph export p1.wmf, as(wmf) replace qchi c2, df(5) graph export c2.wmf, as(wmf) replace quantile p2 graph export p2.wmf, as(wmf) replace qchi c3, df(5) graph export c3.wmf, as(wmf) replace quantile p3 graph export p3.wmf, as(wmf) replace