mantelhaen.test(stats)
mantelhaen.test()所属R语言包:stats
Cochran-Mantel-Haenszel Chi-Squared Test for Count Data
科克伦,曼特尔 - 亨塞尔计数资料卡方检验
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Performs a Cochran-Mantel-Haenszel chi-squared test of the null that two nominal variables are conditionally independent in each stratum, assuming that there is no three-way interaction.
执行一空,两个名义变量是有条件独立的,在各阶层中,假设有没有双向互动的科克伦,曼特尔 - 亨塞尔卡方检验。
用法----------Usage----------
mantelhaen.test(x, y = NULL, z = NULL,
alternative = c("two.sided", "less", "greater"),
correct = TRUE, exact = FALSE, conf.level = 0.95)
参数----------Arguments----------
参数:x
either a 3-dimensional contingency table in array form where each dimension is at least 2 and the last dimension corresponds to the strata, or a factor object with at least 2 levels.
要么在3维数组形式的应急表,其中每个维度至少2个和最后一个维度对应的阶层,或至少有两个层次的因素对象。
参数:y
a factor object with at least 2 levels; ignored if x is an array.
对象具有至少2水平的因素;忽视x如果是一个数组。
参数:z
a factor object with at least 2 levels identifying to which stratum the corresponding elements in x and y belong; ignored if x is an array.
忽略x如果是一个数组。因素至少有两个级别确定到地层中的相应元素y和x属于对象
参数:alternative
indicates the alternative hypothesis and must be one of "two.sided", "greater" or "less". You can specify just the initial letter. Only used in the 2 by 2 by K case.
表示替代假说,必须是一个"two.sided","greater"或"less"。您可以指定只的首字母。只用了2K的情况下,在2。
参数:correct
a logical indicating whether to apply continuity correction when computing the test statistic. Only used in the 2 by 2 by K case.
逻辑表示计算检验统计量时,是否适用连续性校正。只用了2K的情况下,在2。
参数:exact
a logical indicating whether the Mantel-Haenszel test or the exact conditional test (given the strata margins) should be computed. Only used in the 2 by 2 by K case.
逻辑指示是否应计算的Mantel-Haenszel检验或确切的条件测试(地层利润率)。只用了2K的情况下,在2。
参数:conf.level
confidence level for the returned confidence interval. Only used in the 2 by 2 by K case.
返回的置信区间的置信水平。只用了2K的情况下,在2。
Details
详情----------Details----------
If x is an array, each dimension must be at least 2, and the entries should be nonnegative integers. NA's are not allowed. Otherwise, x, y and z must have the same length. Triples containing NA's are removed. All variables must take at least two different values.
x如果是一个数组,每个维度必须至少有2个,参赛作品必须是非负整数。 NA的都是不允许的。否则,x,y和z必须有相同的长度。 NA的三元组包含被删除。所有的变量必须采取至少两种不同的价值观。
值----------Value----------
A list with class "htest" containing the following components:
一类"htest"包含以下组件的列表:
参数:statistic
Only present if no exact test is performed. In the classical case of a 2 by 2 by K table (i.e., of dichotomous underlying variables), the Mantel-Haenszel chi-squared statistic; otherwise, the generalized Cochran-Mantel-Haenszel statistic.
目前唯一的,如果没有进行精确的测试。中了2K表(即二分法的基础变量),卡方统计曼特尔 - 亨塞尔的经典案例,否则广义科克伦曼特尔 - 亨塞尔统计。
参数:parameter
the degrees of freedom of the approximate chi-squared distribution of the test statistic (1 in the classical case). Only present if no exact test is performed.
近似卡方检验统计量的分布(1中的经典案例)自由程度。目前唯一的,如果没有进行精确的测试。
参数:p.value
the p-value of the test.
p值的测试。
参数:conf.int
a confidence interval for the common odds ratio. Only present in the 2 by 2 by K case.
一个常见的赔率比的置信区间。仅在2K情况2。
参数:estimate
an estimate of the common odds ratio. If an exact test is performed, the conditional Maximum Likelihood Estimate is given; otherwise, the Mantel-Haenszel estimate. Only present in the 2 by 2 by K case.
一个常见的赔率比估计。如果进行精确的测试,有条件的最大似然估计;否则,曼特尔 - 亨塞尔估计。仅在2K情况2。
参数:null.value
the common odds ratio under the null of independence, 1. Only present in the 2 by 2 by K case.
常见的胜算比空下的独立,1。仅在2K情况2。
参数:alternative
a character string describing the alternative hypothesis. Only present in the 2 by 2 by K case.
字符串描述替代假说。仅在2K情况2。
参数:method
a character string indicating the method employed, and whether or not continuity correction was used.
受雇于一个字符串,指示方法,是否使用或不连续性校正。
参数:data.name
a character string giving the names of the data.
字符串提供的数据的名称。
注意----------Note----------
The asymptotic distribution is only valid if there is no three-way interaction. In the classical 2 by 2 by K case, this is equivalent to the conditional odds ratios in each stratum being identical. Currently, no inference on homogeneity of the odds ratios is performed.
渐近分布是唯一有效的,如果没有双向互动。在古典K情况2 2,这是相当于条件赔率在各阶层的比率是相同的。目前,没有胜算比同质性的推论。
See also the example below.
还可以看下面的例子。
参考文献----------References----------
Categorical data analysis. New York: Wiley. Pages 230–235.
Categorical data analysis (second edition). New York: Wiley.
举例----------Examples----------
## Agresti (1990), pages 231--237, Penicillin and Rabbits[#Agresti(1990),231 - 237页,青霉素和兔]
## Investigation of the effectiveness of immediately injected or 1.5[#调查的有效性立即注射或1.5]
## hours delayed penicillin in protecting rabbits against a lethal[#小时延迟青霉素防止致命的兔]
## injection with beta-hemolytic streptococci.[#注射β-溶血性链球菌。]
Rabbits <-
array(c(0, 0, 6, 5,
3, 0, 3, 6,
6, 2, 0, 4,
5, 6, 1, 0,
2, 5, 0, 0),
dim = c(2, 2, 5),
dimnames = list(
Delay = c("None", "1.5h"),
Response = c("Cured", "Died"),
Penicillin.Level = c("1/8", "1/4", "1/2", "1", "4")))
Rabbits
## Classical Mantel-Haenszel test[#古典Mantel-Haenszel检验]
mantelhaen.test(Rabbits)
## => p = 0.047, some evidence for higher cure rate of immediate[#=> P = 0.047,一些证据表明治愈率较高立即]
## injection[#注射]
## Exact conditional test[#精确条件测试]
mantelhaen.test(Rabbits, exact = TRUE)
## => p - 0.040[#=> P - 0.040]
## Exact conditional test for one-sided alternative of a higher[片面提出了更高的替代#精确条件测试]
## cure rate for immediate injection[#立即注射治疗率]
mantelhaen.test(Rabbits, exact = TRUE, alternative = "greater")
## => p = 0.020[#=> P = 0.020]
## UC Berkeley Student Admissions[#加州大学伯克利分校的学生入学]
mantelhaen.test(UCBAdmissions)
## No evidence for association between admission and gender[#入学和性别之间的关联没有证据]
## when adjusted for department. However,[#调整后部门。然而,]
apply(UCBAdmissions, 3, function(x) (x[1,1]*x[2,2])/(x[1,2]*x[2,1]))
## This suggests that the assumption of homogeneous (conditional)[#这表明,同质的假设(条件)]
## odds ratios may be violated. The traditional approach would be[#胜算比可能受到侵犯。传统的做法是]
## using the Woolf test for interaction:[#使用交互的伍尔夫测试:]
woolf <- function(x) {
x <- x + 1 / 2
k <- dim(x)[3]
or <- apply(x, 3, function(x) (x[1,1]*x[2,2])/(x[1,2]*x[2,1]))
w <- apply(x, 3, function(x) 1 / sum(1 / x))
1 - pchisq(sum(w * (log(or) - weighted.mean(log(or), w)) ^ 2), k - 1)
}
woolf(UCBAdmissions)
## => p = 0.003, indicating that there is significant heterogeneity.[#=> P = 0.003,表明有显着异质性。]
## (And hence the Mantel-Haenszel test cannot be used.)[#(,因此Mantel-Haenszel检验,不能使用。)]
## Agresti (2002), p. 287f and p. 297.[#Agresti(2002),P。 287f和p。 297。]
## Job Satisfaction example.[#工作满意度的例子。]
Satisfaction <-
as.table(array(c(1, 2, 0, 0, 3, 3, 1, 2,
11, 17, 8, 4, 2, 3, 5, 2,
1, 0, 0, 0, 1, 3, 0, 1,
2, 5, 7, 9, 1, 1, 3, 6),
dim = c(4, 4, 2),
dimnames =
list(Income =
c("<5000", "5000-15000",
"15000-25000", ">25000"),
"Job Satisfaction" =
c("V_D", "L_S", "M_S", "V_S"),
Gender = c("Female", "Male"))))
## (Satisfaction categories abbreviated for convenience.)[#(满意度类别简称为方便)。]
ftable(. ~ Gender + Income, Satisfaction)
## Table 7.8 in Agresti (2002), p. 288.[#表7.8 Agresti(2002年),P。 288。]
mantelhaen.test(Satisfaction)
## See Table 7.12 in Agresti (2002), p. 297.[#Agresti(2002),参见表7.12。 297。]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|