Package 'Peacock.test'

Title: Two and Three Dimensional Kolmogorov-Smirnov Two-Sample Tests
Description: The original definition of the two and three dimensional Kolmogorov-Smirnov two-sample test statistics given by Peacock (1983) is implemented. Two R-functions: peacock2 and peacock3, are provided to compute the test statistics in two and three dimensional spaces, respectively. Note the Peacock test is different from the Fasano and Franceschini test (1987). The latter is a variant of the Peacock test.
Authors: Yuanhui Xiao
Maintainer: Yuanhui Xiao <xiao_yuanhui@hotmail.com>
License: GPL-2
Version: 1.0
Built: 2024-02-12 08:38:32 UTC
Source: CRAN

Help Index


Multidimensional Kolmogorov-Smirnov Two-Sample Test

Description

Two R-functions: peacock2 and peacock3 are provided to compute the two dimensional and three dimensional KS two-sample tests, respectively. The famous KS two sample test was generalized to multidimensional spaces by Peacock (1983). Hence, it is also called the Peacock test. The Peacock is different from the widely used Fasano and Franceschini test (1987). The latter is a variant of the KS test, invented to alleviate the computational intensity of the former. The two R-functions implement the original definition of the KS test given by Peacock (1983).

Details

Package: Peacock.test
Type: Package
Version: 1.0
Date: 2016-07-13
License: GPL-2

The two functions: peacock2 and peacock3, provided in this package are self-explanatory and their usage is straightforward.

Author(s)

Yuanhui Xiao

Maintainer: Yuanhui Xiao <xiao\_yuanhui@hotmail.com> ~~ The author and/or maintainer of the package ~~

References

Fasano, G., Franceschini, A. (1987)<DOI:10.1093/mnras/225.1.155>. A multidimensional version of the Kolmogorov-Smirnov test. Monthly Notices of the Royal Astronomical Society 225:155-170.

Peacock J.A. (1983) <DOI:10.1093/mnras/202.3.615>. Two-dimensional goodness-of-fit testing in astronomy. Monthly Notices of the Royal Astronomical Society 202:615-627.

Xiao Y(2016). A fast algorithm for two-dimensional Kolmogorov-Smirnov two-sample tests, Journal Computational Statistics and Data Analysis, under revision.

Examples

# two-dimensional case 
    x2 <- matrix(rnorm(12, 0, 1), ncol=2)
    y2 <- matrix(rnorm(16, 0, 1), ncol=2)
    ks2 <- peacock2(x2, y2)
    ks2
# three-dimensional case 
    x3 <- matrix(rnorm(12, 0, 1), ncol=3)
    y3 <- matrix(rnorm(18, 0, 1), ncol=3)
    ks3 <- peacock3(x3, y3)
    ks3

Greatest Common Divisor

Description

This function returns the greatest common divisor of two integers

Usage

gcd(x, y)

Arguments

x

a nonnegative integer

y

a nonnegative integer

Details

The function utilizes the Euclidean algorithm to compute the greatest common divisor of two integers

Value

An integer, which is the greatest common divisor. If both arguments are zero, then the returned value is 1.

Author(s)

Yuanhui Xiao

Examples

x <- 4
y <- 6
d <- gcd(x, y)
d

Two Dimensional Kolmogorov-Smirnov/Peacock Two-Sample test

Description

This function implements the original definition of the two-dimensional Kolmogorov-Smirnov test by Peacock (1983). This test is not the widely used Fasano-Franceschini test (1987). The latter is a variant the Peacock test.

Usage

peacock2(x, y)

Arguments

x

x is the object representing the first sample. x should be able to be converted a matrix, where each row represents a sample point. If the object cannot be converted to a matrix, the function will stop and throw an error message. Pleaste note that only the first two columns of the matrix will be used, and the rest columns are just ingored.

y

Similar to x, y is the object representing the second sample.

Value

the value of the test statistic

Author(s)

Yuanhui Xiao

Examples

x <- matrix(rnorm(12, 0, 1), ncol=2)
    y <-  matrix(rnorm(16, 0, 1), ncol=2)
    ks <- peacock2(x, y)
    ks

Three Dimensional Kolmogorov-Smirnov/Peacock Two-Sample test

Description

This function implements the original definition of the three-dimensional Kolmogorov-Smirnov test by Peacock (1983). This test is not the widely used Fasano-Franceschini test (1987). The latter is a variant the Peacock test.

Usage

peacock3(x, y)

Arguments

x

x is the object representing the first sample. x should be able to be converted a matrix, where each row represents a sample point. If the object cannot be converted to a matrix, the function will stop and throw an error message. Pleaste note that only the first three columns of the matrix will be used, and the rest columns are just ingored.

y

Similar to x, y is the object representing the second sample.

Value

the value of the test statistic

Author(s)

Yuanhui Xiao

Examples

x <- matrix(rnorm(12, 0, 1), ncol=3)
    y <- matrix(rnorm(18, 0, 1), ncol=3)
    ks <- peacock3(x, y)
    ks