R/dist_df_related.R

Defines functions is.distreg.fam is.betareg is.bamlss is.gamlss is.discrete is.continuous has.moments is.implemented

Documented in has.moments is.bamlss is.betareg is.continuous is.discrete is.distreg.fam is.gamlss is.implemented

#' Internal: Distribution Implementation Checker
#'
#' Is the distribution generally implemented in the distreg.vis framework?
#' Meaning: Does \code{plot_dist()} work?
#' @keywords internal
is.implemented <- function(fam_name) {
  exists <- fam_name %in% distreg.vis::dists$dist_name
  if (exists)
    return(distreg.vis::dists[distreg.vis::dists$dist_name == fam_name, "implemented"])
  else
    return(FALSE)
}

#' Internal: Distributional Moments implementation checker
#'
#' Is the moment function of a given distribution family implemented? Meaning:
#' will \code{plot_moments()} work?
#' @keywords internal
has.moments <- function(fam_name) {
  exists <- fam_name %in% distreg.vis::dists$dist_name
  if (exists)
    return(distreg.vis::dists[distreg.vis::dists$dist_name == fam_name, "moment_funs"])
  else
    return(FALSE)
}


#' Internal: Continuous/Mixed Distribution checker
#'
#' Check whether a given distribution is at least partly continuous (could be
#' mixed as well).
#' @keywords internal
is.continuous <- function(name) {
  type <- distreg.vis::dists[distreg.vis::dists$dist_name == name, "type"]
  if (type %in% c("Mixed", "Continuous"))
    return(TRUE)
  else
    return(FALSE)
}

#' Internal: Discrete Distribution Checker
#'
#' Check whether a given distribution is fully discrete.
#' @keywords internal
is.discrete <- function(name) {
  type <- distreg.vis::dists[distreg.vis::dists$dist_name == name, "type"]
  if (type == "Discrete")
    return(TRUE)
  else
    return(FALSE)
}

#' Internal: Is gamlss family?
#'
#' Check whether a given distribution comes from the gamlss.dist package
#' @keywords internal
is.gamlss <- function(name) {
  return(any(distreg.vis::dists[distreg.vis::dists$dist_name == name, "class"] == "gamlss"))
}

#' Internal: Is bamlss family?
#'
#' Check whether a given distribution comes from the bamlss package
#' @keywords internal
is.bamlss <- function(name) {
  return(any(distreg.vis::dists[distreg.vis::dists$dist_name == name, "class"] == "bamlss"))
}

#' Internal: Is betareg family?
#'
#' Check whether a given distribution comes from the betareg package
#' @keywords internal
is.betareg <- function(name) {
  return(any(distreg.vis::dists[distreg.vis::dists$dist_name == name, "class"] == "betareg"))
}

#' Internal: Is distreg family
#'
#' Check whether a given distribution is a distributional regression family
#' @keywords internal
#' @details See which classes are currently supported at \link{distreg_checker}.
is.distreg.fam <- function(name) {
  if (is.gamlss(name))
    return(TRUE)
  else if (is.bamlss(name))
    return(TRUE)
  else if (is.betareg(name))
    return(TRUE)
  else
    FALSE
}

Try the distreg.vis package in your browser

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

distreg.vis documentation built on Oct. 27, 2023, 9:07 a.m.