Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lowerBound in weighted.quantile function #39

Open
javakh opened this issue Sep 17, 2016 · 1 comment
Open

lowerBound in weighted.quantile function #39

javakh opened this issue Sep 17, 2016 · 1 comment

Comments

@javakh
Copy link

javakh commented Sep 17, 2016

You have used lowerBound function inside the script of weighted.quantile function.
[weighted.quantile <- function (x, w, probs = seq(0, 1, 0.25), na.rm = FALSE) {
stopifnot(length(x) == length(w))
na <- is.na(x) | is.na(w)
if (any(na)) {
if (na.rm) {
x <- x[!na]
w <- w[!na]
} else {
stop("Missing values not allowed when na.rm is FALSE", call. = FALSE)
}
}

Ensure x and w in ascending order of x

ord <- order(x)
x <- x[ord]
w <- w[ord]

Find closest x just below and above index

n <- sum(w)
index <- 1 + (n - 1) * probs
j <- floor(index)

wts <- cumsum(w)
lo <- x[lowerBound(j, wts)] # X_j
hi <- x[lowerBound(j + 1, wts)]

g <- index - j
ifelse(lo == hi, lo, (1 - g) * lo + g * hi)
}
]

But the lowerBound function does not exist in R.

?lowerBound
No documentation for ‘lowerBound’ in specified packages and libraries:
you could try ‘??lowerBound

??lowerBound also showed there is no such function in R.

So, How does it run inside your script???

@gvegayon
Copy link

Here you have

IntegerVector lowerBound(const NumericVector& x, const NumericVector& breaks) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants