# E

##### Generic Function for the Computation of (Conditional) Expectations

Generic function for the computation of (conditional) expectations.

- Keywords
- methods, distribution

##### Usage

`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)

##### Arguments

- object
object of class

`"Distribution"`

- fun
if missing the (conditional) expectation is computed else the (conditional) expection of

`fun`

is computed.- cond
if not missing the conditional expectation given

`cond`

is computed.- rel.tol
relative tolerance for

`distrExIntegrate`

.- low
lower bound of integration range.

- upp
upper bound of integration range.

- lowerTruncQuantile
lower quantile for quantile based integration range.

- upperTruncQuantile
upper quantile for quantile based integration range.

- IQR.fac
factor for scale based integration range (i.e.; median of the distribution \(\pm\)

`IQR.fac`

\(\times\)IQR).- …
additional arguments to

`fun`

- diagnostic
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).

##### Details

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`

.

##### Value

The expectation is computed.

##### Methods

- object = "Gumbel", fun = "missing", cond = "missing":
exact evaluation using explicit expressions.

- object = "GPareto", fun = "missing", cond = "missing":
exact evaluation using explicit expressions.

- object = "DistributionsIntegratingByQuantiles", fun = "function", cond = "missing":
use probability transform, i.e., a substitution

`y = p(object)(x)`

for numerical integration.- object = "GPareto", fun = "function", cond = "missing":
use substitution method (y := log(x)) for numerical integration.

- object = "Pareto", fun = "missing", cond = "missing":
exact evaluation using explicit expressions.

##### See Also

##### Examples

```
# NOT RUN {
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)})
# }
```

*Documentation reproduced from package RobExtremes, version 1.2.0, License: LGPL-3*