Learn R Programming

coin (version 1.0-7)

IndependenceTest: General Independence Tests

Description

The independence between two sets of variables of arbitrary measurement scales, possibly stratified in blocks, is tested conditional on the data.

Usage

## S3 method for class 'formula':
independence_test(formula, data, subset = NULL, 
    weights = NULL, \dots)
## S3 method for class 'IndependenceProblem':
independence_test(object, 
    teststat = c("max", "quad", "scalar"),
    distribution = c("asymptotic", "approximate", "exact"),
    alternative = c("two.sided", "less", "greater"),
    xtrafo = trafo, ytrafo = trafo, scores = NULL, 
    check = NULL, ...)
## S3 method for class 'table':
independence_test(object, 
    distribution = c("asymptotic", "approximate"), ...)

Arguments

Value

Details

The null hypothesis of the independence between the variables on the left hand side and the variables on the right hand side of formula, possibly stratified by block, is tested. The vector supplied via the weights argument is interpreted as observation counts.

This function is the basic workhorse called by all other convenience functions, mainly by supplying transformations via the xtrafo argument and influence functions via the ytrafo argument.

The scores argument leads to linear-by-linear association tests against ordered alternatives. If the formula y ~ x was supplied and both y and x are factors, scores = list(y = 1:k, x = c(1, 4, 6)) first triggers a coercion to class ordered of both variables and attaches the list elements as scores. The length of a score vector needs to be equal the number of levels of the factor of interest.

The basis of this function is the framework for conditional inference procedures by Strasser & Weber (1999). The theory and this implementation are explained and illustrated in Hothorn, Hornik, van de Wiel and Zeileis (2006).

References

Helmut Strasser & Christian Weber (1999). On the asymptotic theory of permutation statistics. Mathematical Methods of Statistics 8, 220--250.

Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel & Achim Zeileis (2006). A Lego System for Conditional Inference. The American Statistician, 60(3), 257--263.

Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel & Achim Zeileis (2008). Implementing a class of permutation tests: The coin package, Journal of Statistical Software, 28(8), 1--23. http://www.jstatsoft.org/v28/i08/

Examples

Run this code
### independence of asat and group via normal scores test
  independence_test(asat ~ group, data = asat,

    ### exact null distribution
    distribution = "exact", 

    ### one-sided test
    alternative = "greater",

    ### apply normal scores to asat$asat
    ytrafo = function(data) trafo(data, numeric_trafo = normal_trafo),

    ### indicator matrix of 1st level of group
    xtrafo = function(data) trafo(data, factor_trafo = function(x)
        matrix(x == levels(x)[1], ncol = 1))
  )

  ### same as
  normal_test(asat ~ group, data = asat, distribution = "exact", 
              alternative = "greater")


  ### if you are interested in the internals:
  browseURL(system.file("documentation", "html", "index.html", 
                            package = "coin"))

Run the code above in your browser using DataLab