299.multiple comparisons or tests on subtables
(2014-07-15 06:14:28)
标签:
multiple-testproportionsfreqmultitestcall-execute |
分类: 统计分享 |
Sometimes we need to do pairwise analyses on the proportions for a
combination of subgroups. Here lists an example of performing
Pearson Chi-Square tests
In the following example, we want to test the age effect, probably the association more exactly, on/with different types of syncope. The data was seen http://bbs.pinggu.org/thread-3128460-1-1.html.
proc format;
value agefmt
Remember FORMAT should always go to output to enhance data's readability.
1='<=20'
2='21-40'
3='41-60'
4='>=60'
;
run;
data x;
input
age
lines;
1 14 3
2 10 12 29
3 37 20 50
4 14 1
;
The global Chi-Sq test has shown
proc freq data=x order=internal;
Statistic |
DF |
Value |
Prob |
Chi-Square |
6 |
15.6447 |
0.0158 |
Likelihood Ratio Chi-Square |
6 |
16.4677 |
0.0115 |
Mantel-Haenszel Chi-Square |
1 |
1.4303 |
0.2317 |
Phi Coefficient |
|
0.2673 |
|
Contingency Coefficient |
|
0.2582 |
|
Cramer's V |
|
0.1890 |
|
Fisher's Exact Test |
|
Table Probability (P) |
2.060E-08 |
Pr <= P |
0.0169 |
We are looking into the tests of proportions on pairwise
subgroups.
%macro freqfit(ageL,ageR);
Using WHERE- to subset the sample
%mend freqFit;
This SQL code is to form all the combinations of
the
proc sql;
quit;
data _null_;
Why I rename prob = raw_p? The reason is that 'raw_p' is a reserved variable name for the input data set to MULTTEST procedure.
THE code for execute function is very readable in SAS log window. That is why sometimes I prefer this function rather than macro-looping.
Since more than two subgroups
ods output pvalues =pvs;
proc multtest inpvalues=chisq bon holm hoc fdr;
run;
data xx;
pairs |
ChiSq |
Raw_P |
Bonferroni |
|
1 |
<=20 vs. 21-40 |
5.5666 |
0.0618 |
0.3710 |
2 |
<=20 vs. 41-60 |
2.5187 |
0.2838 |
1.0000 |
3 |
<=20 vs. >=60 |
3.3411 |
0.1881 |
1.0000 |
4 |
21-40 vs. 41-60 |
3.7110 |
0.1564 |
0.9383 |
5 |
21-40 vs. >=60 |
13.1866 |
0.0014 |
0.0082 |
6 |
41-60 vs. >=60 |
6.3519 |
0.0418 |
0.2505 |
Here comes the summary of the pairwise Chi-Sq
tests for each combination of age groups. The raw p values give two
significant groups; while considering multiple
comparison,