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

Quantile transform sometimes generates NA values #34

Closed
rplzzz opened this issue Nov 9, 2019 · 0 comments
Closed

Quantile transform sometimes generates NA values #34

rplzzz opened this issue Nov 9, 2019 · 0 comments
Assignees
Labels

Comments

@rplzzz
Copy link
Contributor

rplzzz commented Nov 9, 2019

The problem seems to be with the interpolation function used to approximate the quantile function:

inv.ecdf <- function(column.resids) {
# for one column of the residuals, get the order of points.
order.vector <- rank(column.resids)
# cumulative probabilities are order-1 / Ntime+1
probabilities <- (order.vector - 1) * offset
# return the ecdf for the function
approxfun(x = probabilities, y = column.resids)
}

By default, approxfun produces NA values for inputs outside the range of x-values used to construct the approximation. In theory, this should never happen, but due to roundoff error the largest or smallest value in the empirical distribution can sometimes appear to be out of range. The easiest fix will be to specify rule=2 in the call to approxfun, which will cause these values to be clamped to the range of the x-values used to construct the approximator, which is what we want anyhow.

@rplzzz rplzzz self-assigned this Nov 9, 2019
@rplzzz rplzzz added the bug label Nov 9, 2019
@rplzzz rplzzz closed this as completed in 73ca2f2 Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant