Learn R Programming

distrEx (version 2.9.5)

var: Generic Functions for the Computation of Functionals

Description

Generic functions for the computation of functionals on distributions.

Usage

IQR(x, ...)

# S4 method for UnivariateDistribution IQR(x) # S4 method for UnivariateCondDistribution IQR(x,cond) # S4 method for AffLinDistribution IQR(x) # S4 method for DiscreteDistribution IQR(x) # S4 method for Arcsine IQR(x) # S4 method for Cauchy IQR(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Dirac IQR(x) # S4 method for DExp IQR(x) # S4 method for Exp IQR(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Geom IQR(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Logis IQR(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Norm IQR(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Unif IQR(x, propagate.names=getdistrExOption("propagate.names.functionals"))

median(x, ...)

# S4 method for UnivariateDistribution median(x) # S4 method for UnivariateCondDistribution median(x,cond) # S4 method for AffLinDistribution median(x) # S4 method for Arcsine median(x) # S4 method for Cauchy median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Dirac median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for DExp median(x) # S4 method for Exp median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Geom median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Logis median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Lnorm median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Norm median(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Unif median(x, propagate.names=getdistrExOption("propagate.names.functionals"))

mad(x, ...)

# S4 method for UnivariateDistribution mad(x) # S4 method for AffLinDistribution mad(x) # S4 method for Cauchy mad(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Dirac mad(x) # S4 method for DExp mad(x) # S4 method for Exp mad(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Geom mad(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Logis mad(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Norm mad(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Unif mad(x, propagate.names=getdistrExOption("propagate.names.functionals")) # S4 method for Arcsine mad(x)

sd(x, ...)

# S4 method for UnivariateDistribution sd(x, fun, cond, withCond, useApply, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Norm sd(x, fun, cond, withCond = FALSE, useApply = TRUE, propagate.names=getdistrExOption("propagate.names.functionals"), ...)

var(x, ...)

# S4 method for UnivariateDistribution var(x, fun, cond, withCond, useApply, ...) # S4 method for AffLinDistribution var(x, fun, cond, withCond, useApply, ...) # S4 method for CompoundDistribution var(x, ...) # S4 method for Arcsine var(x, ...) # S4 method for Binom var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Beta var(x, propagate.names=getdistrExOption("propagate.names.functionals"),...) # S4 method for Cauchy var(x, ...) # S4 method for Chisq var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Dirac var(x, ...) # S4 method for DExp var(x, ...) # S4 method for Exp var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Fd var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Gammad var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Geom var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Hyper var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Logis var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Lnorm var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Nbinom var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Norm var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Pois var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Td var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Unif var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Weibull var(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...)

skewness(x, ...) # S4 method for UnivariateDistribution skewness(x, fun, cond, withCond, useApply, ...) # S4 method for AffLinDistribution skewness(x, fun, cond, withCond, useApply, ...) # S4 method for Arcsine skewness(x, ...) # S4 method for Binom skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Beta skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Cauchy skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Chisq skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Dirac skewness(x, ...) # S4 method for DExp skewness(x, ...) # S4 method for Exp skewness(x, ...) # S4 method for Fd skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Gammad skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Geom skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Hyper skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Logis skewness(x, ...) # S4 method for Lnorm skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Nbinom skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Norm skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Pois skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Td skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Unif skewness(x, ...) # S4 method for Weibull skewness(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...)

kurtosis(x, ...) # S4 method for UnivariateDistribution kurtosis(x, fun, cond, withCond, useApply, ...) # S4 method for AffLinDistribution kurtosis(x, fun, cond, withCond, useApply, ...) # S4 method for Arcsine kurtosis(x, ...) # S4 method for Binom kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Beta kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Cauchy kurtosis(x, ...) # S4 method for Chisq kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Dirac kurtosis(x, ...) # S4 method for DExp kurtosis(x, ...) # S4 method for Exp kurtosis(x, ...) # S4 method for Fd kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Gammad kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Geom kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Hyper kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Logis kurtosis(x, ...) # S4 method for Lnorm kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...) # S4 method for Nbinom kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"),...) # S4 method for Norm kurtosis(x, ...) # S4 method for Pois kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"),...) # S4 method for Td kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"),...) # S4 method for Unif kurtosis(x, ...) # S4 method for Weibull kurtosis(x, propagate.names=getdistrExOption("propagate.names.functionals"), ...)

