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
hdr()$hdr sometimes contains only left bound, sometimes only right bound #3
Comments
The "workaround" does not fix the issue. The problem is that the densities provided are essentially triangular. x <- seq(0,1,l=1000)
hdrcde::hdr.den(den = list(x = x, y = dbeta(x, 1, 2)), prob = 99)$hdr
hdrcde::hdr.den(den = list(x = x, y = dbeta(x, 2, 1)), prob = 99)$hdr The function does not know what happens to the density outside the range (0,1). The best solution is to expand the range slightly. x <- seq(-0.01,1.01,l=1000)
hdrcde::hdr(den = list(x = x, y = dbeta(x, 1, 2)), prob = 99)$hdr
hdrcde::hdr(den = list(x = x, y = dbeta(x, 2, 1)), prob = 99)$hdr |
I see. But if I include the second density, it does solve part of my problem, because I get a NA back, instead of just a single column without a name. So then at least I know which bound could not be determined. So I think there are two issues here: the not knowing what the density is at 0 and 1; and the fact that only one column is returned when only one |
I'm having this same problem, with 3 or sometimes 5 endpoints being returned. However, the density is smooth (I've even had this problem with practically normal densities), the probability is 0.95 (not very close to 1), and the HDR intervals should not (as far as I can tell) go beyond the range of the data. I've attached a reproducible example. |
All these problems should now be fixed in the latest commit: 3db6f9b |
Examples:
This means consuming code has to guess which interval is which. A workaround is to include e.g.
prob = c(99, 0.01)
.My version: 3.2 from github.
The text was updated successfully, but these errors were encountered: