ks2d2 | R Documentation |
Computes the D test statistic for the two-sample two-dimensional Kolmogrov-Smirnov test.
ks2d2(x1, y1, x2, y2, justD = FALSE, KSp = FALSE, divbylen = TRUE) ## S3 method for class 'ks2d2' print(x, ...) ## S3 method for class 'ks2d2' plot( x, pchs = c(2, 19), cexs = c(1.25, 1), xlab = NULL, ylab = NULL, xlim = range(c(x$x1, x$x2)), ylim = range(c(x$y1, x$y2)), ... )
x1 |
Vector of X-coordinates for the first set of coordinates. |
y1 |
Vector of Y-coordinates for the first set of coordinates. |
x2 |
Vector of X-coordinates for the second set of coordinates. |
y2 |
Vector of Y-coordinates for the second set of coordinates. |
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 |
... |
Additiona arguments sent to the plot function. |
pchs |
A vector of length two plotting characters to be used when plotting the two sets of coordinates. |
cexs |
A vector of length two character expansion values to be used when plotting the two sets of coordinates. |
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. |
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 of first set of coordinates.
n2 Sample size of second set of coordinates.
max1 Maximum D for first set of coordinates.
max2 Maximum D for second set of coordinates.
where1 Observation(s) where maximum D occurred for first set of coordinates.
where2 Observation(s) where maximum D occurred for second set of coordinates.
KSp Same logical supplied by user.
divbylen Same logical supplied by user.
x1 Same vector of X-coordinates for the first set of coordinates supplied by user.
y1 Same vector of Y-coordinates for the first set of coordinates supplied by user.
x2 Same vector of X-coordinates for the second set of coordinates supplied by user.
y2 Same vector of Y-coordinates for the second set of coordinates supplied by user.
The plot
function returns side-by-side plots showing the two sets of coordinates and the point or points that resulted in the maximum D value for each set of coordinates. 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.
ks2d1
and ks2d2p
data(KS2D_NR) # separate into the two sets of coordinates d1 <- subset(KS2D_NR,group=="triangles") d2 <- subset(KS2D_NR,group=="squares") # perform analysis ( res1 <- ks2d2(d1$x,d1$y,d2$x,d2$y) ) plot(res1,xlim=c(-3,3),ylim=c(-3,3)) # same but with large sample p-values -- HIGHLY EXPERIMENTAL (NOT YET TESTED) ( res1 <- ks2d2(d1$x,d1$y,d2$x,d2$y,KSp=TRUE) ) # perform same analysis with modified computation of proportions ( res2 <- ks2d2(d1$x,d1$y,d2$x,d2$y,divbylen=FALSE) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.