hc4test:

Usage Arguments Examples

Usage

1
hc4test(x, y, pval = c(1:ncol(x)), xout = FALSE, outfun = outpro, pr = TRUE, plotit = FALSE, xlab = "X", ylab = "Y", ...)

Arguments

x
y
pval
xout
outfun
pr
plotit
xlab
ylab
...

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
##---- 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, pval = c(1:ncol(x)), xout = FALSE, outfun = outpro, 
    pr = TRUE, plotit = FALSE, xlab = "X", ylab = "Y", ...) 
{
    x <- as.matrix(x)
    if (ncol(x) > 1 && pr) 
        print("WARNING: more than 1 predictor, olstest might be better")
    if (nrow(x) != length(y)) 
        stop("Length of y does not match number of x values")
    m <- cbind(x, y)
    m <- elimna(m)
    p = ncol(x)
    p1 = p + 1
    y <- m[, p1]
    x = m[, 1:p]
    nrem = length(y)
    n = length(y)
    n.keep = n
    x <- as.matrix(x)
    if (xout) {
        flag <- outfun(x, ...)$keep
        x <- as.matrix(x)
        x <- x[flag, ]
        y <- y[flag]
        n.keep = length(y)
        x <- as.matrix(x)
    }
    n = n.keep
    pvalp1 <- pval + 1
    temp <- lsfit(x, y)
    if (plotit) {
        if (p == 1) {
            plot(x[, 1], y, xlab = xlab, ylab = ylab)
            abline(temp$coef)
        }
    }
    x <- cbind(rep(1, nrow(x)), x)
    hval <- x %*% solve(t(x) %*% x) %*% t(x)
    hval <- diag(hval)
    hbar <- mean(hval)
    delt <- cbind(rep(4, n), hval/hbar)
    delt <- apply(delt, 1, min)
    aval <- (1 - hval)^(0 - delt)
    x2 <- x[, pvalp1]
    pval <- 0 - pvalp1
    x1 <- x[, pval]
    df <- length(pval)
    x1 <- as.matrix(x1)
    imat <- diag(1, n)
    M1 <- imat - x1 %*% solve(t(x1) %*% x1) %*% t(x1)
    M <- imat - x %*% solve(t(x) %*% x) %*% t(x)
    uval <- as.vector(M %*% y)
    R2 <- M1 %*% x2
    rtr <- solve(t(R2) %*% R2)
    temp2 <- aval * uval^2
    S <- diag(aval * uval^2)
    V <- n * rtr %*% t(R2) %*% S %*% R2 %*% rtr
    nvec <- as.matrix(temp$coef[pvalp1])
    test <- n * t(nvec) %*% solve(V) %*% nvec
    test <- test[1, 1]
    p.value <- 1 - pchisq(test, df)
    list(n = nrem, n.keep = n.keep, test = test, p.value = p.value, 
        coef = temp$coef)
  }

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