qhat:

Usage Arguments Examples

Usage

1
qhat(x, y, nboot = 50, op = 2, SEED = TRUE, pr.track = FALSE)

Arguments

x
y
nboot
op
SEED
pr.track

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
##---- 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, nboot = 50, op = 2, SEED = TRUE, pr.track = FALSE) 
{
    x <- x[!is.na(x)]
    y <- y[!is.na(y)]
    if (SEED) 
        set.seed(2)
    print("Taking bootstrap samples. Please wait.")
    datax <- matrix(sample(length(x), size = length(x) * nboot, 
        replace = TRUE), nrow = nboot)
    datay <- matrix(sample(length(y), size = length(y) * nboot, 
        replace = TRUE), nrow = nboot)
    bidx <- apply(datax, 1, idb, n = length(x))
    bidy <- apply(datay, 1, idb, n = length(y))
    temp3 <- matrix(0, ncol = length(x), nrow = nboot)
    temp5 <- matrix(0, ncol = length(y), nrow = nboot)
    for (i in 1:nboot) {
        temp3[i, ] <- disker(x[datax[i, ]], y[datay[i, ]], x, 
            op = op)$zhat
        temp5[i, ] <- disker(y[datay[i, ]], x[datax[i, ]], y, 
            op = op)$zhat
        if (pr.track) 
            print(paste("Iteration ", i, "of ", nboot, " is complete"))
    }
    temp4 <- temp3 * t(bidx)
    temp4 <- apply(temp4, 2, sum)/apply(bidx, 1, sum)
    temp6 <- temp5 * t(bidy)
    temp6 <- apply(temp6, 2, sum)/apply(bidy, 1, sum)
    ep0x <- mean(temp4, na.rm = TRUE)
    aperrorx <- disker(x, y, op = op)$phat
    regprex <- 0.368 * aperrorx + 0.632 * ep0x
    ep0y <- mean(temp6, na.rm = TRUE)
    aperrory <- disker(y, x, op = op)$phat
    regprey <- 0.368 * aperrory + 0.632 * ep0y
    aperror <- (length(x) * aperrorx + length(y) * aperrory)/(length(x) + 
        length(y))
    regpre <- (length(x) * regprex + length(y) * regprey)/(length(x) + 
        length(y))
    list(qhat.632 = regpre)
  }

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