Value

The value of the corresponding functional at the distribution in the argument is computed.

Arguments

x

object of class "UnivariateDistribution"

fun

if missing the (conditional) variance resp. standard deviation is computed else the (conditional) variance resp. standard deviation of fun is computed.

cond

if not missing the conditional variance resp. standard deviation given cond is computed.

...

additional arguments to fun or E

useApply

logical: should sapply, respectively apply be used to evaluate fund.

withCond

logical: is cond in the argument list of fun.

propagate.names

logical: should names obtained from parameter coordinates be propagated to return values of specific S4 methods for functionals; defaults to the value of the respective distrExoption propagate.names.functionals.

Methods

var, signature(x = "Any"):

interface to the stats-function var --- see var resp. help(var,package="stats").

var, signature(x = "UnivariateDistribution"):

variance of univariate distributions using corresponding E()-method.

var, signature(x = "AffLinDistribution"):

if arguments fun, cond are missing: x@a^2 * var(x@X0) else uses method for signature(x = "UnivariateDistribution")

var, signature(x = "CompoundDistribution"):

if we are in i.i.d. situation (i.e., slot SummandsDistr is of class UnivariateDistribution) the formula \({\rm E}[N]{\rm var}[S]+({\rm E}[S]^2+{\rm var}(S)){\rm var}(N)\) for \(N\) the frequency distribution and \(S\) the summand distribution; else we coerce to "UnivarLebDecDistribution".

sd, signature(x = "Any"):

interface to the stats-function sd --- see sd resp. help(sd,package="stats").

sd, signature(x = "NormParameter"):

returns the slot sd of the parameter of a normal distribution --- see sd resp. help(sd,package="distr").

sd, signature(x = "Norm"):

returns the slot sd of the parameter of a normal distribution --- see sd resp. help(sd,package="distr").

sd, signature(x = "UnivariateDistribution"):

standard deviation of univariate distributions using corresponding E()-method.

IQR, signature(x = "Any"):

interface to the stats-function IQR --- see IQR resp. help(IQR,package="stats").

IQR, signature(x = "UnivariateDistribution"):

interquartile range of univariate distributions using corresponding q()-method.

IQR, signature(x = "UnivariateCondDistribution"):

interquartile range of univariate conditional distributions using corresponding q()-method.

IQR, signature(x = "DiscreteDistribution"):

interquartile range of discrete distributions using corresponding q()-method but taking care that between upper and lower quartile there is 50% probability

IQR, signature(x = "AffLinDistribution"):

abs(x@a) * IQR(x@X0)

median, signature(x = "Any"):

interface to the stats-function median --- see median resp. help(var,package="stats").

median, signature(x = "UnivariateDistribution"):

median of univariate distributions using corresponding q()-method.

median, signature(x = "UnivariateCondDistribution"):

median of univariate conditional distributions using corresponding q()-method.

median, signature(x = "AffLinDistribution"):

x@a * median(x@X0) + x@b

mad, signature(x = "Any"):

interface to the stats-function mad --- see mad.

mad, signature(x = "UnivariateDistribution"):

mad of univariate distributions using corresponding q()-method applied to abs(x-median(x)).

mad, signature(x = "AffLinDistribution"):

abs(x@a) * mad(x@X0)

skewness, signature(x = "Any"):

bias free estimation of skewness under normal distribution (default) as well as sample version (by argument sample.version = TRUE).

skewness, signature(x = "UnivariateDistribution"):

