Generic function for the computation of (conditional) expectations.
E(object, fun, cond, ...)# S4 method for GEV,missing,missing
E(object, low = NULL, upp = NULL, ..., diagnostic = FALSE)
# S4 method for DistributionsIntegratingByQuantiles,function,missing
E(object,
fun, low = NULL, upp = NULL,
rel.tol= getdistrExOption("ErelativeTolerance"),
lowerTruncQuantile = getdistrExOption("ElowerTruncQuantile"),
upperTruncQuantile = getdistrExOption("EupperTruncQuantile"),
IQR.fac = max(1e4,getdistrExOption("IQR.fac")), ..., diagnostic = FALSE)
# S4 method for Gumbel,missing,missing
E(object, low = NULL, upp = NULL, ..., diagnostic = FALSE)
# S4 method for GPareto,missing,missing
E(object, low = NULL, upp = NULL, ..., diagnostic = FALSE)
# S4 method for GPareto,function,missing
E(object, fun, low = NULL, upp = NULL,
rel.tol= getdistrExOption("ErelativeTolerance"),
lowerTruncQuantile = getdistrExOption("ElowerTruncQuantile"),
upperTruncQuantile = getdistrExOption("EupperTruncQuantile"),
IQR.fac = max(1e4,getdistrExOption("IQR.fac")), ..., diagnostic = FALSE)
# S4 method for Pareto,missing,missing
E(object, low = NULL, upp = NULL, ..., diagnostic = FALSE)
The expectation is computed.
object of class "Distribution"
if missing the (conditional) expectation is computed
else the (conditional) expection of fun
is computed.
if not missing the conditional expectation
given cond
is computed.
relative tolerance for distrExIntegrate
.
lower bound of integration range.
upper bound of integration range.
lower quantile for quantile based integration range.
upper quantile for quantile based integration range.
factor for scale based integration range (i.e.;
median of the distribution \(\pm\)IQR.fac
\(\times\)IQR).
additional arguments to fun
logical; if TRUE
, the return value obtains
an attribute "diagnostic"
with diagnostic information on the
integration, i.e., a list with entries method
("integrate"
or "GLIntegrate"
), call
, result
(the complete return
value of the method), args
(the args with which the
method was called), and time
(the time to compute the integral).
exact evaluation using explicit expressions.
exact evaluation using explicit expressions.
use probability transform, i.e., a substitution y = p(object)(x)
for numerical integration.
use substitution method (y := log(x)) for numerical integration.
exact evaluation using explicit expressions.
Matthias Kohl Matthias.Kohl@stamats.de and Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de
The precision of the computations can be controlled via
certain global options; cf. distrExOptions
.
Also note that arguments low
and upp
should be given as
named arguments in order to prevent them to be matched by arguments
fun
or cond
. Also the result, when arguments
low
or upp
is given, is the unconditional value of the
expectation; no conditioning with respect to low <= object <= upp
is done. To be able to use integration after transformation via the
respective probability transformation to [0,1], we introduce a class union
"DistributionsIntegratingByQuantiles"
, which currently comprises
classes "GPareto"
, "Pareto"
, "Weibull"
, "GEV"
.
In addition, the specific method for "GPareto", "function", "missing"
uses integration on [0,1] via the substitution method (y := log(x)).
Diagnostics on the involved integrations are available
if argument diagnostic
is TRUE
. Then there is attribute
diagnostic
attached to the return value, which may be inspected
and accessed through showDiagnostic
and
getDiagnostic
.
distrExIntegrate
, m1df
, m2df
,
Distribution-class
GP <- GPareto(shape=0.3)
E(GP)
E(GP, fun = function(x){2*x^2}) ## uses the log trafo
P <- Pareto()
E(P)
E(P,fun = function(x){1/(x^2+1)})
Run the code above in your browser using DataLab