qregplots:

Usage Arguments Examples

Usage

1
qregplots(x, y, qval = 0.5, q = NULL, op = 1, pr = FALSE, xout = FALSE, outfun = out, plotit = FALSE, xlab = "X", ylab = "Y", ...)

Arguments

x
y
qval
q
op
pr
xout
outfun
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
39
40
41
42
##---- 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, qval = 0.5, q = NULL, op = 1, pr = FALSE, xout = FALSE, 
    outfun = out, plotit = FALSE, xlab = "X", ylab = "Y", ...) 
{
    if (!is.null(q)) 
        qval = q
    x <- as.matrix(x)
    if (ncol(x) != 1) 
        stop("Current version allows only one predictor")
    X <- cbind(x, y)
    X <- elimna(X)
    np <- ncol(X)
    p <- np - 1
    x <- X[, 1:p]
    x <- as.matrix(x)
    y <- X[, np]
    if (xout) {
        x <- as.matrix(x)
        flag <- outfun(x, ...)$keep
        x <- x[flag, ]
        y <- y[flag]
        x <- as.matrix(x)
    }
    est = matrix(NA, ncol = 3, nrow = length(qval))
    dimnames(est) = list(NULL, c("q", "Inter", "Slope"))
    library(quantreg)
    x <- as.matrix(x)
    plot(x, y, xlab = xlab, ylab = ylab)
    if (ncol(x) != 1) 
        stop("Current version allows only one predictor")
    for (j in 1:length(qval)) {
        coef = coefficients((rq(y ~ x, tau = qval[j])))
        est[j, 1] = qval[j]
        est[j, 2:3] = coef
        abline(coef)
    }
    list(coef = est)
  }

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