1、有序分类资料的统计分析Stata实现第十二章有序分类资料的统计分析的Stata实现本章使用的STATA命令:列变量有序时的分类资料CMH卡方分析opartchi 行变量 weight, by(列变量)(见Stata7附加程序)双向有序时的Spearman相关spearman 变量1 变量2例12-2 某研究欲观察人参的镇静作用,选取32只同批次的小白鼠,将其中20只随机分配到人参组:以5%人参浸液对其做腹腔注射,12只分配到对照组:以等量蒸馏水对其做同样注射。实验结果如表12-2所示。能否说明人参有镇静作用?表12-2 人参镇静作用的实验结果镇静等级人参组对照组- 411 1 0+ 2 1+
2、1 0+12 0 1建立检验假设,确定检验水准。:人参没有镇静作用(样本来自两个相同总体):人参有镇静作用(样本来自两个不同总体) Stata数据为:abx11412113214115122111220231240250Stata命令为:opartchi b weight=x,by(a)结果为: Chi-square tests df Chi-square P-value Independence 4 16.64 0.0023 - Components of independence test Location 1 15.29 0.0001 Dispersion 1 .3496 0.5543
3、在的水平上,拒绝,接受H1,认为两总体之间的差别有统计学意义,可以认为人参组和对照组镇静等级的差别有统计学意义,人参有镇静作用。例12-3 试根据表12-4的资料,检验针刺不同穴位的镇痛效果有无差别? 表12-4 针刺不同穴位的镇痛效果穴位镇痛效果合谷38441224足三里53292816扶突47231933 1建立检验假设,确定检验水准。:三个穴位的镇痛效果相同:三个穴位的镇痛效果不全相同Stata数据为:groupeffectw113812441312142421532229232824163147322333193433Stata命令为:opartchi effect weight=w,
4、by(group)结果为: Chi-square tests df Chi-square P-value Independence 6 22.07 0.0012 - Components of independence test Location 2 3.118 0.2103 Dispersion 2 5.914 0.0520 有。在的水平上尚不能拒绝,即根据本例资料尚不能认为针刺不同穴位的镇痛效果差别有统计学意义。例12-4 两名放射科医师对13张肺部X线片各自做出评定,评定方法是将X线片按病情严重程度给出等级,结果如表12-6所示。问他们的评定结果是否相关。表12-6 两名放射科医师对13
5、张肺部X片的评定结果X片编号12345678910111213甲医师X+ +乙医师Y + +1建立检验假设,确定检验水准。:0(两名医师的等级评定结果不相关):(两名医师的等级评定结果相关)Stata数据为:ixy1212333024125006237348439341044110112331323Stata命令为:spearman y x结果为:Number of obs = 13Spearmans rho = 0.8082Test of Ho: y and x are independent Prob |t| = 0.0008Pchi2 = 0.1027Chi2(1) for trend
6、= 4.546, prchi2 = 0.0330Chi2(1) for departure = 0.004, prchi2 = 0.9467The “Chi2(1) for trend” is slightly different. Its 4.546 rather than 4.515. Well, ptrend is just using N rather than N 1 in the formula: Qtrend = Chi2(1) for trend = N * ray2Lets go back to data arranged for the corr computation a
7、nd show this. . quietly corr y a fw=weight . display r(N)*r(rho)24.5464579Qtrend is just Pearsons correlation again. A regression is performed here to compute the slope, and the test of slope = 0 is given by the Qtrend statistic. Well, we all know the relationship between Pearsons correlation and re
8、gressionthis is all this is. Qdeparture (=Chi2(1) for departure as Roystons output nicely labels it) is the statistic for the CochranArmitage test. But Qtrend and Qdeparture are usually performed at the same time, so lumping them together under the name “CochranArmitage” is sometimes loosely done. T
9、he null hypothesis for the CochranArmitage test is that the trend is linear, and the test is for “departures” from linearity; i.e., its simply a goodness-of-fit test for the linear model. Qs (or equivalently Qtrend) tests the null hypothesis of no association. Since its just a Pearsons correlation,
10、we know that its powerful against alternative hypotheses of monotonic trend, but its not at all powerful against curvilinear (or other) associations with a 0 linear component. Model itRich Goldstein recommended logistic regression. Regression is certainly a better context to understand what you are
11、doingrather than all these chi-squared tests that are simply Pearsons correlations or goodness-of-fit tests under another name. Since Pearsons correlation is equivalent to a regression of y on “a”, why not just do the regression . regress y a fw=weight Source | SS df MS Number of obs = 144 -+- F( 1,
12、 142) = 4.63 Model | .692624451 1 .692624451 Prob F = 0.0331 Residual | 21.2448755 142 .1496118 R-squared = 0.0316 -+- Adj R-squared = 0.0248 Total | 21.9375 143 .153409091 Root MSE = .3868 - y | Coef. Std. Err. t P|t| 95% Conf. Interval -+- a | .0955344 .0444011 2.15 0.033 .0077618 .183307 _cons |
13、-.0486823 .1144041 -0.43 0.671 -.2748375 .177473 -But recall that y is a 0/1 variable. Heck, wouldnt you be laughed at by your colleagues if you presented this result? Theyd say, “Dont ya know anything, you dummy, you should be using logit/probit for a 0/1 dependent variable!” But call these same re
14、sults a “chi-squared test for linear trend” and, oh wow, instant respectability. Your colleagues walk away thinking how smart you are and jealous about all those special statistical tests you know. I guess it sounds as if Im agreeing fully with Rich Goldsteins recommendation for logit (or probit, which
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1