1 | kstiesig(x, y, val)
|
x |
|
y |
|
val |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, y, val)
{
m <- length(x)
n <- length(y)
z <- c(x, y)
z <- sort(z)
cmat <- matrix(0, m + 1, n + 1)
umat <- matrix(0, m + 1, n + 1)
for (i in 0:m) {
for (j in 0:n) {
if (abs(i/m - j/n) <= val)
cmat[i + 1, j + 1] <- 1
k <- i + j
if (k > 0 && k < length(z) && z[k] == z[k + 1])
cmat[i + 1, j + 1] <- 1
}
}
for (i in 0:m) {
for (j in 0:n) if (i * j == 0)
umat[i + 1, j + 1] <- cmat[i + 1, j + 1]
else umat[i + 1, j + 1] <- cmat[i + 1, j + 1] * (umat[i +
1, j] + umat[i, j + 1])
}
term <- lgamma(m + n + 1) - lgamma(m + 1) - lgamma(n + 1)
kstiesig <- 1 - umat[m + 1, n + 1]/exp(term)
kstiesig
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.