1 |
x |
|
y |
|
est |
|
fr |
|
varfun |
|
model |
|
adz |
|
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 38 | ##---- 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, est = tmean, fr = NA, varfun = pbvar, model = NULL,
adz = TRUE, xout = FALSE, outfun = out, ...)
{
if (xout) {
x <- as.matrix(x)
flag <- outfun(x, ...)$keep
x <- x[flag, ]
y <- y[flag]
}
x = as.matrix(x)
p = ncol(x)
if (p > 5)
stop("Can have at most 5 predictors")
if (is.null(model))
model = modgen(p)
mout <- matrix(NA, length(model), 3, dimnames = list(NULL,
c("error", "var.used", "rank")))
for (imod in 1:length(model)) {
nmod = length(model[[imod]]) - 1
temp = c(nmod:0)
mout[imod, 2] = sum(model[[imod]] * 10^temp)
mout[imod, 1] = rplotCV(x[, model[[imod]]], y, fr = fr,
est = est, varfun = varfun)$VAR.Y.HAT
}
if (adz) {
va = 0
for (i in 1:30) va[i] = y[i] - tmean(y[-i])
no = pbvar(va)
mout = rbind(mout, c(no, 0, NA))
}
mout[, 3] = rank(mout[, 1])
list(estimates = mout)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.