1 |
x |
|
y |
|
xout |
|
outfun |
|
plotit |
|
xlab |
|
ylab |
|
zlab |
|
RES |
|
... |
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 42 43 44 45 46 47 48 | ##---- 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 = outpro, plotit = FALSE,
xlab = "X", ylab = "Y", zlab = "Z", RES = FALSE, ...)
{
m <- elimna(cbind(x, y))
n = nrow(m)
n.keep = n
x <- as.matrix(x)
p <- ncol(x)
pp <- p + 1
x <- m[, 1:p]
y <- m[, pp]
if (xout) {
m <- cbind(x, y)
flag <- outfun(x, plotit = FALSE, ...)$keep
m <- m[flag, ]
x <- m[, 1:p]
y <- m[, pp]
n.keep = length(y)
}
x <- as.matrix(x)
temp <- summary(lm(y ~ x))
coef <- temp[4]$coefficients
if (plotit) {
if (p == 1) {
plot(x, y, xlab = xlab, ylab = ylab)
abline(coef[, 1])
}
if (p == 2) {
regp2plot(x, y, regfun = ols, xlab = xlab, ylab = ylab,
zlab = zlab)
}
}
Ftest <- temp[10]$fstatistic
Ftest.p.value <- 1 - pf(Ftest[1], Ftest[2], Ftest[3])
Rval = Rsq(x, y)
res = NULL
if (RES)
res = y - x %*% coef[2:pp, 1] - coef[1, 1]
list(n = n, n.keep = n.keep, summary = coef, coef = coef[,
1], F.test = temp[10]$fstatistic[1], Ftest.p.value = Ftest.p.value,
F.test.degrees.of.freedom = temp[10]$fstatistic[2:3],
R.squared = Rval, residuals = as.vector(res))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.