regpreCV:

Usage Arguments Examples

Usage

1
regpreCV(x, y, regfun = tsreg, varfun = pbvar, adz = TRUE, model = NULL, locfun = mean, xout = FALSE, outfun = out, plotit = TRUE, xlab = "Model Number", ylab = "Prediction Error", ...)

Arguments

x
y
regfun
varfun
adz
model
locfun
xout
outfun
plotit
xlab
ylab
...

Examples

 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
49
50
##---- 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 = tsreg, varfun = pbvar, adz = TRUE, model = NULL, 
    locfun = mean, xout = FALSE, outfun = out, plotit = TRUE, 
    xlab = "Model Number", ylab = "Prediction Error", ...) 
{
    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, ...)$keep
        x <- x[flag, ]
        y <- y[flag]
        x <- as.matrix(x)
    }
    if (is.null(model)) {
        if (d <= 5) 
            model <- modgen(d, adz = adz)
        if (d > 5) 
            model[[1]] <- c(1:ncol(x))
    }
    mout <- matrix(NA, length(model), 3, dimnames = list(NULL, 
        c("est.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)
        if (sum(model[[imod]] == 0) != 1) {
            xx <- x[, model[[imod]]]
            xx <- as.matrix(xx)
            mout[imod, 1] <- regpecv(xx, y, regfun = regfun, 
                varfun = varfun, ...)
        }
        if (sum(model[[imod]] == 0) == 1) {
            mout[imod, 1] <- locCV(y, varfun = varfun, locfun = locfun)
        }
    }
    mout[, 3] = rank(mout[, 1])
    if (plotit) 
        plot(c(1:nrow(mout)), mout[, 1], xlab = xlab, ylab = ylab)
    mout
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.