liesInSupport: Generic Function for Testing the Support of a Distribution

liesInSupportR Documentation

Generic Function for Testing the Support of a Distribution

Description

The function tests if x lies in the support of the distribution object.

Usage

liesInSupport(object, x, ...)
## S4 method for signature 'UnivarLebDecDistribution,numeric'
liesInSupport(object,x, checkFin = FALSE)
## S4 method for signature 'UnivarMixingDistribution,numeric'
liesInSupport(object,x, checkFin = FALSE)
## S4 method for signature 'LatticeDistribution,numeric'
liesInSupport(object,x, checkFin = FALSE)
## S4 method for signature 'DiscreteDistribution,numeric'
liesInSupport(object,x, checkFin = FALSE)
## S4 method for signature 'AbscontDistribution,numeric'
liesInSupport(object,x, checkFin = FALSE)
## S4 method for signature 'Distribution,matrix'
liesInSupport(object,x, checkFin = FALSE)
## S4 method for signature 'ExpOrGammaOrChisq,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Lnorm,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Fd,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Norm,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'DExp,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Cauchy,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Td,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Logis,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Weibull,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Unif,numeric'
liesInSupport(object,x, checkFin = TRUE)
## S4 method for signature 'Beta,numeric'
liesInSupport(object,x, checkFin = TRUE)

Arguments

object

object of class "Distribution"

x

numeric vector or matrix

checkFin

logical: in case FALSE, we simply check whether x lies in the numerical (i.e., possibly cut to relevant quantile range) support; in case TRUE we try to check this by more exact techniques (e.g. in case of lattice distributions) and by using slot .finSupport / the return values of q.l(object) in 0 and 1. This is only used on discrete (parts of) distributions).

...

used for specific arguments to particular methods.

Value

logical vector

Methods

object = "DiscreteDistribution", x = "numeric":

We return a logical vector of the same length as x with TRUE when x lies in the support of object. As support we use the value of support(object), so this is possibly cut to relevant quantile ranges. In case checkFin is TRUE, in addition, we flag those coordinates to TRUE where x < min(support(object)) if is.na(object@.finSupport[1]) or object@.finSupport[1]==FALSE or q.l(object)(0)==-Inf, and similarly, where x > max(support(object)) if is.na(object@.finSupport[2]) or object@.finSupport[2]==FALSE or q.l(object)(1)==Inf. In addition we flag those coordinates to TRUE where q.l(object)(0)<=x<min(support(object)) if object@.finSupport[1]==TRUE and, similarly, where q.l(object)(1)>=x>max(support(object)) if object@.finSupport[2]==TRUE.

object = "Distribution", x = "matrix":

Argument x is cast to vector and then the respective liesInSupport method for vectors is called. The method throws an arror when the dispatch mechanism does not find a suitable, applicable respective vector-method.

object = "AbscontDistribution", x = "numeric":

We return a logical vector of the same length as x with TRUE where q.l(object)(0)<=x<=q.l(object)(1) (and replace the boundary values by q.l(object)(10*.Machine$double.eps) resp. q.l(object)(1-10*.Machine$double.eps) once the return values for 0 or 1 return are NaN.

object = "LatticeDistribution", x = "numeric":

We return a logical vector of the same length as x with TRUE when x lies in the support of object. As support we use the value of support(object), so this is possibly cut to relevant quantile ranges. In case checkFin is TRUE, we instead use the lattice information: We check whether all values (x-pivot(lattice(object))/width(lattice(object)) are non-negative integers and are non larger than Length(lattice(object))-1. In addition, we flag those coordinates to TRUE where x < min(support(object)) if is.na(object@.finSupport[1]) or object@.finSupport[1]==FALSE, and similarly, where x > max(support(object)) if is.na(object@.finSupport[2]) or object@.finSupport[2]==FALSE.

object = "UnivarLebDecDistribution", x = "numeric":

We split up object into discrete and absolutely continuous part and for each of them apply liesInSupport separately; the two return values are combined by a coponentwise logical |.

object = "UnivarMixingDistribution", x = "numeric":

We first cast object to UnivarLebDecDistribution by flat.mix and then apply the respective method.

Author(s)

Matthias Kohl Matthias.Kohl@stamats.de and Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de

See Also

Distribution-class

Examples

liesInSupport(Exp(1), rnorm(10))

# note
x <- rpois(10, lambda = 10)
liesInSupport(Pois(1), x)
# better
liesInSupport(Pois(1), x, checkFin = TRUE)
liesInSupport(Pois(1), 1000*x, checkFin = TRUE)
liesInSupport(-10*Pois(1), -10*x+1, checkFin = TRUE)

xs = c(1000*x,runif(10))
D <- UnivarMixingDistribution(Pois(1),Unif())
liesInSupport(D, xs)


distr documentation built on Jan. 29, 2024, 3 a.m.