R/eval_chf.R

Defines functions enframe_chf eval_chf.dst eval_chf

Documented in enframe_chf eval_chf

#' Cumulative Hazard Function
#'
#' Access a distribution's cumulative hazard function (chf).
#'
#' @inheritParams eval_cdf
#' @return The evaluated cumulative hazard
#' in vector form (for `eval_`) and data frame
#' or tibble form (for `enframe_`).
#' @examples
#' d <- dst_unif(0, 4)
#' eval_chf(d, at = 0:4)
#' enframe_chf(d, at = 0:4)
#' @family distributional representations
#' @rdname chf
#' @export
eval_chf <- function(distribution, at) UseMethod("eval_chf")

#' @export
eval_chf.dst <- function(distribution, at) {
  if (variable(distribution) == "continuous") {
    sf <- eval_survival(distribution, at = at)
    -log(sf)
  } else {
    stop("Not programmed yet")
  }
}

#' @rdname chf
#' @export
enframe_chf <- function(..., at, arg_name = ".arg", fn_prefix = "chf",
						sep = "_") {
	enframe_general(..., at = at, arg_name = arg_name, fn_prefix = fn_prefix,
					sep = sep, eval_fn = eval_chf)
}
vincenzocoia/distionary documentation built on March 5, 2024, 3:13 a.m.