skewness of univariate distributions using corresponding E()-method.

skewness, signature(x = "AffLinDistribution"):

if arguments fun, cond are missing: skewness(x@X0) else uses method for signature(x = "UnivariateDistribution")

kurtosis, signature(x = "Any"):

bias free estimation of kurtosis under normal distribution (default) as well as sample version (by argument sample.version = TRUE).

kurtosis, signature(x = "UnivariateDistribution"):

kurtosis of univariate distributions using corresponding E()-method.

kurtosis, signature(x = "AffLinDistribution"):

if arguments fun, cond are missing: kurtosis(x@X0) else uses method for signature(x = "UnivariateDistribution")

var, signature(x = "Arcsine"):

exact evaluation using explicit expressions.

var, signature(x = "Beta"):

for noncentrality 0 exact evaluation using explicit expressions.

var, signature(x = "Binom"):

exact evaluation using explicit expressions.

var, signature(x = "Cauchy"):

exact evaluation using explicit expressions.

var, signature(x = "Chisq"):

exact evaluation using explicit expressions.

var, signature(x = "Dirac"):

exact evaluation using explicit expressions.

var, signature(x = "DExp"):

exact evaluation using explicit expressions.

var, signature(x = "Exp"):

exact evaluation using explicit expressions.

var, signature(x = "Fd"):

exact evaluation using explicit expressions.

var, signature(x = "Gammad"):

exact evaluation using explicit expressions.

var, signature(x = "Geom"):

exact evaluation using explicit expressions.

var, signature(x = "Hyper"):

exact evaluation using explicit expressions.

var, signature(x = "Logis"):

exact evaluation using explicit expressions.

var, signature(x = "Lnorm"):

exact evaluation using explicit expressions.

var, signature(x = "Nbinom"):

exact evaluation using explicit expressions.

var, signature(x = "Norm"):

exact evaluation using explicit expressions.

var, signature(x = "Pois"):

exact evaluation using explicit expressions.

var, signature(x = "Td"):

exact evaluation using explicit expressions.

var, signature(x = "Unif"):

exact evaluation using explicit expressions.

var, signature(x = "Weibull"):

exact evaluation using explicit expressions.

IQR, signature(x = "Arcsine"):

exact evaluation using explicit expressions.

IQR, signature(x = "Cauchy"):

exact evaluation using explicit expressions.

IQR, signature(x = "Dirac"):

exact evaluation using explicit expressions.

IQR, signature(x = "DExp"):

exact evaluation using explicit expressions.

IQR, signature(x = "Exp"):

exact evaluation using explicit expressions.

IQR, signature(x = "Geom"):

exact evaluation using explicit expressions.

IQR, signature(x = "Logis"):

exact evaluation using explicit expressions.

IQR, signature(x = "Norm"):

exact evaluation using explicit expressions.

IQR, signature(x = "Unif"):

exact evaluation using explicit expressions.

median, signature(x = "Arcsine"):

exact evaluation using explicit expressions.

median, signature(x = "Cauchy"):

exact evaluation using explicit expressions.

median, signature(x = "Dirac"):

exact evaluation using explicit expressions.

median, signature(x = "DExp"):

exact evaluation using explicit expressions.

median, signature(x = "Exp"):

exact evaluation using explicit expressions.

median, signature(x = "Geom"):

exact evaluation using explicit expressions.

median, signature(x = "Logis"):

exact evaluation using explicit expressions.

median, signature(x = "Lnorm"):

exact evaluation using explicit expressions.

median, signature(x = "Norm"):

exact evaluation using explicit expressions.

median, signature(x = "Unif"):

exact evaluation using explicit expressions.

mad, signature(x = "Arcsine"):

exact evaluation using explicit expressions.

mad, signature(x = "Cauchy"):

exact evaluation using explicit expressions.

mad, signature(x = "Dirac"):

exact evaluation using explicit expressions.

mad, signature(x = "DExp"):

