Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

expectation-methods

Extraction of the Expectation, Variance and Covariance of the Linear Statistic


Description

Methods for extraction of the expectation, variance and covariance of the linear statistic.

Usage

## S4 method for signature 'IndependenceLinearStatistic'
expectation(object, partial = FALSE, ...)
## S4 method for signature 'IndependenceTest'
expectation(object, partial = FALSE, ...)

## S4 method for signature 'Variance'
variance(object, ...)
## S4 method for signature 'CovarianceMatrix'
variance(object, ...)
## S4 method for signature 'IndependenceLinearStatistic'
variance(object, partial = FALSE, ...)
## S4 method for signature 'IndependenceTest'
variance(object, partial = FALSE, ...)

## S4 method for signature 'CovarianceMatrix'
covariance(object, ...)
## S4 method for signature 'IndependenceLinearStatistic'
covariance(object, invert = FALSE, partial = FALSE, ...)
## S4 method for signature 'QuadTypeIndependenceTestStatistic'
covariance(object, invert = FALSE, partial = FALSE, ...)
## S4 method for signature 'IndependenceTest'
covariance(object, invert = FALSE, partial = FALSE, ...)

Arguments

object

an object from which the expectation, variance or covariance of the linear statistic can be extracted.

partial

a logical indicating that the partial result for each block should be extracted. Defaults to FALSE.

invert

a logical indicating that the Moore-Penrose inverse of the covariance should be extracted. Defaults to FALSE.

...

further arguments (currently ignored).

Details

The methods expectation, variance and covariance extract the expectation, variance and covariance, respectively, of the linear statistic.

For tests of conditional independence within blocks, the partial result for each block is obtained by setting partial = TRUE.

Value

The expectation, variance or covariance of the linear statistic extracted from object. A matrix or array.

Examples

## Example data
dta <- data.frame(
    y = gl(3, 2),
    x = sample(gl(3, 2))
)

## Asymptotic Cochran-Mantel-Haenszel Test
ct <- cmh_test(y ~ x, data = dta)

## The linear statistic, i.e., the contingency table...
(T <- statistic(ct, type = "linear"))

## ...and its expectation...
(mu <- expectation(ct))

## ...and variance...
(sigma <- variance(ct))

## ...and covariance...
(Sigma <- covariance(ct))

## ...and its inverse
(SigmaPlus <- covariance(ct, invert = TRUE))

## The standardized contingency table...
(T - mu) / sqrt(sigma)

## ...is identical to the standardized linear statistic
statistic(ct, type = "standardized")

## The quadratic form...
U <- as.vector(T - mu)
U %*% SigmaPlus %*% U

## ...is identical to the test statistic
statistic(ct, type = "test")

coin

Conditional Inference Procedures in a Permutation Test Framework

v1.4-1
GPL-2
Authors
Torsten Hothorn [aut, cre] (<https://orcid.org/0000-0001-8301-0471>), Henric Winell [aut] (<https://orcid.org/0000-0001-7995-3047>), Kurt Hornik [aut] (<https://orcid.org/0000-0003-4198-9911>), Mark A. van de Wiel [aut] (<https://orcid.org/0000-0003-4780-8472>), Achim Zeileis [aut] (<https://orcid.org/0000-0003-0918-3766>)
Initial release
2021-02-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.