logSM:

Usage Arguments Examples

Usage

1
logSM(x, y, pyhat = FALSE, plotit = TRUE, xlab = "X", ylab = "Y", zlab = "Z", xout = FALSE, outfun = outpro, pr = TRUE, theta = 50, phi = 25, duplicate = "error", LP = TRUE, expand = 0.5, scale = TRUE, fr = 2, ticktype = "simple", ...)

Arguments

x
y
pyhat
plotit
xlab
ylab
zlab
xout
outfun
pr
theta
phi
duplicate
LP
expand
scale
fr
ticktype
...

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
##---- 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, pyhat = FALSE, plotit = TRUE, xlab = "X", ylab = "Y", 
    zlab = "Z", xout = FALSE, outfun = outpro, pr = TRUE, theta = 50, 
    phi = 25, duplicate = "error", LP = TRUE, expand = 0.5, scale = TRUE, 
    fr = 2, ticktype = "simple", ...) 
{
    x = as.matrix(x)
    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)
    flag <- (y == 1)
    phat <- NA
    m1 = matrix(NA, nrow = length(y), ncol = length(y))
    for (i in 1:nrow(x)) m1[, i] <- mahalanobis(x, x[i, ], m$cov)
    m2 <- exp(-1 * m1) * (sqrt(m1) <= fr)
    m3 <- matrix(y, length(y), length(y)) * m2
    phat = apply(m3, 2, sum)/apply(m2, 2, sum)
    if (p == 1) {
        if (plotit) {
            plot(x, y, xlab = xlab, ylab = ylab)
            flag2 <- order(x)
            lines(x[flag2], phat[flag2])
        }
    }
    if (p == 2) {
        if (plotit) {
            library(akima)
            if (pr) {
                if (!scale) 
                  print("With dependence, suggest using scale=T")
            }
            fitr <- phat
            iout <- c(1:length(fitr))
            nm1 <- length(fitr) - 1
            for (i in 1:nm1) {
                ip1 <- i + 1
                for (k in ip1:length(fitr)) if (sum(x[i, ] == 
                  x[k, ]) == 2) 
                  iout[k] <- 0
            }
            fitr <- fitr[iout >= 1]
            if (LP) 
                fitr = lplot(x[iout >= 1, ], fitr, pyhat = TRUE, 
                  pr = FALSE, plotit = FALSE)$yhat
            mkeep <- x[iout >= 1, ]
            fit <- interp(mkeep[, 1], mkeep[, 2], fitr, duplicate = duplicate)
            persp(fit, theta = theta, phi = phi, expand = expand, 
                scale = scale, xlab = xlab, ylab = ylab, zlab = zlab, 
                ticktype = ticktype)
        }
    }
    if (!pyhat) 
        phat <- "Done"
    phat
  }

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