Transformations {coin}  R Documentation 
Transformations for factors and numeric variables.
id_trafo(x) rank_trafo(x, ties.method = c("midranks", "random")) normal_trafo(x, ties.method = c("midranks", "averagescores")) median_trafo(x, mid.score = c("0", "0.5", "1")) savage_trafo(x, ties.method = c("midranks", "averagescores")) consal_trafo(x, ties.method = c("midranks", "averagescores"), a = 5) koziol_trafo(x, ties.method = c("midranks", "averagescores"), j = 1) klotz_trafo(x, ties.method = c("midranks", "averagescores")) mood_trafo(x, ties.method = c("midranks", "averagescores")) ansari_trafo(x, ties.method = c("midranks", "averagescores")) fligner_trafo(x, ties.method = c("midranks", "averagescores")) logrank_trafo(x, ties.method = c("midranks", "HothornLausen", "averagescores"), weight = logrank_weight, ...) logrank_weight(time, n.risk, n.event, type = c("logrank", "GehanBreslow", "TaroneWare", "PetoPeto", "Prentice", "PrenticeMarek", "AndersenBorganGillKeiding", "FlemingHarrington", "GauglerKimLiao", "Self"), rho = NULL, gamma = NULL) f_trafo(x) of_trafo(x, scores = NULL) zheng_trafo(x, increment = 0.1) maxstat_trafo(x, minprob = 0.1, maxprob = 1  minprob) fmaxstat_trafo(x, minprob = 0.1, maxprob = 1  minprob) ofmaxstat_trafo(x, minprob = 0.1, maxprob = 1  minprob) trafo(data, numeric_trafo = id_trafo, factor_trafo = f_trafo, ordered_trafo = of_trafo, surv_trafo = logrank_trafo, var_trafo = NULL, block = NULL) mcp_trafo(...)
x 
an object of class 
ties.method 
a character, the method used to handle ties. The score generating function
either uses the midranks ( 
mid.score 
a character, the score assigned to observations exactly equal to the median:
either 0 ( 
a 
a numeric vector, the values taken as the constant a in the
ConoverSalsburg scores. Defaults to 
j 
a numeric, the value taken as the constant j in the KoziolNemec
scores. Defaults to 
weight 
a function where the first three arguments must correspond to 
time 
a numeric vector, the ordered distinct time points. 
n.risk 
a numeric vector, the number of subjects at risk at each time point
specified in 
n.event 
a numeric vector, the number of events at each time point specified in

type 
a character, one of 
rho 
a numeric vector, the ρ constant when 
gamma 
a numeric vector, the γ constant when 
scores 
a numeric vector or list, the scores corresponding to each level of an
ordered factor. Defaults to 
increment 
a numeric, the score increment between the orderrestricted sets of scores.
A fraction greater than 0, but smaller than or equal to 1. Defaults to

minprob 
a numeric, a fraction between 0 and 0.5; see 
maxprob 
a numeric, a fraction between 0.5 and 1; see 
data 
an object of class 
numeric_trafo 
a function to be applied to elements of class 
factor_trafo 
a function to be applied to elements of class 
ordered_trafo 
a function to be applied to elements of class 
surv_trafo 
a function to be applied to elements of class 
var_trafo 
an optional named list of functions to be applied to the corresponding
variables in 
block 
an optional factor whose levels are interpreted as blocks. 
... 

The utility functions documented here are used to define specialized test procedures.
id_trafo
is the identity transformation.
rank_trafo
, normal_trafo
, median_trafo
,
savage_trafo
, consal_trafo
and koziol_trafo
compute rank
scores, normal scores, median scores, Savage scores, ConoverSalsburg scores
(see neuropathy
) and KoziolNemec scores, respectively, for
location problems.
klotz_trafo
, mood_trafo
, ansari_trafo
and
fligner_trafo
compute Klotz scores, Mood scores, AnsariBradley scores
and FlignerKilleen scores, respectively, for scale problems.
logrank_trafo
computes weighted logrank scores for rightcensored data,
allowing for a userdefined weight function through the weight
argument
(see GTSG
).
f_trafo
computes dummy matrices for factors and of_trafo
assigns
scores to ordered factors. For ordered factors with two levels, the scores
are normalized to the [0, 1] range. zheng_trafo
computes a
finite collection of orderrestricted scores for ordered factors (see
jobsatisfaction
, malformations
and
vision
).
maxstat_trafo
, fmaxstat_trafo
and ofmaxstat_trafo
compute
scores for cutpoint problems (see maxstat_test
).
trafo
applies its arguments to the elements of data
according to
the classes of the elements. A trafo
function with modified default
arguments is usually supplied to independence_test
via the
xtrafo
or ytrafo
arguments. Fine tuning, i.e., different
transformations for different variables, is possible by supplying a named list
of functions to the var_trafo
argument.
mcp_trafo
computes contrast matrices for factors.
A numeric vector or matrix with nrow(x)
rows and an arbitrary number of
columns. For trafo
, a named matrix with nrow(data)
rows and an
arbitrary number of columns.
Starting with coin version 1.10, all transformation functions are now
passing through missing values (i.e., NA
s). Furthermore,
median_trafo
and logrank_trafo
are now increasing
functions (in conformity with most other transformations in this package).
## Dummy matrix, twosample problem (only one column) f_trafo(gl(2, 3)) ## Dummy matrix, Ksample problem (K columns) x < gl(3, 2) f_trafo(x) ## Score matrix ox < as.ordered(x) of_trafo(ox) of_trafo(ox, scores = c(1, 3:4)) of_trafo(ox, scores = list(s1 = 1:3, s2 = c(1, 3:4))) zheng_trafo(ox, increment = 1/3) ## Normal scores y < runif(6) normal_trafo(y) ## All together now trafo(data.frame(x = x, ox = ox, y = y), numeric_trafo = normal_trafo) ## The same, but allows for finetuning trafo(data.frame(x = x, ox = ox, y = y), var_trafo = list(y = normal_trafo)) ## Transformations for maximally selected statistics maxstat_trafo(y) fmaxstat_trafo(x) ofmaxstat_trafo(ox) ## Apply transformation blockwise (as in the Friedman test) trafo(data.frame(y = 1:20), numeric_trafo = rank_trafo, block = gl(4, 5)) ## Multiple comparisons dta < data.frame(x) mcp_trafo(x = "Tukey")(dta) ## The same, but useful when specific contrasts are desired K < rbind("2  1" = c(1, 1, 0), "3  1" = c(1, 0, 1), "3  2" = c( 0, 1, 1)) mcp_trafo(x = K)(dta)