olswbtest:

Usage Arguments Examples

Usage

1
olswbtest(x, y, nboot = 500, SEED = TRUE, RAD = TRUE, alpha = 0.05)

Arguments

x
y
nboot
SEED
RAD
alpha

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
##---- 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 = 500, SEED = TRUE, RAD = TRUE, alpha = 0.05) 
{
    if (SEED) 
        set.seed(2)
    x <- as.matrix(x)
    temp <- cbind(x, y)
    temp <- elimna(temp)
    pval <- ncol(temp) - 1
    x <- temp[, 1:pval]
    y <- temp[, pval + 1]
    x <- as.matrix(x)
    p <- ncol(x)
    pp <- p + 1
    temp <- lsfit(x, y)
    yhat <- mean(y)
    res <- y - yhat
    s <- olshc4(x, y)$cov[-1, -1]
    si <- solve(s)
    b <- temp$coef[2:pp]
    test = abs(b) * sqrt(diag(si))
    if (RAD) 
        data <- matrix(ifelse(rbinom(length(y) * nboot, 1, 0.5) == 
            1, -1, 1), nrow = nboot)
    if (!RAD) {
        data <- matrix(runif(length(y) * nboot), nrow = nboot)
        data <- (data - 0.5) * sqrt(12)
    }
    rvalb <- apply(data, 1, olswbtest.sub, yhat, res, x)
    rvalb = abs(rvalb)
    ic = round((1 - alpha) * nboot)
    if (p == 1) 
        rvalb = t(as.matrix(rvalb))
    temp = apply(rvalb, 1, sort)
    pvals = NA
    for (j in 1:p) pvals[j] = mean((rvalb[j, ] >= test[j]))
    cr = temp[ic, ]
    ci = b - cr/diag(sqrt(si))
    ci = cbind(ci, b + cr/diag(sqrt(si)))
    ci = cbind(b, ci)
    ci = cbind(c(1:nrow(ci)), ci, test, pvals)
    dimnames(ci) <- list(NULL, c("Slope_No.", "Slope_est", "Lower.ci", 
        "Upper.ci", "Test.Stat", "p.value"))
    ci
  }

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