|
下面用R语言实现上面的检验:
> x=c(1,9,11,3)
> alle<-matrix(x, nrow=2)
> fisher.test(alle,alternative ="two.sided")
Fisher's Exact Test for Count Data
data: alle
p-value = 0.002759
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.0006438284 0.4258840381
sample estimates:
odds ratio
0.03723312
通过> help(fisher.test) 来查看使用说明,alternative = "two.sided"是双侧检验,可以根据说明进行调整为单侧'"greater"' or '"less"'.
fisher.test package:stats R Documentation
Fisher's Exact Test for Count Data
Description:
Performs Fisher's 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)
Arguments:
x: either a two-dimensional contingency table in matrix form, or
a factor object.
y: a factor object; ignored if 'x' is a matrix.
|
|