stsregp1:

Usage Arguments Examples

Usage

1
stsregp1(x, y, sc = pbvar, xout = FALSE, outfun = out, ...)

Arguments

x
y
sc
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
##---- 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, sc = pbvar, xout = FALSE, outfun = out, ...) 
{
    xy = elimna(cbind(x, y))
    p = ncol(as.matrix(x))
    if (p != 1) 
        stop("Current version is limited to one predictor")
    p1 = p + 1
    x = xy[, 1:p]
    y = xy[, p1]
    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)
    }
    ord <- order(x)
    xs <- x[ord]
    ys <- y[ord]
    vec1 <- outer(ys, ys, "-")
    vec2 <- outer(xs, xs, "-")
    v1 <- vec1[vec2 > 0]
    v2 <- vec2[vec2 > 0]
    slope <- v1/v2
    allvar <- NA
    for (i in 1:length(slope)) allvar[i] <- sc(y - slope[i] * 
        x, ...)
    temp <- order(allvar)
    coef <- 0
    coef[2] <- slope[temp[1]]
    coef[1] <- median(y) - coef[2] * median(x)
    res <- y - coef[2] * x - coef[1]
    list(coef = coef, residuals = res)
  }

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