BR003
Stata 11 Stata ROC whitepaper mwp anova/oneway 3 mwp-042 kwallis Kruskal Wallis 28 mwp-045 ranksum/median / 31 mwp-047 roctab/roccomp ROC 34 mwp-050 sampsi 47 mwp-044 sdtest 54 mwp-043 signrank/signtest / 61 mwp-046 sktest / 65 mwp-048 swilk/sfrancia 67 mwp-049 ttest 70 mwp-041 StataCorp c 2011 Math c 2011 StataCorp LP Math web: www.math-koubou.jp email: master@math-koubou.jp
mwp-042 anova/oneway - anova oneway ANOVA 1. 2. 3. ANOVA oneway 4. ANOVA anova 5. 6. ANOVA 7. ANOVA 8. ANOVA 1. 2 t mwp-041 3 A, B, C t α 5% (1) A-B = 0.95 (2) A-C = 0.95 (3) B-C = 0.95 3 0.95 3 = 0.86 (1), (2), (3) 1 0.86 = 0.14 1 5% c Copyright Math c Copyright StataCorp LP (used with permission) 3
3 (ANOVA: analysis of variance) F (multiple comparison) 2. (1) (2) (3) (4) (repeated-measures) ANOVA 3. ANOVA oneway (factor) 1 ANOVA (one-way ANOVA) ANOVA anova, oneway oneway anova1.dta. use http://www.math-koubou.jp/stata/data11/anova1.dta, clear 24 (blood pressure). list if n <= 3 n >= 22, separator(3) * 1 bp drug 1. 126 1 2. 121 1 3. 115 1 22. 137 4 23. 139 4 24. 123 4 drug 1, 2, 3, 4 4 drug *2 *1 Data Describe data List data *2 Stata 4
drug bp 1 126 121 115 123 125 113 120.5 2 112 123 115 129 106 108 115.5 3 123 112 133 124 130 121 123.8 4 122 132 125 137 139 123 129.7 oneway α 5% Statistics Linear models and related ANOVA/MANOVA One-way ANOVA Main : Response variable: bp Factor variable: drug Multiple-comparison tests: Bonferroni Output: Produce summary table: 1 oneway - Main 5
. oneway bp drug, bonferroni tabulate Summary of bp drug Mean Std. Dev. Freq. 1 120.5 5.3572381 6 2 115.5 8.9162773 6 3 123.83333 7.3598007 6 4 129.66667 7.3665913 6 Total 122.375 8.6467511 24 Analysis of Variance Source SS df MS F Prob > F Between groups 636.458333 3 212.152778 3.92 0.0237 Within groups 1083.16667 20 54.1583333 Total 1719.625 23 74.7663043 Bartlett's test for equal variances: chi2(3) = 1.1493 Prob>chi2 = 0.765 Comparison of bp by drug (Bonferroni) Row Mean Col Mean 1 2 3 2 5 1.000 3 3.33333 8.33333 1.000 0.383 4 9.16667 14.1667 5.83333 0.260 0.020 1.000 (1) ANOVA tabulate (frequency) 6 oneway anova (unbalanced data) ANOVA Analysis of Variance Source SS df MS F Prob > F Between groups 636.458333 3 212.152778 3.92 0.0237 Within groups 1083.16667 20 54.1583333 Total 1719.625 23 74.7663043 Bartlett's test for equal variances: chi2(3) = 1.1493 Prob>chi2 = 0.765 6
SS (sum of squares) regress mwp-037 y (yi ȳ) 2 = (y i ŷ i ) 2 + (ŷ i ȳ) 2 (yi ȳ) 2 TSS (total sum of squares) (ŷi ȳ) 2 MSS (model sum of squares) (yi ŷ i ) 2 RSS (residual sum of squares) MSS (between groups) 636.46 RSS (within groups) 1083.17 TSS (total) 1719.63 (df: degrees of freedom) MS (mean square) 212.15, 54.16 F 212.15/54.16 = 3.92 F F p 0.0237 p < 0.05 ANOVA Bartlett ANOVA p 0.05 (2) ANOVA µ 1 = µ 2 = µ 3 = µ 4 bonferroni Bonferroni ANOVA Comparison of bp by drug (Bonferroni) Row Mean Col Mean 1 2 3 2 5 1.000 3 3.33333 8.33333 1.000 0.383 4 9.16667 14.1667 5.83333 0.260 0.020 1.000 M ij M ij µ i µ j 0 Bonferroni p µ 4 µ 2 Bonferroni Scheffe, Šidák 7
4. ANOVA anova 5. 6. ANOVA 7. ANOVA 8. ANOVA ANOVA 8
mwp-050 roc - ROC roc ROC roc roctab ROC roccomp AUC rocgold AUC 1. ROC AUC 2. roctab 3. roccomp 3.1 3.2 4. rocgold 1. ROC AUC (ROC: receiver operating characteristic) / 2 roctab ROC (AUC: area under the curve) ROC AUC roc01.dta. use http://www.math-koubou.jp/stata/data11/roc01.dta 100 10 c Copyright Math c Copyright StataCorp LP (used with permission) 9
. list in 1/10 * 1 disease rating 1. 1 4 2. 1 4 3. 0 1 4. 1 5 5. 0 2 6. 0 1 7. 1 5 8. 0 1 9. 0 4 10. 1 5 ROC refvar classvar 2 refvar (observation) / 0/1 0 1 roc01.dta disease refvar classvar roc01.dta rating classvar 1, 2, 3, 4, 5 5 1 5 5 rating 2 2 4 rating 2 rating4. generate rating4 = rating >= 4 * 2 rating >= 4 generate rating4 { rating4 = 0 if rating < 4 rating4 = 1 if rating 4 rating4 disease. tabulate rating4 disease, column * 3 *1 Data Describe data List data *2 Data Create or change data Create new variable *3 Statistics Summaries, tables, and tests Tables Two-way tables with measures of association 10
. tabulate rating4 disease, column Key frequency column percentage disease rating4 0 1 Total 0 44 11 55 91.67 21.15 55.00 1 4 41 45 8.33 78.85 45.00 Total 48 52 100 100.00 100.00 100.00 (frequency) (sensitivity) (specificity) 4 { = 78.85% = 91.67% (, ) 2 ROC 11
x (1 ) AUC 2. roctab 1 (1) 2 (2) (3) roctab ROC AUC (1) (2) (3) ROC (2) 6 (, ) 2 ROC roctab Statistics Epidemiology and related ROC analysis Nonparametric ROC analysis Main : Reference variable: disease Classification variable: rating Graph the ROC curve: Report the area under the ROC curve:. roctab disease rating, graph summary ROC Asymptotic Normal Obs Area Std. Err. [95% Conf. Interval] 100 0.9125 0.0290 0.85562 0.96930 12
AUC summary 95% CI 3. roccomp roccomp AUC (1) ROC (2) ROC 2 (1) wide (2) long wide, long [D] reshape (mwp-036 ) 3.1 3.2 4. rocgold 13