R/cdf_t.R

Defines functions cdf_t

#' @import rlang stats stringr
cdf_t <- function(x,
                  t,
                  n1,
                  n2 = NULL,
                  ind_samples = FALSE,
                  prior_loc,
                  prior_scale,
                  prior_df,
                  rel_tol = .Machine$double.eps^0.25) {
  out <- integrate(posterior_t,
                   lower = -Inf,
                   upper = x,
                   t = t,
                   n1 = n1,
                   n2 = n2,
                   ind_samples = ind_samples,
                   prior_loc = prior_loc,
                   prior_scale = prior_scale,
                   prior_df = prior_df,
                   rel.tol = rel_tol)$value
  if (out > 1) {
    out <- 1
    warn(str_c(
      "Numerical integration yields a CDF value slightly larger than 1. ",
      "The CDF value has been replaced by 1."
    ))
  }
  out
}

Try the baymedr package in your browser

Any scripts or data that you put into this service are public.

baymedr documentation built on March 28, 2021, 9:08 a.m.