___ ____ ____ ____ ____ (R) /__ / ____/ / ____/ ___/ / /___/ / /___/ 14.0 Copyright 1985-2015 StataCorp LP Statistics/Data Analysis StataCorp 4905 Lakeway Drive MP - Parallel Edition College Station, Texas 77845 USA 800-STATA-PC http://www.stata.com 979-696-4600 stata@stata.com 979-696-4601 (fax) 5-user 16-core Stata network license expires 23 Oct 2016: Serial number: 501409202298 Licensed to: Social Science Computing Cooperative University of Wisconsin-Madison Notes: 1. Stata is running in batch mode. 2. Unicode is supported; see help unicode_advice. 3. More than 2 billion observations are allowed; see help obs_advice. 4. Maximum number of variables is set to 5000; see help set_maxvar. . do kwmcchisq.do . // Chi-square, df=3, non-central . twoway (function y=chi2den(3,x), range(0 4)) /// > (function y=nchi2den(3,0.5^2,x), range(0 4)) /// > (function y=nchi2den(3,1^2,x), range(0 4)), title("Chisquare, d = 0.5 > ") . . postfile kwpower test d T dfm dfr using kwpowermcchi.dta, replace (note: file kwpowermcchi.dta not found) . quietly forvalues d=0(0.1)1 { difference 0 difference .1 difference .2 difference .3 difference .4 difference .5 difference .6 difference .7 difference .8 difference .9 difference 1 . postclose kwpower . . use kwpowermcchi.dta, clear . . generate sig = Ftail(dfm, dfr, T)<0.05 if test==1 (27,500 missing values generated) . replace sig = chi2tail(dfm, T)<0.05 if test==2 (27,500 real changes made) . bysort test: tabulate d sig, row ------------------------------------------------------------------------------- -> test = 1 +----------------+ | Key | |----------------| | frequency | | row percentage | +----------------+ | sig d | 0 1 | Total -----------+----------------------+---------- 0 | 2,381 119 | 2,500 | 95.24 4.76 | 100.00 -----------+----------------------+---------- .1 | 2,365 135 | 2,500 | 94.60 5.40 | 100.00 -----------+----------------------+---------- .2 | 2,323 177 | 2,500 | 92.92 7.08 | 100.00 -----------+----------------------+---------- .3 | 2,084 416 | 2,500 | 83.36 16.64 | 100.00 -----------+----------------------+---------- .4 | 1,448 1,052 | 2,500 | 57.92 42.08 | 100.00 -----------+----------------------+---------- .5 | 637 1,863 | 2,500 | 25.48 74.52 | 100.00 -----------+----------------------+---------- .6 | 156 2,344 | 2,500 | 6.24 93.76 | 100.00 -----------+----------------------+---------- .7 | 19 2,481 | 2,500 | 0.76 99.24 | 100.00 -----------+----------------------+---------- .8 | 0 2,500 | 2,500 | 0.00 100.00 | 100.00 -----------+----------------------+---------- .9 | 0 2,500 | 2,500 | 0.00 100.00 | 100.00 -----------+----------------------+---------- 1 | 0 2,500 | 2,500 | 0.00 100.00 | 100.00 -----------+----------------------+---------- Total | 11,413 16,087 | 27,500 | 41.50 58.50 | 100.00 ------------------------------------------------------------------------------- -> test = 2 +----------------+ | Key | |----------------| | frequency | | row percentage | +----------------+ | sig d | 0 1 | Total -----------+----------------------+---------- 0 | 2,383 117 | 2,500 | 95.32 4.68 | 100.00 -----------+----------------------+---------- .1 | 2,364 136 | 2,500 | 94.56 5.44 | 100.00 -----------+----------------------+---------- .2 | 2,330 170 | 2,500 | 93.20 6.80 | 100.00 -----------+----------------------+---------- .3 | 2,114 386 | 2,500 | 84.56 15.44 | 100.00 -----------+----------------------+---------- .4 | 1,568 932 | 2,500 | 62.72 37.28 | 100.00 -----------+----------------------+---------- .5 | 736 1,764 | 2,500 | 29.44 70.56 | 100.00 -----------+----------------------+---------- .6 | 206 2,294 | 2,500 | 8.24 91.76 | 100.00 -----------+----------------------+---------- .7 | 22 2,478 | 2,500 | 0.88 99.12 | 100.00 -----------+----------------------+---------- .8 | 1 2,499 | 2,500 | 0.04 99.96 | 100.00 -----------+----------------------+---------- .9 | 0 2,500 | 2,500 | 0.00 100.00 | 100.00 -----------+----------------------+---------- 1 | 0 2,500 | 2,500 | 0.00 100.00 | 100.00 -----------+----------------------+---------- Total | 11,724 15,776 | 27,500 | 42.63 57.37 | 100.00 . . collapse (mean) sig, by(test d) . separate sig, by(test) storage display value variable name type format label variable label ------------------------------------------------------------------------------- sig1 float %9.0g sig, test == 1 sig2 float %9.0g sig, test == 2 . label variable sig1 "Anova" . label variable sig2 "Kruskal-Wallis" . save kwpowermcchi2table.dta, replace (note: file kwpowermcchi2table.dta not found) file kwpowermcchi2table.dta saved . line sig1 sig2 d, title("Chi-square, by MC") ytitle("Power") /// > xtitle("group differences") . end of do-file