ks2d2p: A permutation test to compute a p-value for the D test...

View source: R/ks2d.R

ks2d2pR Documentation

A permutation test to compute a p-value for the D test statistic for the two-sample two-dimensional Kolmogrov-Smirnov test.

Description

A permutation test to compute a p-value for the D test statistic for the two-sample two-dimensional Kolmogrov-Smirnov test.

Usage

ks2d2p(
  object,
  B = 100,
  type = c("resample", "randomize"),
  randtype = c("discrete", "continuous"),
  coordX = NULL,
  coordY = NULL
)

## S3 method for class 'ks2d2p'
print(x, ...)

## S3 method for class 'ks2d2p'
plot(x, xlab = "D Test Statistic", main = "", ...)

Arguments

object

An object returned from ks2d2.

B

A numeric representing the number of resamples.

type

The type of ‘resampling’ to be conducted. See details.

randtype

The type of randomization to use if type="randomize"; ignored if type="resample".

coordX

A vector of length two giving the minimum and maximum values of the X coordinates when randtype="discrete"; ignored if type="resample" or if type="randomize" and randtype="continuous".

coordY

Same as coordX but for Y coordinates.

x

An object returned from ks2d2p.

...

Additional arguments sent to the plot function.

xlab

A string to label the x-axis.

main

A string to label the main title on the plot.

Details

NEED DETAIL HERE.

Value

The main function returns a list with the following items:

  • D The D test statistic from the ks2d2 object.

  • pval The p-value from the permutation test. See details.

  • Ds The D test statistics from each of the B ‘resamples’.

  • type The type supplied by the user.

  • randtype The randtype supplied by the user.

  • B The B value supplied by the user.

The plot function returns a density plot of the D test statistics from each of the B ‘resamples’ with the observed D test statistic shown with a vertical line. The print function prints the results in a nice format).

Note

This function is experimental at best at this point.

Author(s)

Derek H. Ogle, dogle@northland.edu, with significant help from Ben Bolker.

References

Garvey, J.E., E.A. Marschall, and R.A. Wright. 1998. From star charts to stoneflies: detecting relationships in continuous bivariate data. Ecology 79:442 447.

Press, W.H., S.A. Teukolsky, W.T. Vetterling, B.P. Flannery. 2007. Numerical Recipes: The Art of Scientific Computing, 3rd Edition. Cambridge University Press. 1286 pages.

See Also

ks2d2

Examples

data(KS2D_NR)

# separate into the two sets of coordinates
d1 <- subset(KS2D_NR,group=="triangles")
d2 <- subset(KS2D_NR,group=="squares")

# perform D2KS analysis
( res1 <- ks2d2(d1$x,d1$y,d2$x,d2$y) )

# perform permutation test using resampling
( res1p <- ks2d2p(res1,B=10) )  # B should be >1000, used 10 here to save time
plot(res1p)


droglenc/FSAmisc documentation built on Jan. 8, 2023, 12:59 a.m.