tshdreg:

Usage Arguments Examples

Usage

1
tshdreg(x, y, HD = TRUE, xout = FALSE, outfun = out, iter = 10, varfun = pbvar, corfun = pbcor, plotit = FALSE, tol = 1e-04, RES = FALSE, OPT = FALSE, xlab = "X", ylab = "Y", ...)

Arguments

x
y
HD
xout
outfun
iter
varfun
corfun
plotit
tol
RES
OPT
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
69
70
71
72
##---- 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, HD = TRUE, xout = FALSE, outfun = out, iter = 10, 
    varfun = pbvar, corfun = pbcor, plotit = FALSE, tol = 1e-04, 
    RES = FALSE, OPT = FALSE, xlab = "X", ylab = "Y", ...) 
{
    x <- as.matrix(x)
    xx <- cbind(x, y)
    xx <- elimna(xx)
    x <- xx[, 1:ncol(x)]
    x <- as.matrix(x)
    y <- xx[, ncol(x) + 1]
    temp <- NA
    x <- as.matrix(x)
    if (xout) {
        x <- as.matrix(x)
        flag <- outfun(x, plotit = plotit, ...)$keep
        x <- x[flag, ]
        y <- y[flag]
        x <- as.matrix(x)
    }
    if (ncol(x) == 1) {
        temp1 <- tshd(x, y, HD = HD, plotit = plotit, xlab = xlab, 
            ylab = ylab, OPT = OPT)
        coef <- temp1$coef
        res <- y - coef[2] * x - coef[1]
    }
    if (ncol(x) > 1) {
        for (p in 1:ncol(x)) {
            temp[p] <- tshd(x[, p], y)$coef[2]
        }
        res <- y - x %*% temp
        alpha <- hd(res)
        r <- matrix(NA, ncol = ncol(x), nrow = nrow(x))
        tempold <- temp
        for (it in 1:iter) {
            for (p in 1:ncol(x)) {
                r[, p] <- y - x %*% temp - alpha + temp[p] * 
                  x[, p]
                temp[p] <- tshd(x[, p], r[, p], plotit = FALSE)$coef[2]
            }
            if (max(abs(temp - tempold)) < tol) 
                break
            alpha <- hd(y - x %*% temp)
            tempold <- temp
        }
        coef <- c(alpha, temp)
        res <- y - x %*% temp - alpha
    }
    yhat <- y - res
    stre = NULL
    temp = varfun(y)
    if (temp == 0) 
        print("Warning: When computing strength of association, measure of variation=0")
    e.pow = NULL
    if (temp > 0) {
        e.pow <- varfun(yhat)/varfun(y)
        if (!is.na(e.pow)) {
            if (e.pow >= 1) 
                e.pow <- corfun(yhat, y)$cor^2
            e.pow = as.numeric(e.pow)
            stre = sqrt(e.pow)
        }
    }
    if (!RES) 
        res = NULL
    list(coef = coef, residuals = res, Strength.Assoc = stre, 
        Explanatory.Power = e.pow, residuals = res)
  }

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