同一题,计算1:1配对资料的卡方值时候R语言程序及结果
> y<-c(1287,61,7,2)
> cc<-matrix(y,nrow = 2,ncol = 2)
> cc
[,1] [,2]
[1,] 1287 7
[2,] 61 2
> mcnemar.test(cc)
McNemar's Chi-squared test with continuity
correction
data: cc
McNemar's chi-squared = 41.309, df = 1, p-value =
1.3e-10
SAS程序及结果
data ex3;
do r=1 to 2;
do c=1 to 2;
input f@@;
output;end;end;
cards;
1287 7 61 2
;
proc freq;
tables r*c/chisq expected nopercent
nocol agree;
weight f;
run;
McNemar 检验
---------------------
统计量 (S) 42.8824
自由度 1
Pr > S <.0001
手工计算与SAS结果一致,求老司机解答,是否我R程序出错了?