E {distrEx}R Documentation

Generic Function for the Computation of (Conditional) Expectations

Description

Generic function for the computation of (conditional) expectations.

Usage

E(object, fun, cond, ...)

## S4 method for signature 'UnivariateCondDistribution,
##   function, numeric':
E(object, fun, cond, withCond = FALSE, ...)

## S4 method for signature 'AbscontCondDistribution,
##   function, numeric':
E(object, fun, cond, withCond = FALSE, ...)

## S4 method for signature 'DiscreteCondDistribution,
##   function, numeric':
E(object, fun, cond, withCond = 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.
... additional arguments to fun
withCond logical: is cond in the argument list of fun.

Details

The precision of the computations can be controlled via certain global options; cf. distrExOptions.

Value

The (conditional) expectation is computed.

Methods

object = "UnivariateDistribution", fun = "missing", cond = "missing":
expectation of univariate distributions using crude Monte-Carlo integration.
object = "AbscontDistribution", fun = "missing", cond = "missing":
expectation of absolutely continuous univariate distributions using distrExIntegrate.
object = "DiscreteDistribution", fun = "missing", cond = "missing":
expectation of discrete univariate distributions using support and sum.
object = "DiscreteMVDistribution", fun = "missing", cond = "missing":
expectation of discrete multivariate distributions. The computation is based on support and sum.
object = "UnivariateDistribution", fun = "function", cond = "missing":
expectation of fun under univariate distributions using crude Monte-Carlo integration.
object = "AbscontDistribution", fun = "function", cond = "missing":
expectation of fun under absolutely continuous univariate distributions using distrExIntegrate.
object = "DiscreteDistribution", fun = "function", cond = "missing":
expectation of fun under discrete univariate distributions using support and sum.
object = "DiscreteMVDistribution", fun = "function", cond = "missing":
expectation of fun under discrete multivariate distributions. The computation is based on support and sum.

object = "UnivariateCondDistribution", fun = "missing", cond = "numeric":
conditional expectation for univariate conditional distributions given cond. The integral is computed using crude Monte-Carlo integration.
object = "AbscontCondDistribution", fun = "missing", cond = "numeric":
conditional expectation for absolutely continuous, univariate conditional distributions given cond. The computation is based on distrExIntegrate.
object = "DiscreteCondDistribution", fun = "missing", cond = "numeric":
conditional expectation for discrete, univariate conditional distributions given cond. The computation is based on support and sum.
object = "UnivariateCondDistribution", fun = "function", cond = "numeric":
conditional expectation of fun under univariate conditional distributions given cond. The integral is computed using crude Monte-Carlo integration.
object = "AbscontCondDistribution", fun = "function", cond = "numeric":
conditional expectation of fun under absolutely continuous, univariate conditional distributions given cond. The computation is based on distrExIntegrate.
object = "DiscreteCondDistribution", fun = "function", cond = "numeric":
conditional expectation of fun under discrete, univariate conditional distributions given cond. The computation is based on support and sum.

Author(s)

Matthias Kohl robast@gmx.de

See Also

distrExIntegrate, m1df, m2df, Distribution-class

Examples

# mean of Exp(1) distribution
E(Exp())

# second moment of N(1,4)
E(Norm(mean=1, sd=2), fun = function(x){x^2})

# conditional distribution of a linear model
D1 <- LMCondDistribution(theta = 1) 
E(D1, cond = 1)
E(Norm(mean=1))
E(D1, function(x){x^2}, cond = 1)
E(Norm(mean=1), fun = function(x){x^2})
E(D1, function(x, cond){cond*x^2}, cond = 2, withCond = TRUE)
E(Norm(mean=2), function(x){2*x^2})

[Package distrEx version 0.3-9 Index]