- 52
- 0
- 约 50页
- 2016-12-25 发布于重庆
- 举报
例5.13 P-value计算演示 ne=sqrt(500/45) r=ne+0.12+0.11/ne ra=r*0.23 y=2*c(exp(-2*ra*ra),-exp(-2*4*ra*ra),exp(-2*9*ra*ra),-exp(-2*16*ra*ra)) p=sum(y) P-value=0.5411246 单样本的p-value通过随机模拟,再拟合模拟结果得到, 以正态分布为例: 两个样本的K-S检验: 出自台湾静宜大学研究生徐碧君 [2] 上式为实验极限分布曲线。 R软件算法[3]: 例5.9正态检验的其他方法比较: x=c(25,45,50,54,55,61,64,68,72,75,75,78,79,81,83,84,84,84,85,86,86,86,87,89,89,89,90,91,91,92,100) ks.test(x,pnorm, mean(x), sd(x)) shapiro.test(x) Shapiro-Wilk normality test data: x W = 0.8633, p-value = 0.0009852 One-sample Kolmogorov-Smirnov test data: x D = 0.1952, p-value = 0.1883 alternative hypothesis: two-sided 注: 1.Kolmogorov-Smirnov检验可以用于小样本资料,Chi-square检验则会因样本小二产生问题; 2.在任何大小的样本里, Kolmogorov-Smirnov检验是比Chi-square检验还要有力的检验; 3.单样本KS检验适合连续型分布,不适合泊松分布,二项分布等离散分布检验; 5.3.3列联表数据的独立性检验 Pearson检验: 拒绝域: 例5.14 x=c(60,3,32,11) dim(x)=c(2,2) chisq.test(x,correct=FALSE) Pearsons Chi-squared test data: x X-squared = 9.6636, df = 1, p-value = 0.001880 吸烟与肺癌有关 Fisher精确的独立检验 适用小样本检验:n40 ; 或计算出 χ2值后所得的概率p≈α ; 某医师为研究乙肝免疫球蛋白预防胎儿宫内感染HBV的效果,将33例HBsAg阳性孕妇随机分为预防注射组合对照组,结果由表5.7所示,问两组新生儿的HBV总体感染率有无差别? Description Fishers Exact Test for Count Data Description Performs Fishers exact test for testing the null of independence of rows and columns in a contingency table with fixed marginals. Usage fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE, control = list(), or = 1, alternative = two.sided, conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE, B = 2000) x either a two-dimensional contingency table in matrix form, or a factor object. y a factor object; ignored if x is a matrix. For 2 by 2 cases, p-values are obtained directly using the (central or non-central) hypergeometric distribution. Otherwise, computations are based on a C version of the FORTRAN subroutine FEXACT which implements the network developed by Mehta and Patel (1986) and improved by Clarkson, Fan and Joe (1993). R实现: x=c(4,5,18,6) dim(x)=c(2,2) fisher.test(x) Fishers Exact Test for Count Data data: x p-value
原创力文档

文档评论(0)