R/AllClasses.R

Defines functions valid_skewtFit

########################################################################################################
#
# DEFINITION OF CLASSES AND CORRESPONDING VALIDITY CHECKS
#
########################################################################################################


########################################################################################################
# CLASS skewtFit
########################################################################################################

setClass("skewtFit", representation("list"), prototype = prototype(elementType = "list"), contains="list")

valid_skewtFit <- function(object) {
  msg <- NULL
  if (!all(c('mu','Sigma','alpha','nu','probs','probcluster','G','ttype') %in% names(object))) msg <- "skewtFit object missing either mu, Sigma, alpha, nu, probs, probscluster or G"
  if (length(object$mu)!=object$G) msg <- "mu has the wrong length"
  if (length(object$Sigma)!=object$G) msg <- "Sigma has the wrong length"
  if (length(object$alpha)!=object$G) msg <- "alpha has the wrong length"
  if (length(object$nu)!=object$G) msg <- "nu has the wrong length"
  if (ncol(object$probs) != object$G) msg <- "probs has the wrong number of columns"
  if (!(object$ttype %in% c('independent','dependent'))) stop("ttype must be 'independent' or 'dependent'")
  if(!(is.null(msg))) { TRUE } else { msg }
}

setValidity("skewtFit", valid_skewtFit)

Try the twopiece package in your browser

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

twopiece documentation built on May 2, 2019, 5:32 p.m.