1  | 
x | 
|
y | 
|
est | 
|
tr | 
|
nboot | 
|
alpha | 
|
fr | 
|
jv | 
|
SEED | 
|
... | 
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 = mean, tr = 0, nboot = 600, alpha = 0.05, 
    fr = NA, jv = NA, SEED = TRUE, ...) 
{
    x = as.matrix(x)
    if (!is.matrix(x)) 
        stop("X values should be stored in a matrix")
    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 (is.na(fr)) {
        if (tr == 0.2) {
            nval <- c(20, 40, 60, 80, 120, 160)
            fval <- c(1.2, 1, 0.85, 0.75, 0.65, 0.65)
            if (length(y) <= 160) 
                fr <- approx(nval, fval, length(y))$y
            if (length(y) > 160) 
                fr <- 0.65
        }
        if (tr == 0) {
            nval <- c(20, 40, 60, 80, 120, 160)
            fval <- c(0.8, 0.7, 0.55, 0.5, 0.5, 0.5)
            if (length(y) <= 160) 
                fr <- approx(nval, fval, length(y))$y
            if (length(y) > 160) 
                fr <- 0.6
        }
    }
    if (is.na(fr)) 
        stop("Span can be deteremined only for 0 or .2 trimming")
    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))
        }
    }
    if (!is.na(jv)) 
        prval <- jv
    if (is.na(jv)) 
        prval <- c(1:ncol(x))
    c.sum <- matrix(NA, nrow = length(prval), ncol = 2)
    dimnames(c.sum) <- list(NULL, c("d.stat", "p.value"))
    for (ip in 1:length(prval)) {
        flag <- rep(T, ncol(x))
        flag[prval[ip]] <- F
        yhat <- adrun(x[, flag], y, plotit = FALSE, fr = fr, 
            pyhat = T)
        regres <- y - yhat
        temp <- indt(x[, !flag], regres)
        c.sum[ip, 1] <- temp$dstat
        c.sum[ip, 2] <- temp$p.value.d
    }
    list(results = c.sum)
  }
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.