regYci:

Usage Arguments Examples

Usage

1
regYci(x, y, regfun = tsreg, pts = unique(x), nboot = 100, ADJ = FALSE, xout = FALSE, outfun = out, SEED = TRUE, alpha = 0.05, crit = NULL, null.value = 0, plotPV = FALSE, scale = TRUE, span = 0.75, xlab = "X", xlab1 = "X1", xlab2 = "X2", ylab = "p-values", zlab = "p-values", theta = 50, phi = 25, MC = FALSE, nreps = 1000, SM = FALSE, pch = "*", ...)

Arguments

x
y
regfun
pts
nboot
ADJ
xout
outfun
SEED
alpha
crit
null.value
plotPV
scale
span
xlab
xlab1
xlab2
ylab
zlab
theta
phi
MC
nreps
SM
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
85
86
87
88
89
90
##---- 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, pts = unique(x), nboot = 100, 
    ADJ = FALSE, xout = FALSE, outfun = out, SEED = TRUE, alpha = 0.05, 
    crit = NULL, null.value = 0, plotPV = FALSE, scale = TRUE, 
    span = 0.75, xlab = "X", xlab1 = "X1", xlab2 = "X2", ylab = "p-values", 
    zlab = "p-values", theta = 50, phi = 25, MC = FALSE, nreps = 1000, 
    SM = FALSE, pch = "*", ...) 
{
    xy = elimna(cbind(x, y))
    x <- as.matrix(x)
    p = ncol(x)
    p1 = p + 1
    vals = NA
    x <- xy[, 1:p]
    y <- xy[, p1]
    x <- as.matrix(x)
    if (xout) {
        m <- cbind(x, y)
        flag <- outfun(x, plotit = FALSE, ...)$keep
        m <- m[flag, ]
        n = nrow(m)
        x <- m[, 1:p]
        y <- m[, p1]
        x = as.matrix(x)
    }
    if (ADJ) {
        if (n < 10) 
            stop("Should have a sample size of at least 10")
        if (alpha == 0.05) {
            alpha = 0.01
            if (identical(regfun, ols)) {
                nv = c(10, 20, 50, 100, 400)
                pval = c(0.001, 0.004, 0.008, 0.008, 0.01)
                ipos = sum(nv <= n)
                alpha = pval[ipos]
            }
            if (identical(regfun, tshdreg)) 
                alpha = 0.009
            if (identical(regfun, qreg)) 
                alpha = 0.009
            crit = qnorm(1 - alpha/2)
        }
    }
    if (SEED) 
        set.seed(2)
    if (is.null(crit)) {
        if (!ADJ) 
            crit = qnorm(1 - alpha/2)
        if (ADJ) {
            padj = regYciCV(n, nboot = nreps, regfun = regfun, 
                MC = MC, SEED = FALSE, null.value = 0, ...)
            crit = qnorm(1 - padj/2)
        }
    }
    sqsd = regYvar(x, y, regfun = regfun, pts = pts, nboot = nboot, 
        SEED = SEED)
    sd = sqrt(sqsd)
    est = regYhat(x, y, regfun = regfun, xr = pts, ...)
    pv = 2 * (1 - pnorm(abs(est - null.value)/sd))
    est = cbind(est, est - crit * sd, est + crit * sd, pv)
    dimnames(est) = list(NULL, c("Pred. Y", "Lower.ci", "Upper.ci", 
        "p.value"))
    if (plotPV) {
        if (ncol(x) > 2) 
            stop("Can plot only with one or two independent variables")
        if (ncol(x) == 1) 
            plot(pts, pv, xlab = xlab, ylab = ylab, pch = pch)
        if (ncol(x) == 2) {
            if (SM) 
                lplot(pts, pv, xlab = xlab1, ylab = xlab2, zlab = zlab, 
                  span = span, ticktype = "detail", scale = scale, 
                  theta = theta, phi = phi)
            if (!SM) 
                scatterplot3d(pts[, 1], pts[, 2], pv, xlab = xlab1, 
                  ylab = xlab2, zlab = zlab)
        }
    }
    if (p == 1) {
        xord = order(pts)
        outp = cbind(pts[xord], est[xord, ])
        dimnames(outp) = list(NULL, c("X", "Pred. Y", "Lower.ci", 
            "Upper.ci", "p.value"))
        est = outp
    }
    est
  }

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