Last data update: 2014.03.03

R: One, Two and C Sample Rank Tests for Location based on...
rank.ctestR Documentation

One, Two and C Sample Rank Tests for Location based on Marginal Ranks

Description

Performs the one, two or c sample location test based on marginal ranks. Three different score functions are available.

Usage

rank.ctest(X, ...)

## Default S3 method:
rank.ctest(X, Y = NULL, mu = NULL, scores = "rank", 
           na.action = na.fail, ...)

## S3 method for class 'formula'
rank.ctest(formula, na.action = na.fail, ...)

## S3 method for class 'ics'
rank.ctest(X, g = NULL, index = NULL, na.action = na.fail, ...)

Arguments

X

a numeric data frame or matrix or an ics object.

Y

an optional numeric data frame or matrix for the two sample test. If NULL a one sample test is performed.

mu

a vector indicating the hypothesized value of the mean (or difference in means if you are performing a two sample test). NULL represents origin or no difference between the groups. For more than two groups mu should be 0 or not be specified at all.

scores

if 'sign', a sign test is performed, if 'rank' a signed rank test is performed or if 'normal' a normal score test is performed.

formula

a formula of the form X ~ g where X is a numeric matrix giving the data values and g a factor with at least two levels giving the corresponding groups.

g

a grouping factor with at least two levels.

index

an integer vector that gives the columns to choose the invariant coordinates form the 'ics' object. The default uses all columns.

na.action

a function which indicates what should happen when the data contain 'NA's. Default is to fail.

...

further arguments to be passed to or from methods.

Details

These tests are well described in Puri and Sen (1971). The tests are based on the marginal ranks for which three score functions are available. The scores are also used to estimate the covariance matrices. In the multisample case it is assumed that the distribution of the different populations differs only in their location.

The ics interface provides an invariant test based on the invariant coordinate selection. The assymptotic distribution is however still an open question when more than one component is used, though the chi-square approximation works well also for several components as shown in Nordhausen, Oja and Tyler (2006).

Value

A list with class 'htest' containing the following components:

statistic

the value of the T-statistic.

parameter

the degrees of freedom for the T-statistic.

p.value

the p-value for the test.

null.value

the specified hypothesized value of the mean or mean difference depending on whether it was a one-sample test or a two-sample test.

alternative

a character string with the value 'two.sided'.

method

a character string indicating what type of test was performed.

data.name

a character string giving the name of the data (and grouping vector).

Author(s)

Klaus Nordhausen, klaus.nordhausen@uta.fi

References

Puri , M.L. and Sen, P.K. (1971), Nonparametric Methods in Multivariate Analysis, New York: Wiley.

Nordhausen, K., Oja, H. and Tyler, D.E. (2006), On the Efficiency of Invariant Multivariate Sign and Rank Tests, in Festschrift of Tarmo Pukkila on his 60th Birthday, 217–231.

Examples

# one sample tests:

data(pulmonary)

rank.ctest(pulmonary, scores = "sign")
rank.ctest(pulmonary, mu = c(0,0,2))

# two sample tests:

set.seed(123456)
X <- rmvnorm(20, c(0,0,0,0), diag(1:4))
Y <- rmvnorm(30, c(0.5,0.5,0.5,0.5), diag(1:4))
Z <- rbind(X,Y)
g <- factor(rep(c(1,2), c(20,30)))

rank.ctest(X, Y, scores = "normal")
rank.ctest(Z~g, scores = "sign", mu = rep(-0.5,4))

# c sample test:

W <- rmvnorm(30, c(0,0,0,0), diag(1:4))
Z2 <- rbind(X,Y,W)
g2 <- factor(rep(1:3, c(20,30,30)))

rank.ctest(Z2~g2, scores = "normal")

# in an invariant coordinate system

rank.ctest(ics(Z2,covOrigin, cov4, S2args=list(location =
           "Origin")), index = c(1,4), scores = "sign")

rank.ctest(ics(Z), g, index = 4)

rank.ctest(ics(Z2), g2, scores = "normal",index = 4)

rm(.Random.seed)
         

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ICSNP)
Loading required package: mvtnorm
Loading required package: ICS
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ICSNP/rank.ctest.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rank.ctest
> ### Title: One, Two and C Sample Rank Tests for Location based on Marginal
> ###   Ranks
> ### Aliases: rank.ctest rank.ctest.default rank.ctest.formula
> ###   rank.ctest.ics
> ### Keywords: htest multivariate nonparametric
> 
> ### ** Examples
> 
> # one sample tests:
> 
> data(pulmonary)
> 
> rank.ctest(pulmonary, scores = "sign")

	Marginal One Sample Sign Test

data:  pulmonary
T = 3.6667, df = 3, p-value = 0.2998
alternative hypothesis: true location is not equal to c(0,0,0)

> rank.ctest(pulmonary, mu = c(0,0,2))

	Marginal One Sample Signed Rank Test

data:  pulmonary
T = 8.3333, df = 3, p-value = 0.0396
alternative hypothesis: true location is not equal to c(0,0,2)

> 
> # two sample tests:
> 
> set.seed(123456)
> X <- rmvnorm(20, c(0,0,0,0), diag(1:4))
> Y <- rmvnorm(30, c(0.5,0.5,0.5,0.5), diag(1:4))
> Z <- rbind(X,Y)
> g <- factor(rep(c(1,2), c(20,30)))
> 
> rank.ctest(X, Y, scores = "normal")

	Marginal Two Sample Normal Scores Test

data:  X and Y
T = 11.261, df = 4, p-value = 0.02378
alternative hypothesis: true location difference is not equal to c(0,0,0,0)

> rank.ctest(Z~g, scores = "sign", mu = rep(-0.5,4))

	Marginal Two Sample Median Test

data:  Z by g
T = 1.8037, df = 4, p-value = 0.7718
alternative hypothesis: true location difference is not equal to c(-0.5,-0.5,-0.5,-0.5)

> 
> # c sample test:
> 
> W <- rmvnorm(30, c(0,0,0,0), diag(1:4))
> Z2 <- rbind(X,Y,W)
> g2 <- factor(rep(1:3, c(20,30,30)))
> 
> rank.ctest(Z2~g2, scores = "normal")

	Marginal C Sample Normal Score Test

data:  Z2 by g2
T = 14.379, df = 8, p-value = 0.07241

> 
> # in an invariant coordinate system
> 
> rank.ctest(ics(Z2,covOrigin, cov4, S2args=list(location =
+            "Origin")), index = c(1,4), scores = "sign")

	Marginal One Sample Sign Test

data:  ics(Z2, covOrigin, cov4, S2args = list(location = "Origin"))
T = 1.9449, df = 2, p-value = 0.3782
alternative hypothesis: true location is not equal to c(0,0)

> 
> rank.ctest(ics(Z), g, index = 4)

	Marginal Two Sample Rank Sum Test

data:  ics(Z) and g
T = 0.40976, df = 1, p-value = 0.5221
alternative hypothesis: true location difference is not equal to c(0)

> 
> rank.ctest(ics(Z2), g2, scores = "normal",index = 4)

	Marginal C Sample Normal Score Test

data:  ics(Z2) and g2
T = 1.5023, df = 2, p-value = 0.4718

> 
> rm(.Random.seed)
>          
> 
> 
> 
> 
> dev.off()
null device 
          1 
>