logSMpred:

Usage Arguments Examples

Usage

1
logSMpred(x, y, pts, fr = 2, LP = TRUE, xout = FALSE, outfun = outpro, SEED = TRUE, ...)

Arguments

x
y
pts
fr
LP
xout
outfun
SEED
...

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
##---- 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, pts, fr = 2, LP = TRUE, xout = FALSE, outfun = outpro, 
    SEED = TRUE, ...) 
{
    if (SEED) 
        set.seed(2)
    x = as.matrix(x)
    pts = as.matrix(pts)
    p = ncol(x)
    p1 = p + 1
    xx <- elimna(cbind(x, y))
    x <- xx[, 1:p]
    y <- xx[, p1]
    if (xout) {
        m <- cbind(x, y)
        flag <- outfun(x, plotit = FALSE, ...)$keep
        m <- m[flag, ]
        x <- m[, 1:p]
        y <- m[, p1]
    }
    x = as.matrix(x)
    library(MASS)
    m = cov.mve(x)
    phat <- NA
    m1 = matrix(NA, nrow = nrow(pts), ncol = nrow(pts))
    yhat = NULL
    for (i in 1:nrow(pts)) {
        d <- mahalanobis(x, pts[i, ], m$cov)
        flag = sqrt(d) <= fr
        w = flag * exp(-1 * d)
        yhat[i] = sum(w * y)/sum(w)
    }
    yhat
  }

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