coin (version 0.4-2)

expectation-methods: Extract the Expectation and Variance / Covariance of Linear Statistics

Description

Extracts the conditional expectation and covariance for linear statistics from objects inheriting from "IndependenceTest".

Usage

expectation(object, ...)
covariance(object, ...)
variance(object, ...)

Arguments

object
an object inheriting from class IndependenceTest-class.
...
further arguments (currently ignored).

Examples

Run this code
df <- data.frame(y = gl(3, 2), x = gl(3, 2)[sample(1:6)])

### Cochran-Mantel-Haenzel Test
ct <- cmh_test(y ~ x, data = df)
 
### the linear statistic, i.e, the contingency table
l <- statistic(ct, type = "linear")
l

### expectation
El <- expectation(ct)
El

### covariance
Vl <- covariance(ct)
Vl

### the standardized contingency table (hard way)
(l - El) / sqrt(variance(ct))

### easy way
statistic(ct, type = "standardized")

Run the code above in your browser using DataLab