qreg_1:

Usage Arguments Examples

Usage

1
Qreg(x, y, q = 0.5, xout = FALSE, outfun = outpro, res.vals = TRUE, plotit = FALSE, xlab = "X", ylab = "Y", ...)

Arguments

x
y
q
xout
outfun
res.vals
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
##---- 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, q = 0.5, xout = FALSE, outfun = outpro, res.vals = TRUE, 
    plotit = FALSE, xlab = "X", ylab = "Y", ...) 
{
    x <- as.matrix(x)
    xx <- cbind(x, y)
    xx <- elimna(xx)
    xx = as.matrix(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)
    }
    init = ols(x, y)$coef
    v = optim(init, qfun, x = x, y = y, q = q, method = "BFGS")$par
    p1 = ncol(x) + 1
    res = NULL
    if (res.vals) 
        res <- y - x %*% v[2:p1] - v[1]
    if (ncol(x) == 1) {
        if (plotit) {
            plot(x, y, xlab = xlab, ylab = ylab)
            abline(v)
        }
    }
    list(coef = v, residuals = res)
  }

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