Learn R Programming

exactRankTests (version 0.7-5)

cscores: Computation of Scores

Description

This function can be used to compute several scores for a data vector.

Usage

## S3 method for class 'default':
cscores(y, type=c("Data", "Wilcoxon", "NormalQuantile", 
        "AnsariBradley", "Median"), int=FALSE, ...)
## S3 method for class 'factor':
cscores(y, \dots)
## S3 method for class 'Surv':
cscores(y, type="LogRank", int=FALSE, \dots)

Arguments

y
a numeric, factor or logical vector or an object of class `Surv'.
type
a character string which specifies the type of the scores to be computed. Data just returns y if y is numeric.
int
a logical, forcing integer valued scores.
...
additional arguments, not passed to anything at the moment.

Value

  • A vector of scores for y with an attribute scores indicating the kind of scores used is returned.

Details

This function will serve as the basis for a more general framework of rank and permutation tests in future versions of this package. Currently, it is only used in the examples.

The logrank scores are computed as given in Hothorn & Lausen, 2002.

If integer valued scores are requested (int = TRUE), the scores are mapped into integers by round(scores*length(scores)/max(scores)). See dperm for more details.

References

Hothorn, T. and Lausen, B. (2002). On the Exact Distribution of Maximally Selected Rank Statistics. Computational Statistics & Data Analysis, (in press). Preprint available from http://www.mathpreprints.com/math/Preprint/hothorn/20020227/2

Examples

Run this code
y <- rnorm(50)
# v.d. Waerden scores
nq <- cscores(y, type="Normal", int=TRUE)
# quantile for m=20 observations in the first group
qperm(0.1, nq, 20)

# Table 9.19 StaXact-4 manual: lung cancer clinical trial
time <- c(257, 476, 355, 1779, 355, 191, 563, 242, 285, 16, 16, 16, 257, 16)
cens <- c(0,0,1,1,0,1,1,1,1,1,1,1,1,1)

# round logrank scores
scores <- cscores.Surv(cbind(time, cens))
T <- sum(scores[1:5])
system.time(prob <- pperm(T, scores, m=5, al="le"))
prob
pperm(T, scores, m=5, al="tw")

# map into integers, faster
scores <- cscores.Surv(cbind(time, cens), int=TRUE)
T <- sum(scores[1:5])
system.time(prob <- pperm(T, scores, m=5, al="le"))
prob # compare with 0.001
pperm(T, scores, m=5, al="tw") # compare with 0.001

Run the code above in your browser using DataLab