Description Usage Arguments Details Value Author(s) References Examples
Qkde complains if the output is not sorted. Theoretically it is impossible for this to happen, but in practise floating point error can allow this to occur. This function is a cheap work-around to this problem.
1 | qkdeSorted(p, fhat)
|
p |
See qkde in package ks |
fhat |
See qkde in package ks |
See qkde in package ks
See qkde in package ks
Luke Mazur
see package ks
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 | ##---- 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 (p, fhat)
{
if (any(p > 1) | any(p < 0))
stop("p must be <= 1 and >= 0")
cumul.prob <- pkde(q = fhat$eval.points, fhat = fhat)
ind <- findIntervalSorted(x = p, vec = cumul.prob)
quant <- rep(0, length(ind))
for (j in 1:length(ind)) {
i <- ind[j]
if (i == 0)
quant[j] <- fhat$eval.points[1]
else if (i >= length(fhat$eval.points))
quant[j] <- fhat$eval.points[length(fhat$eval.points)]
else {
quant1 <- fhat$eval.points[i]
quant2 <- fhat$eval.points[i + 1]
prob1 <- cumul.prob[i]
prob2 <- cumul.prob[i + 1]
alpha <- (p[j] - prob2)/(prob1 - prob2)
quant[j] <- quant1 * alpha + quant2 * (1 - alpha)
}
}
return(quant)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.