R/initialize_weights.R

Defines functions initialize_weights

Documented in initialize_weights

#===============================================================================
# initialize_weights.R
#===============================================================================

#' @title Initialize weights
#'
#' @details
#' Initialize the weights using the histogram of p_hat
#'
#' @param data_table Input data table
#' @param n_breaks Number of breaks for the histogram
#' @param spline_order Order of splines
#' @param plot Logical. Produce a histogram plot if true
#' @return Histogram values
#' @export
#' @seealso \code{\link{npbin}}, \code{\link{emBspl}}, \code{\link{ebBeta}}
initialize_weights <- function(
  data_table,
  n_breaks = 11,
  spline_order = 4,
  plot = FALSE
) {
  h <- hist(
    data_table[, p_hat],
    breaks = seq(0, 1, length.out = n_breaks + spline_order - 3),
    plot = plot
  )
  h[["density"]]
}
anthony-aylward/npbin documentation built on Aug. 22, 2019, 8:08 a.m.