adtest:

Usage Arguments Examples

Usage

1
adtest(x, y, est = tmean, nboot = 100, alpha = 0.05, fr = NA, xout = FALSE, outfun = out, SEED = TRUE, ...)

Arguments

x
y
est
nboot
alpha
fr
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
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
##---- 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, est = tmean, nboot = 100, alpha = 0.05, fr = NA, 
    xout = FALSE, outfun = out, SEED = TRUE, ...) 
{
    x = as.matrix(x)
    if (ncol(x) == 1) 
        stop("There should be two or more predictors")
    temp <- cbind(x, y)
    p <- ncol(x)
    p1 <- p + 1
    temp <- elimna(temp)
    x <- temp[, 1:p]
    x <- as.matrix(x)
    y <- temp[, p1]
    if (xout) {
        keepit <- rep(T, nrow(x))
        flag <- outfun(x, plotit = FALSE, ...)$out.id
        keepit[flag] <- F
        x <- x[keepit, ]
        y <- y[keepit]
    }
    if (alpha < 0.05 && nboot <= 100) 
        warning("You used alpha<.05 and nboot<=100")
    if (is.na(fr)) {
        fr <- 0.8
        if (ncol(x) == 2) {
            nval <- c(20, 30, 50, 80, 150)
            fval <- c(0.4, 0.36, 0.18, 0.15, 0.09)
            if (length(y) <= 150) 
                fr <- approx(nval, fval, length(y))$y
            if (length(y) > 150) 
                fr <- 7.57/length(y) + 0.05
        }
    }
    if (SEED) 
        set.seed(2)
    x <- as.matrix(x)
    mflag <- matrix(NA, nrow = length(y), ncol = length(y))
    for (j in 1:length(y)) {
        for (k in 1:length(y)) {
            mflag[j, k] <- (sum(x[j, ] <= x[k, ]) == ncol(x))
        }
    }
    yhat <- adrun(x, y, est = est, plotit = FALSE, fr = fr, pyhat = T)
    regres <- y - yhat
    print("Taking bootstrap samples, please wait.")
    data <- matrix(runif(length(y) * nboot), nrow = nboot)
    data <- sqrt(12) * (data - 0.5)
    rvalb <- apply(data, 1, adtests1, yhat, regres, mflag, x, 
        fr)
    rvalb <- rvalb/sqrt(length(y))
    dstatb <- apply(abs(rvalb), 2, max)
    wstatb <- apply(rvalb^2, 2, mean)
    v <- c(rep(1, length(y)))
    rval <- adtests1(v, yhat, regres, mflag, x, fr)
    rval <- rval/sqrt(length(y))
    dstat <- max(abs(rval))
    wstat <- mean(rval^2)
    p.value.d <- 1 - sum(dstat >= dstatb)/nboot
    p.value.w <- 1 - sum(wstat >= wstatb)/nboot
    list(dstat = dstat, wstat = wstat, p.value.d = p.value.d, 
        p.value.w = p.value.w)
  }

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