Description Usage Arguments Details Value Examples
Methods for extraction of the test statistic and the linear statistic.
1 2 3 4 5 6 7 8 9 | ## S4 method for signature 'IndependenceLinearStatistic'
statistic(object, type = c("test", "linear", "centered", "standardized"),
partial = FALSE, ...)
## S4 method for signature 'IndependenceTestStatistic'
statistic(object, type = c("test", "linear", "centered", "standardized"),
partial = FALSE, ...)
## S4 method for signature 'IndependenceTest'
statistic(object, type = c("test", "linear", "centered", "standardized"),
partial = FALSE, ...)
|
object |
an object from which the test statistic or the linear statistic can be extracted. |
type |
a character string indicating the type of statistic: either |
partial |
a logical indicating that the partial linear statistic for each block should
be extracted. Defaults to |
... |
further arguments (currently ignored). |
The method statistic
extracts the univariate test statistic or the,
possibly multivariate, linear statistic in its unstandardized, centered or
standardized form.
The test statistic (type = "test"
) is returned by default. The
unstandardized, centered or standardized linear statistic is obtained by
setting type
to "linear"
, "centered"
or
"standardized"
, respectively. For tests of conditional independence
within blocks, the partial linear statistic for each block is obtained by
setting partial = TRUE
.
The test statistic or the unstandardized, centered or standardized linear
statistic extracted from object
. A numeric vector, matrix or array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Example data
dta <- data.frame(
y = gl(4, 5),
x = gl(5, 4)
)
## Asymptotic Cochran-Mantel-Haenszel Test
ct <- cmh_test(y ~ x, data = dta)
## Test statistic
statistic(ct)
## The unstandardized linear statistic...
statistic(ct, type = "linear")
## ...is identical to the contingency table
xtabs(~ x + y, data = dta)
## The centered linear statistic...
statistic(ct, type = "centered")
## ...is identical to
statistic(ct, type = "linear") - expectation(ct)
## The standardized linear statistic, illustrating departures from the null
## hypothesis of independence...
statistic(ct, type = "standardized")
## ...is identical to
(statistic(ct, type = "linear") - expectation(ct)) / sqrt(variance(ct))
|
Loading required package: survival
[1] 38
1 2 3 4
1 4 0 0 0
2 1 3 0 0
3 0 2 2 0
4 0 0 3 1
5 0 0 0 4
y
x 1 2 3 4
1 4 0 0 0
2 1 3 0 0
3 0 2 2 0
4 0 0 3 1
5 0 0 0 4
1 2 3 4
1 3 -1 -1 -1
2 0 2 -1 -1
3 -1 1 1 -1
4 -1 -1 2 0
5 -1 -1 -1 3
1 2 3 4
1 3 -1 -1 -1
2 0 2 -1 -1
3 -1 1 1 -1
4 -1 -1 2 0
5 -1 -1 -1 3
1 2 3 4
1 3.774917 -1.258306 -1.258306 -1.258306
2 0.000000 2.516611 -1.258306 -1.258306
3 -1.258306 1.258306 1.258306 -1.258306
4 -1.258306 -1.258306 2.516611 0.000000
5 -1.258306 -1.258306 -1.258306 3.774917
1 2 3 4
1 3.774917 -1.258306 -1.258306 -1.258306
2 0.000000 2.516611 -1.258306 -1.258306
3 -1.258306 1.258306 1.258306 -1.258306
4 -1.258306 -1.258306 2.516611 0.000000
5 -1.258306 -1.258306 -1.258306 3.774917
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.