lplot:

Usage Arguments Examples

Usage

1
lplot(x, y, span = 0.75, pyhat = FALSE, eout = FALSE, xout = FALSE, outfun = outpro, plotit = TRUE, expand = 0.5, low.span = 2/3, varfun = pbvar, cor.op = FALSE, cor.fun = pbcor, pr = TRUE, scale = TRUE, xlab = "X", ylab = "Y", zlab = "", theta = 50, phi = 25, family = "gaussian", duplicate = "error", pc = "*", ticktype = "simple", frame = TRUE, ...)

Arguments

x
y
span
pyhat
eout
xout
outfun
plotit
expand
low.span
varfun
cor.op
cor.fun
pr
scale
xlab
ylab
zlab
theta
phi
family
duplicate
pc
ticktype
frame
...

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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
##---- 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, span = 0.75, pyhat = FALSE, eout = FALSE, xout = FALSE, 
    outfun = outpro, plotit = TRUE, expand = 0.5, low.span = 2/3, 
    varfun = pbvar, cor.op = FALSE, cor.fun = pbcor, pr = TRUE, 
    scale = TRUE, xlab = "X", ylab = "Y", zlab = "", theta = 50, 
    phi = 25, family = "gaussian", duplicate = "error", pc = "*", 
    ticktype = "simple", frame = TRUE, ...) 
{
    library(stats)
    x <- as.matrix(x)
    m <- elimna(cbind(x, y))
    n.orig = nrow(m)
    n.keep = n.orig
    if (!is.matrix(x)) 
        stop("x is not a matrix")
    d <- ncol(x)
    if (d >= 2) {
        library(akima)
        if (ncol(x) == 2 && !scale) {
            if (pr) {
                print("scale=F is specified.")
                print("If there is dependence, might use scale=T")
                print("To get a p-value, based on the measure of the")
                print("strength of association based on this function,")
                print("use the function lplotPV")
            }
        }
        x <- m[, 1:d]
        y <- m[, d + 1]
        if (eout && xout) 
            stop("Can't have both eout and xout = F")
        if (eout) {
            flag <- outfun(m, plotit = FALSE, ...)$keep
            m <- m[flag, ]
            n.keep = nrow(m)
        }
        if (xout) {
            flag <- outfun(x, plotit = FALSE, ...)$keep
            m <- m[flag, ]
            n.keep = nrow(m)
        }
        x <- m[, 1:d]
        y <- m[, d + 1]
        if (d == 2) 
            fitr <- fitted(loess(y ~ x[, 1] * x[, 2], span = span, 
                family = family))
        if (d == 3) 
            fitr <- fitted(loess(y ~ x[, 1] * x[, 2] * x[, 3], 
                span = span, family = family))
        if (d == 4) 
            fitr <- fitted(loess(y ~ x[, 1] * x[, 2] * x[, 3] * 
                x[, 4], span = span, family = family))
        if (d > 4) 
            stop("Can have at most four predictors")
        last <- fitr
        if (d == 2 && plotit) {
            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]
            mkeep <- x[iout >= 1, ]
            fitr <- interp(mkeep[, 1], mkeep[, 2], fitr, duplicate = duplicate)
            persp(fitr, theta = theta, phi = phi, xlab = xlab, 
                ylab = ylab, zlab = zlab, expand = expand, scale = scale, 
                ticktype = ticktype)
        }
    }
    if (d == 1) {
        m <- elimna(cbind(x, y))
        x <- m[, 1:d]
        y <- m[, d + 1]
        if (eout && xout) 
            stop("Can't have both eout and xout = T")
        if (eout) {
            flag <- outfun(m, plotit = FALSE, ...)$keep
            m <- m[flag, ]
            n.keep = nrow(m)
        }
        if (xout) {
            flag <- outfun(x, plotit = FALSE, ...)$keep
            m <- m[flag, ]
            n.keep = nrow(m)
        }
        x <- m[, 1:d]
        y <- m[, d + 1]
        if (plotit) {
            plot(x, y, xlab = xlab, ylab = ylab, pch = pc, frame = frame)
            lines(lowess(x, y, f = low.span))
        }
        tempxy <- lowess(x, y, f = low.span)
        yyy <- tempxy$y
        xxx <- tempxy$x
        last <- yyy
        chkit <- sum(duplicated(x))
        if (chkit > 0) {
            last <- rep(1, length(y))
            for (j in 1:length(yyy)) {
                for (i in 1:length(y)) {
                  if (x[i] == xxx[j]) 
                    last[i] <- yyy[j]
                }
            }
        }
    }
    E.power <- 1
    if (!cor.op) 
        E.power <- varfun(last[!is.na(last)])/varfun(y)
    if (cor.op || E.power >= 1) {
        if (d == 1) {
            xord <- order(x)
            E.power <- cor.fun(last, y[xord])$cor^2
        }
        if (d > 1) 
            E.power <- cor.fun(last, y)$cor^2
    }
    E.power = as.numeric(E.power)
    if (!pyhat) 
        last <- NULL
    list(Strength.Assoc = sqrt(E.power), Explanatory.power = E.power, 
        yhat.values = last, n = n.orig, n.keep = n.keep)
  }

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