ks2d1: Computes the D test statistic for the one-sample...

View source: R/ks2d.R

ks2d1R Documentation

Computes the D test statistic for the one-sample two-dimensional Kolmogrov-Smirnov test.

Description

Computes the D test statistic for the one-sample two-dimensional Kolmogrov-Smirnov test.

Usage

ks2d1(x1, y1, justD = FALSE, KSp = FALSE, divbylen = TRUE)

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

## S3 method for class 'ks2d1'
plot(
  x,
  xlab = NULL,
  ylab = NULL,
  xlim = range(x$x1),
  ylim = range(x$y1),
  pch = 16,
  ...
)

Arguments

x1

Vector of X values.

y1

Vector of Y values.

justD

Logical that indicates whether just the D test statistic (=TRUE) or more information should be returned (default; see value section below).

KSp

Logical that indicates whether the approximate p-value from the Kolmogorov-Smirnov distribution should be returned. HIGHLY EXPERIMENTAL (NOT YET TESTED).

divbylen

Logical that indicates whether the proportion of values in each quadrant is computed by dividing by the sample size (=TRUE, default) or by the number of points that could be assigned to quadrants.

x

An object returned from d2ks1.

...

Additional arguments sent to the plot function.

xlab

A string to label the x-axis.

ylab

A string to label the y-axis.

xlim

A vector of length two that indicates the limits over which to plot the x-axis.

ylim

A vector of length two that indicates the limits over which to plot the y-axis.

pch

A numeric that indicates the character to be used when plotting the results.

Details

NEED DETAIL HERE.

Value

The main function returns a single numeric of the D test statistic if justD=TRUE or a list with the following items if justD=FALSE:

  • D The D test statistic. See details.

  • pval The approximate p-value from the Kolmogorov-Smirnov distribution. Returned only if KSp=TRUE. HIGHLY EXPERIMENTAL (NOT YET TESTED).

  • n1 Sample size.

  • max1 Maximum D .

  • where1 Observation(s) where maximum D occurred.

  • KSp Same logical supplied by user.

  • divbylen Same logical supplied by user.

  • x1 Same vector of X data supplied by user.

  • y1 Same vector of Y data supplied by user.

The plot function return a scatterplot of the data with the point or points that resulted in the maximum D value. The print function prints results in a nice format if justD=FALSE (only D will be printed if justD=TRUE).

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

ks2d1p

Examples

# Example from Figure 4a in Garvey
data(Garvey4a)

# with the defaults
( res1 <- with(Garvey4a,ks2d1(shad,sunfish)) )
plot(res1,xlab="Shad Densitiy",ylab="Sunfish Density")

# same, but with modified computation of proportions
( res2 <- with(Garvey4a,ks2d1(shad,sunfish,divbylen=FALSE)) )

# same, but compute large-sample p-value -- HIGHLY EXPERIMENTAL (NOT TESTED)
( res3 <- with(Garvey4a,ks2d1(shad,sunfish,KSp=TRUE)) )

# Example from Figure 1 in Garvey
data(Garvey1)
( res4 <- with(Garvey1,ks2d1(Ameletus,Leuctra)) )
plot(res4,xlab="Ameletus Numbers",ylab="Leuctra Numbers",col=rgb(0,0,0,0.1))


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