df <- data.frame(x = rnorm(1e3), y = rnorm(1e3))
# Two ways to specify `method`
get_hdr(df, method = "kde")
get_hdr(df, method = method_kde())
if (FALSE) {
# If parenthesis are omitted, `get_hdr()` errors
get_hdr(df, method = method_kde)
}
# Estimate different HDRs with `probs`
get_hdr(df, method = method_kde(), probs = c(.975, .6, .2))
# Adjust estimator parameters with arguments to `method_kde()`
get_hdr(df, method = method_kde(h = 1))
# Parametric normal estimator of density
get_hdr(df, method = "mvnorm")
get_hdr(df, method = method_mvnorm())
# Compute "population" HDRs of specified bivariate pdf with `method = "fun"`
f <- function(x, y, sd_x = 1, sd_y = 1) dnorm(x, sd = sd_x) * dnorm(y, sd = sd_y)
get_hdr(
method = "fun", fun = f,
rangex = c(-5, 5), rangey = c(-5, 5)
)
get_hdr(
method = "fun", fun = f,
rangex = c(-5, 5), rangey = c(-5, 5),
args = list(sd_x = .5, sd_y = .5) # specify additional arguments w/ `args`
)
Run the code above in your browser using DataLab