Learn R Programming

coin (version 1.0-7)

Transformations: Functions for Data Transformations

Description

Rank-transformations for numerical data or dummy codings of factors.

Usage

trafo(data, numeric_trafo = id_trafo, factor_trafo = f_trafo,
    ordered_trafo = of_trafo, surv_trafo = logrank_trafo, 
    var_trafo = NULL, block = NULL)
id_trafo(x)
ansari_trafo(x, ties.method = c("mid-ranks", "average-scores"))
fligner_trafo(x, ties.method = c("mid-ranks", "average-scores"))
normal_trafo(x, ties.method = c("mid-ranks", "average-scores"))
median_trafo(x)
consal_trafo(x, ties.method = c("mid-ranks", "average-scores"))
maxstat_trafo(x, minprob = 0.1, maxprob = 1 - minprob)
logrank_trafo(x, ties.method = c("logrank", "HL", "average-scores"))
f_trafo(x)
of_trafo(x)

Arguments

Value

  • A named matrix with nrow(data) rows and arbitrary number of columns. User-supplied transformations must return a numeric vector or matrix.

Details

The utility functions documented here are used to define special independence tests.

trafo applies its arguments to the elements of data according to the classes of the elements.

id_trafo is the identity transformation and f_trafo computes dummy matrices for factors.

ansari_trafo and fligner_trafo compute Ansari-Bradley or Fligner scores for scale problems.

normal_trafo, median_trafo and consal_trafo implement normal scores, median scores or Conover-Salburg scores (see neuropathy) for location problems, logrank_trafo returns logrank scores for censored data.

A trafo function with modified default arguments is usually feeded into independence_test via the xtrafo or ytrafo arguments.

Fine tuning (different transformations for different variables) is possible by supplying a named list of functions to the var_trafo argument.

Examples

Run this code
### dummy matrices, 2-sample problem (only one column)
  f_trafo(y <- gl(2, 5))

  ### score matrices
  of_trafo(y <- ordered(gl(3, 5)))

  ### K-sample problem (K columns)
  f_trafo(y <- gl(5, 2))

  ### normal scores
  normal_trafo(x <- rnorm(10))

  ### and now together
  trafo(data.frame(x = x, y = y), numeric_trafo = normal_trafo)

  ### the same, more flexible when multiple variables are in play
  trafo(data.frame(x = x, y = y), var_trafo = list(x = normal_trafo))

  ### maximally selected statistics
  maxstat_trafo(rnorm(10))

  ### apply transformation blockwise (e.g. for Friedman test)
  trafo(data.frame(y = 1:20), numeric_trafo = rank, block = gl(4, 5))

Run the code above in your browser using DataLab