1 |
x |
|
y |
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 33 34 35 36 37 38 39 40 41 | ##---- 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 = NA)
{
if (!is.na(y[1]))
x <- cbind(x, y)
if (!is.matrix(x))
stop("x should be a matrix")
x <- elimna(x)
n <- nrow(x)
p <- ncol(x)
temp <- tbs(x)$cov
val <- matrix(NA, p, p)
for (j in 1:p) {
for (k in 1:p) {
val[j, k] <- temp[k, j]/sqrt(temp[k, k] * temp[j,
j])
}
}
test <- abs(val * sqrt((n - 2)/(1 - val^2)))
if (p == 2) {
val <- val[1, 2]
p.value <- c("Greater than .1")
crit <- 20.2/n + 1.89
if (test >= crit)
p.value <- c("Less than .1")
crit <- 30.41/n + 2.21
if (test >= crit)
p.value <- c("Less than .05")
crit <- 39.72/n + 2.5
if (test >= crit)
p.value <- c("Less than .025")
crit <- 58.55/n + 2.8
if (test >= crit)
p.value <- c("Less than .01")
}
list(cor = val, test.stat = test, p.value = p.value)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.