r2dtable(stats)
r2dtable()所属R语言包:stats
Random 2-way Tables with Given Marginals
鉴于勉强随机2路表
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Generate random 2-way tables with given marginals using Patefield's algorithm.
给予勉强使用Patefield的算法生成随机2路表。
用法----------Usage----------
r2dtable(n, r, c)
参数----------Arguments----------
参数:n
a non-negative numeric giving the number of tables to be drawn.
一个非负的数字给表的数量要绘制。
参数:r
a non-negative vector of length at least 2 giving the row totals, to be coerced to integer. Must sum to the same as c.
非负向量的长度至少为2行总计,被强迫integer。必须总结的c一样。
参数:c
a non-negative vector of length at least 2 giving the column totals, to be coerced to integer.
给予非负向量的长度至少2列总数,被强迫integer。
值----------Value----------
A list of length n containing the generated tables as its components.
长度名单n包含生成的表作为其组成部分。
参考文献----------References----------
Algorithm AS159. An efficient method of generating r x c tables with given row and column totals. Applied Statistics 30, 91–97.
举例----------Examples----------
## Fisher's Tea Drinker data.[#费舍尔的茶饮数据。]
TeaTasting <-
matrix(c(3, 1, 1, 3),
nrow = 2,
dimnames = list(Guess = c("Milk", "Tea"),
Truth = c("Milk", "Tea")))
## Simulate permutation test for independence based on the maximum[#模拟基础上的最大置换的独立测试]
## Pearson residuals (rather than their sum).[#皮尔森残差(而不是他们的总和)。]
rowTotals <- rowSums(TeaTasting)
colTotals <- colSums(TeaTasting)
nOfCases <- sum(rowTotals)
expected <- outer(rowTotals, colTotals, "*") / nOfCases
maxSqResid <- function(x) max((x - expected) ^ 2 / expected)
simMaxSqResid <-
sapply(r2dtable(1000, rowTotals, colTotals), maxSqResid)
sum(simMaxSqResid >= maxSqResid(TeaTasting)) / 1000
## Fisher's exact test gives p = 0.4857 ...[#费舍尔的精确测试,给出了P = 0.4857 ......]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|