1 |
x |
|
y |
|
xout |
|
outfun |
|
... |
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 | ##---- 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, xout = FALSE, outfun = out, ...)
{
x <- as.matrix(x)
if (xout) {
flag <- outfun(x, ...)$keep
x <- as.matrix(x)
x <- x[flag, ]
y <- y[flag]
x <- as.matrix(x)
}
pv <- ncol(x)
pv1 <- pv + 1
m <- cbind(x, y)
m <- elimna(m)
x <- m[, 1:pv]
x <- as.matrix(x)
y <- m[, pv1]
dvec <- NA
mat <- matrix(nrow = nrow(x), ncol = pv)
temp <- lsfit(x, y)
sigest <- mean(temp$res^2)
dvec <- y - temp$res
dbar <- dvec - mean(dvec)
uval <- temp$res^2
uval <- as.matrix(uval)
test <- t(uval) %*% dbar %*% solve(t(dbar) %*% dbar) %*%
t(dbar) %*% uval
psihat <- mean((temp$res^2 - sigest)^2)
test <- test/psihat
p.value <- 1 - pchisq(test, 1)
list(test = test, p.value = p.value)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.