ca.test | R Documentation |
Performs a Cochran-Armitage chi-squared test for trend in proportions for
a 2 x c
contingency table with a nominal row (r == 2) and ordinal
column (c > 2) variable.
ca.test(x, ...)
## Default S3 method:
ca.test(x, g, ..., score = NULL, simulate.p.value = FALSE, B = 2000L)
## S3 method for class 'formula'
ca.test(formula, data, ...)
x |
a factor-like vector giving the (unordered) variable (equivalently the row variable of a contingency table) alternatively, |
... |
further arguments to be passed to or from methods |
g |
a factor-like vector giving the ordered group for each
corresponding element of |
score |
group score for each column, default is |
simulate.p.value |
logical; if |
B |
an integer specifying the number of replicates used in the Monte Carlo test |
formula |
a formula of the form |
data |
an optional matrix or data frame (or similar: see
|
A list with class "htest
" containing the following elements:
statistic |
the chi-squared test statistic |
parameter |
the degrees of freedom of the approximate chi- squared distribution of the test statistic |
p.value |
the p-value of the test (two-sided) |
method |
a character string describing the test, and, optionally, the number of Monte Carlo replications, if applicable |
data.name |
a character string giving the names of the data |
conf.int |
optionally (if |
summary |
optionally (if |
prop.trend.test
; jt.test
for doubly-ordered tables;
cuzick.test
; DescTools::CochranArmitageTest
## example from stats::prop.trend.test
smokers <- c(83, 90, 129, 70)
patients <- c(86, 93, 136, 82)
prop.test(smokers, patients)
prop.trend.test(smokers, patients)
# DescTools::CochranArmitageTest(rbind(smokers, patients - smokers))
ca.test(rbind(smokers, patients - smokers))
ca.test(rbind(smokers, patients - smokers), score = c(0, 0, 1, 2))
## equivalent ways to call ca.test
dat <- data.frame(x = mtcars$vs, y = mtcars$gear)
ca.test(dat$x, dat$y)
ca.test(x ~ y, dat)
ca.test(split(dat$x, dat$y))
ca.test(table(dat$x, dat$y))
## Not run:
## simulate p-value with 1k replicates
set.seed(1)
ca.test(rbind(smokers, patients - smokers), simulate.p.value = TRUE, B = 1000)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.