Generic Functions for the Computation of Functionals

Share:

Description

Generic functions for the computation of functionals on distributions.

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
IQR(x, ...)

## S4 method for signature 'UnivariateDistribution'
IQR(x)
## S4 method for signature 'UnivariateCondDistribution'
IQR(x,cond)
## S4 method for signature 'AffLinDistribution'
IQR(x)
## S4 method for signature 'DiscreteDistribution'
IQR(x)
## S4 method for signature 'Arcsine'
IQR(x)
## S4 method for signature 'Cauchy'
IQR(x)
## S4 method for signature 'Dirac'
IQR(x)
## S4 method for signature 'DExp'
IQR(x)
## S4 method for signature 'Exp'
IQR(x)
## S4 method for signature 'Geom'
IQR(x)
## S4 method for signature 'Logis'
IQR(x)
## S4 method for signature 'Norm'
IQR(x)
## S4 method for signature 'Unif'
IQR(x)

median(x, ...)

## S4 method for signature 'UnivariateDistribution'
median(x)
## S4 method for signature 'UnivariateCondDistribution'
median(x,cond)
## S4 method for signature 'AffLinDistribution'
median(x)
## S4 method for signature 'Arcsine'
median(x)
## S4 method for signature 'Cauchy'
median(x)
## S4 method for signature 'Dirac'
median(x)
## S4 method for signature 'DExp'
median(x)
## S4 method for signature 'Exp'
median(x)
## S4 method for signature 'Geom'
median(x)
## S4 method for signature 'Logis'
median(x)
## S4 method for signature 'Lnorm'
median(x)
## S4 method for signature 'Norm'
median(x)
## S4 method for signature 'Unif'
median(x)

mad(x, ...)

## S4 method for signature 'UnivariateDistribution'
mad(x)
## S4 method for signature 'AffLinDistribution'
mad(x)
## S4 method for signature 'Cauchy'
mad(x)
## S4 method for signature 'Dirac'
mad(x)
## S4 method for signature 'DExp'
mad(x)
## S4 method for signature 'Exp'
mad(x)
## S4 method for signature 'Geom'
mad(x)
## S4 method for signature 'Logis'
mad(x)
## S4 method for signature 'Norm'
mad(x)
## S4 method for signature 'Unif'
mad(x)
## S4 method for signature 'Arcsine'
mad(x)

sd(x, ...)

## S4 method for signature 'UnivariateDistribution'
sd(x, fun, cond, withCond, useApply, ...)
## S4 method for signature 'Norm'
sd(x, fun, cond, withCond = FALSE, useApply = TRUE, ...)

var(x, ...)

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

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

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

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.

Value

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

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 E[N]var[S]+E[S*S]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.

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.

Author(s)

Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 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

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.