1 |
x |
|
y |
|
regfun |
|
error |
|
nboot |
|
mval |
|
locfun |
|
pr |
|
xout |
|
outfun |
|
plotit |
|
xlab |
|
ylab |
|
SEED |
|
... |
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 | ##---- 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, regfun = lsfit, error = absfun, nboot = 100,
mval = round(5 * log(length(y))), locfun = mean, pr = TRUE,
xout = FALSE, outfun = out, plotit = TRUE, xlab = "Model Number",
ylab = "Prediction Error", SEED = TRUE, ...)
{
if (SEED)
set.seed(2)
q = ncol(x)
qm1 = q - 1
x <- as.matrix(x)
d <- ncol(x)
p1 <- d + 1
temp <- elimna(cbind(x, y))
x <- temp[, 1:d]
y <- temp[, d + 1]
x <- as.matrix(x)
if (xout) {
x <- as.matrix(x)
flag <- outfun(x, SEED = FALSE, ...)$keep
x <- x[flag, ]
y <- y[flag]
x <- as.matrix(x)
}
adit = NULL
pval = c(1:ncol(x))
allp = pval
for (ip in 1:qm1) {
model = list()
for (j in 1:length(pval)) model[[j]] = c(adit, pval[j])
temp = regpre(x, y, model = model, pr = FALSE, plotit = FALSE,
adz = FALSE, regfun = regfun, SEED = SEED)$estimates
pbest = order(temp[, 5])
adit = model[[pbest[1]]]
pval = allp[-adit]
}
output = model[[pbest[1]]]
output = c(output, allp[-output])
output
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.