1 |
x |
|
y |
|
qval |
|
q |
|
pr |
|
xout |
|
outfun |
|
plotit |
|
xlab |
|
ylab |
|
zlab |
|
pyhat |
|
fr |
|
LP |
|
theta |
|
phi |
|
ticktype |
|
nmin |
|
scale |
|
pr.qhd |
|
pch |
|
... |
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 73 74 75 76 | ##---- 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, pr = FALSE, xout = FALSE,
outfun = outpro, plotit = TRUE, xlab = "X", ylab = "Y", zlab = "Z",
pyhat = FALSE, fr = NULL, LP = TRUE, theta = 50, phi = 25,
ticktype = "simple", nmin = 0, scale = TRUE, pr.qhd = TRUE,
pch = ".", ...)
{
if (!is.null(q))
qval = q
x <- as.matrix(x)
X <- cbind(x, y)
X <- elimna(X)
np <- ncol(X)
p <- np - 1
if (p > 1 & length(q) > 1)
print("Only first quantile specified can be plotted")
x <- X[, 1:p]
x <- as.matrix(x)
y <- X[, np]
if (xout) {
x <- as.matrix(x)
flag <- outfun(x, plotit = FALSE, ...)$keep
x <- x[flag, ]
y <- y[flag]
x <- as.matrix(x)
}
if (p == 1) {
if (is.null(fr))
fr = 0.8
ord = order(x)
x = sort(x)
y = y[ord]
est = matrix(NA, ncol = 3, nrow = length(qval))
dimnames(est) = list(NULL, c("q", "Inter", "Slope"))
x <- as.matrix(x)
qest = matrix(NA, ncol = length(qval), nrow = length(y))
for (j in 1:length(qval)) {
rmd = NA
for (i in 1:length(x)) rmd[i] <- hd(y[near(x, x[i],
fr)], q = qval[j])
if (LP)
rmd = lplot(x, rmd, plotit = FALSE, pyhat = TRUE,
pr = FALSE)$yhat
qest[, j] = rmd
}
if (plotit) {
plot(x, y, xlab = xlab, ylab = ylab, pch = pch)
for (j in 1:ncol(qest)) lines(x, qest[, j])
}
if (!pyhat)
qest = "DONE"
}
if (p > 1) {
if (is.null(fr))
fr = 1
if (p == 2) {
if (pr.qhd) {
if (!scale)
print("scale=F is specified. If there is dependence, might want to use scale=TRUE")
}
}
qest = rplot(x, y, est = hd, q = qval[1], fr = fr, plotit = plotit,
pyhat = pyhat, theta = theta, phi = phi, scale = scale,
SEED = FALSE, varfun = pbvar, xlab = xlab, ylab = ylab,
zlab = zlab, ticktype = ticktype, nmin = nmin, pr = pr)
if (!pyhat)
qest = "DONE"
if (pyhat)
qest = qest$yhat
}
qest
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.