exact evaluation using explicit expressions.

mad, signature(x = "Exp"):

exact evaluation using explicit expressions.

mad, signature(x = "Geom"):

exact evaluation using explicit expressions.

mad, signature(x = "Logis"):

exact evaluation using explicit expressions.

mad, signature(x = "Norm"):

exact evaluation using explicit expressions.

mad, signature(x = "Unif"):

exact evaluation using explicit expressions.

skewness, signature(x = "Arcsine"):

exact evaluation using explicit expressions.

skewness, signature(x = "Beta"):

for noncentrality 0 exact evaluation using explicit expressions.

skewness, signature(x = "Binom"):

exact evaluation using explicit expressions.

skewness, signature(x = "Cauchy"):

exact evaluation using explicit expressions.

skewness, signature(x = "Chisq"):

exact evaluation using explicit expressions.

skewness, signature(x = "Dirac"):

exact evaluation using explicit expressions.

skewness, signature(x = "DExp"):

exact evaluation using explicit expressions.

skewness, signature(x = "Exp"):

exact evaluation using explicit expressions.

skewness, signature(x = "Fd"):

exact evaluation using explicit expressions.

skewness, signature(x = "Gammad"):

exact evaluation using explicit expressions.

skewness, signature(x = "Geom"):

exact evaluation using explicit expressions.

skewness, signature(x = "Hyper"):

exact evaluation using explicit expressions.

skewness, signature(x = "Logis"):

exact evaluation using explicit expressions.

skewness, signature(x = "Lnorm"):

exact evaluation using explicit expressions.

skewness, signature(x = "Nbinom"):

exact evaluation using explicit expressions.

skewness, signature(x = "Norm"):

exact evaluation using explicit expressions.

skewness, signature(x = "Pois"):

exact evaluation using explicit expressions.

skewness, signature(x = "Td"):

exact evaluation using explicit expressions.

skewness, signature(x = "Unif"):

exact evaluation using explicit expressions.

skewness, signature(x = "Weibull"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Arcsine"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Beta"):

for noncentrality 0 exact evaluation using explicit expressions.

kurtosis, signature(x = "Binom"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Cauchy"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Chisq"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Dirac"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "DExp"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Exp"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Fd"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Gammad"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Geom"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Hyper"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Logis"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Lnorm"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Nbinom"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Norm"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Pois"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Td"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Unif"):

exact evaluation using explicit expressions.

kurtosis, signature(x = "Weibull"):

exact evaluation using explicit expressions.

Author

Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de

Caveat

If any of the packages e1071, moments, fBasics is to be used together with distrEx the latter must be attached after any of the first mentioned. Otherwise kurtosis() and skewness() defined as methods in distrEx may get masked.
To re-mask, you may use kurtosis <- distrEx::kurtosis; skewness <- distrEx::skewness. See also distrExMASK().

Acknowledgement

G. Jay Kerns, gkerns@ysu.edu, has provided a major contribution, in particular the functionals skewness and kurtosis are due to him.

See Also

distrExIntegrate, m1df, m2df, Distribution-class,
sd, var, IQR,
median, mad, sd,
Sn, Qn

Examples

Run this code
# Variance of Exp(1) distribution
var(Exp())

#median(Exp())
IQR(Exp())
mad(Exp())

# Variance of N(1,4)^2
var(Norm(mean=1, sd=2), fun = function(x){x^2})
var(Norm(mean=1, sd=2), fun = function(x){x^2}, useApply = FALSE)

## sd -- may equivalently be replaced by var
sd(Pois()) ## uses explicit terms
sd(as(Pois(),"DiscreteDistribution")) ## uses sums
sd(as(Pois(),"UnivariateDistribution")) ## uses simulations
sd(Norm(mean=2), fun = function(x){2*x^2}) ## uses simulations
#
mad(sin(exp(Norm()+2*Pois()))) ## weird

Run the code above in your browser using DataLab