lintestMC:

Usage Arguments Examples

Usage

1
lintestMC(x, y, regfun = tsreg, nboot = 500, alpha = 0.05, xout = FALSE, outfun = out, ...)

Arguments

x
y
regfun
nboot
alpha
xout
outfun
...

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
##---- 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, nboot = 500, alpha = 0.05, xout = FALSE, 
    outfun = out, ...) 
{
    library(parallel)
    set.seed(2)
    x <- as.matrix(x)
    d <- ncol(x)
    temp <- elimna(cbind(x, y))
    x <- temp[, 1:d]
    x <- as.matrix(x)
    y <- temp[, d + 1]
    if (xout) {
        flag <- outfun(x, ...)$keep
        x <- x[flag, ]
        x <- as.matrix(x)
        y <- y[flag]
    }
    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))
        }
    }
    reg <- regfun(x, y, ...)
    yhat <- y - reg$residuals
    print("Taking bootstrap sample, please wait.")
    data <- matrix(runif(length(y) * nboot), nrow = nboot)
    data <- sqrt(12) * (data - 0.5)
    data = listm(t(data))
    rvalb <- mclapply(data, lintests1, yhat, reg$residuals, mflag, 
        x, regfun, mc.preschedule = TRUE, ...)
    rvalb = matl(rvalb)
    rvalb <- rvalb/sqrt(length(y))
    dstatb <- apply(abs(rvalb), 2, max)
    wstatb <- apply(rvalb^2, 2, mean)
    v <- c(rep(1, length(y)))
    rval <- lintests1(v, yhat, reg$residuals, mflag, x, regfun, 
        ...)
    rval <- rval/sqrt(length(y))
    dstat <- max(abs(rval))
    wstat <- mean(rval^2)
    ib <- round(nboot * (1 - alpha))
    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.