CochranArmitageTest {DescTools} | R Documentation |
Cochran-Armitage Test for Trend
Description
Perform a Cochran Armitage test for trend in binomial proportions across the levels of a single variable. This test is appropriate only when one variable has two levels and the other variable is ordinal. The two-level variable represents the response, and the other represents an explanatory variable with ordered levels. The null hypothesis is the hypothesis of no trend, which means that the binomial proportion is the same for all levels of the explanatory variable.
Usage
CochranArmitageTest(x, alternative = c("two.sided", "one.sided"))
Arguments
x |
a frequency table or a matrix. |
alternative |
a character string specifying the alternative hypothesis, must be one of |
Value
A list of class htest
, containing the following components:
statistic |
the z-statistic of the test. |
parameter |
the dimension of the table. |
p.value |
the p-value for the test. |
alternative |
a character string describing the alternative hypothesis. |
method |
the character string “Cochran-Armitage test for trend”. |
data.name |
a character string giving the names of the data. |
Author(s)
Andri Signorell <andri@signorell.net> strongly based on code from
Eric Lecoutre <lecoutre@stat.ucl.ac.be>
https://stat.ethz.ch/pipermail/r-help/2005-July/076371.html
References
Agresti, A. (2002) Categorical Data Analysis. John Wiley & Sons
See Also
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_freq_details76.htm
Examples
# http://www.lexjansen.com/pharmasug/2007/sp/sp05.pdf, pp. 4
dose <- matrix(c(10,9,10,7, 0,1,0,3), byrow=TRUE, nrow=2, dimnames=list(resp=0:1, dose=0:3))
Desc(dose)
CochranArmitageTest(dose)
CochranArmitageTest(dose, alternative="one.sided")
# not exactly the same as in package coin:
# independence_test(tumor ~ dose, data = lungtumor, teststat = "quad")
lungtumor <- data.frame(dose = rep(c(0, 1, 2), c(40, 50, 48)),
tumor = c(rep(c(0, 1), c(38, 2)),
rep(c(0, 1), c(43, 7)),
rep(c(0, 1), c(33, 15))))
tab <- table(lungtumor$dose, lungtumor$tumor)
CochranArmitageTest(tab)
# but similar to
prop.trend.test(tab[,1], apply(tab,1, sum))