标题: 请问如何求两组率的差值的可信区间? [打印本页] 作者: shiyiming 时间: 2010-1-7 12:22 标题: 请问如何求两组率的差值的可信区间? 假设A组有403人 有效率为百分之33% B组有401人 有效率为38% 求两组率的差值5%的可信区间~ 没找到现成的公式 求算法 谢谢各位了作者: shiyiming 时间: 2010-1-7 12:34 标题: Re: 请问如何求两组率的差值的可信区间? 确实没辙耶!
哪位,嘿,大哥能拿个可行性方案出来?作者: shiyiming 时间: 2010-1-7 23:01 标题: Re: 请问如何求两组率的差值的可信区间? 很简单的问题,教科书上有公式.两大样本率的Z检验的合并标准误算出+-1.96倍就行了.
也可以用 (p1-p2)+-1.96*sqrt(p1(1-p1)/n1+p2(1-p2)/n2)作者: shiyiming 时间: 2010-1-7 23:40 标题: Re: 请问如何求两组率的差值的可信区间? 楼上正确。
[code:1ein6bnj]data _null_;
input pa na pb nb;
dif_p = pb-pa;
sigma = sqrt(pa*(1-pa)/na+pb*(1-pb)/nb);
z = dif_p/sigma;
p = 1-probnorm(z);
_95LCI = dif_p-1.96*sigma;
_95UCI =dif_p+1.96*sigma;
format pa pb dif_p percent6. p pvalue6.4 _95LCI _95UCI percentn7.1;
putlog @2 'Group A:' @20 'Proportion = ' pa @40 'sample = ' na;
putlog @2 'Group B:' @20 'Proportion = ' pb @40 'sample = ' nb;
putlog @2 'Between A and B: ' @20'Difference[95% CI] = ' dif_p '[' _95LCI',' _95UCI']' ' p value = ' p;
if p < 0.05 then put @2 ' Conclusion: the difference in proportion between A and B is not significant at 5% level';
else put @2 'Conclusion: the difference in proportion between A and B is significant at 5% level';
cards;
0.33 403 0.38 401
; [/code:1ein6bnj]作者: shiyiming 时间: 2010-1-8 00:08 标题: Re: 请问如何求两组率的差值的可信区间? I am wondering how come SAS did not provide two-independent sample proportion test or just I don't know it. some thoughts here:
[code:2iuauos8]data a;
input trt $ y p n;
ny = round(p*n);
datalines;
a 1 0.33 403
a 0 0.67 403
b 1 0.38 401
b 0 0.62 401
;
proc ttest data = a;
class trt;
var y;
freq ny;
run;[/code:2iuauos8]
Here a little trouble is the test p value for the difference using T test rather than normal test we want while the confidence interval is Okay.
*****JingJu*****作者: shiyiming 时间: 2010-1-8 11:02 标题: Re: 请问如何求两组率的差值的可信区间? 谢谢各位 我在一本别的书上找到了公式,用SAS简单的编了下 是没有各位编的好了 呵呵!作者: shiyiming 时间: 2010-1-8 11:06 标题: Re: 请问如何求两组率的差值的可信区间? SAS里我也不知道有直接对两组率比较的程序 不过U检验的公式不算复杂 自己编个~~~嘿嘿