rplotCI:

Usage Arguments Examples

Usage

1
rplotCI(x, y, tr = 0.2, fr = 0.8, plotit = TRUE, scat = TRUE, pyhat = FALSE, SEED = TRUE, dfmin = 8, eout = FALSE, xout = FALSE, xlab = "x", ylab = "y", outfun = out, LP = TRUE, alpha = 0.05, pch = ".", ...)

Arguments

x
y
tr
fr
plotit
scat
pyhat
SEED
dfmin
eout
xout
xlab
ylab
outfun
LP
alpha
pch
...

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
##---- 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, tr = 0.2, fr = 0.8, plotit = TRUE, scat = TRUE, 
    pyhat = FALSE, SEED = TRUE, dfmin = 8, eout = FALSE, xout = FALSE, 
    xlab = "x", ylab = "y", outfun = out, LP = TRUE, alpha = 0.05, 
    pch = ".", ...) 
{
    plotit <- as.logical(plotit)
    scat <- as.logical(scat)
    str = rplot(x, y, tr = tr, xout = xout, plotit = FALSE, LP = LP, 
        fr = fr, pr = FALSE)$Strength.Assoc
    m <- cbind(x, y)
    if (ncol(m) > 2) 
        stop("To get a smooth with more than one covariate, use rplot")
    m <- elimna(m)
    nv = nrow(m)
    if (eout && xout) 
        stop("Not allowed to have eout=xout=T")
    if (eout) {
        flag <- outfun(m, plotit = FALSE)$keep
        m <- m[flag, ]
    }
    if (xout) {
        flag <- outfun(m[, 1])$keep
        m <- m[flag, ]
    }
    x = m[, 1]
    y = m[, 2]
    n.keep = length(y)
    rmd <- c(1:length(x))
    for (i in 1:length(x)) rmd[i] <- mean(y[near(x, x[i], fr)], 
        tr = tr)
    sedf = runse(x, y, fr = fr, tr = tr, pts = x, SEED = SEED)
    df = sedf$df
    flag = df > dfmin
    se = sedf$se
    low = rmd[flag] - qt(1 - alpha/2, df[flag]) * se[flag]
    up = rmd[flag] + qt(1 - alpha/2, df[flag]) * se[flag]
    rmd = rmd[flag]
    x = x[flag]
    y = y[flag]
    if (plotit) {
        ord = order(x)
        x = x[ord]
        rmd = rmd[ord]
        up = up[ord]
        low = low[ord]
        if (LP) {
            rmd = lplot(x, rmd, plotit = FALSE, pyhat = TRUE, 
                pr = FALSE)$yhat
            up = lplot(x, up, plotit = FALSE, pyhat = TRUE, pr = FALSE)$yhat
            low = lplot(x, low, plotit = FALSE, pyhat = TRUE, 
                pr = FALSE)$yhat
        }
        if (scat) {
            plot(c(x, x), c(y, rmd), xlab = xlab, ylab = ylab, 
                type = "n")
            lines(x, up, lty = 2)
            lines(x, low, lty = 2)
            points(x, y, pch = pch)
        }
        if (!scat) 
            plot(c(x, x), c(y, rmd), type = "n", ylab = ylab, 
                xlab = xlab)
        points(x, rmd, type = "n")
        sx <- sort(x)
        xorder <- order(x)
        sysm <- rmd[xorder]
        lines(sx, sysm)
        lines(x, up, lty = 2)
        lines(x, low, lty = 2)
    }
    if (pyhat) {
        output <- cbind(x, rmd, low, up)
        dimnames(output) = list(NULL, c("x", "y.hat", "ci.low", 
            "ci.up"))
    }
    if (!pyhat) 
        output <- "Done"
    list(output = output, str = str, n = nv, n.keep = n.keep)
  }

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