SAS CMH检验

Table 控制变量*分组变量*分析变量 / CMH ;

 

 CMH用在调整某几个分层变量时非常强劲。CMH中的分析都是“计数”,通过数个数来计算的。所以会加在FREQ中。

 这的stratified factor只能是分类变量。

 举例:

 

data dat6;
do id = 1 to 2;
do r=1 to 4;
do c=1 to 4;
input freq @@;
output;
end;
end;
end;
datalines;
1 4 11 27 143 411
2 9 37 66 317 1183
3 3 39 84 22 182 355
2 147 94 41 139 160
1 6 11 27 143 411
2 2 37 66 317 1183
3 5 39 84 22 182 355
2 47 94 41 139 160
;

proc freq data=dat6;
tables id * r * c/nopct nocol norow chisq cmh;*Nonzero Correlation;*M-H;
weight freq;
run;

 

 

 

 

 

 

 第一个图是没加CMH,没有去除中心ID效应。第二个图是加了CMH,去掉了中心ID效应,卡方值变小。

  1. 当加了CMH,此时只看下图CMH中那三个统计量,不需要看上述的统计量。
  2. 上图中的M-H卡方统计量,只有在行列都有序的情况下才看。

 

 

 

1. 行列都有顺序。

 

 都是认为在行列都有顺序的情况下使用,一般情况下都是这么用。

*row and column are in order;
data dat6;
do r=1 to 4;
do c=1 to 4;
input freq @@;
output;
end;
end;
datalines;
4 11 143 411
9 37 317 1183
39 22 182 355
147 94 139 160
;
proc freq data=dat6;
tables r * c/nopct nocol norow chisq cmh;*Nonzero Correlation;*M-H;
weight freq;
run;

行和列都有序,也就是影响变量和反应变量都有序,看它们之间的相关性。看Non-zero Correlation, 也就是第一个。也就是非零相关。比如说服药量和红肿等级。只是说根据数类型据选取合适的统计方法。

这个就是卡方结果中的Mantel-Haenszel 卡方的,在不指定stratified factor时。

Spearman等级相关也是顺序资料,但Spearman等级相关计算时,是用等级进行的计算,而不是频数。

 

2. 行有序,就是影响变量有序

The two-level variable represents the response, and the other variable represents an explanatory variable with ordered levels

这是用trend选项实现Cochran-Armitage Test,限制是,反应变量是二分类变量。

 

*row is in order;
data dat5;
do r = 1 to 3;
do c = 1 to 2;
input freq @@;
output;
end;
end;
datalines;
59 25
169 29
196 9
;

proc freq data=dat5;
tables r * c/nopct chisq nocol trend cmh;
weight freq;
run;

 

 

 影响变量有序,说明随着影响变量的顺序,反应变量有某种趋势。加上trend。比如剂量和不良时间发生数,随着剂量增大,不良反应数减小。

 

3. 列有序,也就是反应变量有序。

 

 当只有一个层时,也就是没分层因素,基本就是方差分析。

如果有多个层,相当于分层方差分析或者K-W检验。

*column is in order;
data dat4;
do r=1 to 2;
do c=1 to 3;
input freq @@;
output;
end;
end;
datalines;
13 10 6
21 7 4
;
proc freq data=dat4;
tables r * c/nopct nocol chisq cmh;*row means score differ;
weight freq;
run;

列有序,选第二个row means score differ。说明在不同区间,反应有高有底。

如果指定 / score = rank。是Friedman检验,说明不同group间,反应是否不同。

 

4. 行列都无序

 

data dat3;
do r=1 to 3;
do c=1 to 4;
input freq @@;
output;
end;
end;
datalines;
112 150 205 40
200 112 135 73
362 219 310 69
;

proc freq data = dat3;
table r*c/chisq cmh NOROW NOCOL;*general association;
weight freq;
run;

行列都无序,选最后一个,general association常规关联。

 

 

 

 

posted @ 2021-11-12 19:03  Iving  阅读(4202)  评论(0编辑  收藏  举报