ks2d1 | R Documentation |
Computes the D test statistic for the one-sample two-dimensional Kolmogrov-Smirnov test.
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, ... )
x1 |
Vector of X values. |
y1 |
Vector of Y values. |
justD |
Logical that indicates whether just the D test statistic ( |
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 ( |
x |
An object returned from |
... |
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. |
NEED DETAIL HERE.
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
).
This function is experimental at best at this point.
Derek H. Ogle, dogle@northland.edu, with significant help from Ben Bolker.
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.
ks2d1p
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.