E                  package:distrEx                  R Documentation

_G_e_n_e_r_i_c _F_u_n_c_t_i_o_n _f_o_r _t_h_e _C_o_m_p_u_t_a_t_i_o_n _o_f (_C_o_n_d_i_t_i_o_n_a_l) _E_x_p_e_c_t_a_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Generic function for the computation of (conditional)
     expectations.

_U_s_a_g_e:

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

     ## S4 method for signature 'UnivariateDistribution,
     ##   function, missing':
     E(object, fun, cond, useApply = TRUE, ...)

     ## S4 method for signature 'AbscontDistribution, function,
     ##   missing':
     E(object, fun, cond, useApply = TRUE, ...)

     ## S4 method for signature 'DiscreteDistribution, function,
     ##   missing':
     E(object, fun, cond, useApply = TRUE, ...)

     ## S4 method for signature 'MultivariateDistribution,
     ##   function, missing':
     E(object, fun, cond, useApply = TRUE, ...)

     ## S4 method for signature 'DiscreteMVDistribution,
     ##   function, missing':
     E(object, fun, cond, useApply = TRUE, ...)

     ## S4 method for signature 'AbscontCondDistribution,
     ##   missing, numeric':
     E(object, cond, useApply = TRUE)

     ## S4 method for signature 'DiscreteCondDistribution,
     ##   missing, numeric':
     E(object, cond, useApply = TRUE)

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

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

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

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

     ## S4 method for signature 'Beta, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Binom, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Cauchy, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Chisq, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Dirac, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Exp, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Fd, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Gammad, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Geom, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Hyper, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Logis, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Lnorm, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Nbinom, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Norm, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Pois, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Unif, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Td, missing, missing':
     E(object, fun, cond)
     ## S4 method for signature 'Weibull, missing, missing':
     E(object, fun, cond)

_A_r_g_u_m_e_n_t_s:

  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' 

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

withCond: logical: is 'cond' in the argument list of 'fun'. 

_D_e_t_a_i_l_s:

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

_V_a_l_u_e:

     The (conditional) expectation is computed.

_M_e_t_h_o_d_s:

     _o_b_j_e_c_t = "_U_n_i_v_a_r_i_a_t_e_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of univariate distributions using crude Monte-Carlo
          integration. 

     _o_b_j_e_c_t = "_A_b_s_c_o_n_t_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of absolutely continuous univariate distributions
          using 'distrExIntegrate'. 

     _o_b_j_e_c_t = "_D_i_s_c_r_e_t_e_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of discrete univariate distributions using 'support'
          and 'sum'.

     _o_b_j_e_c_t = "_M_u_l_t_i_v_a_r_i_a_t_e_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of multivariate distributions using crude Monte-Carlo
          integration. 

     _o_b_j_e_c_t = "_D_i_s_c_r_e_t_e_M_V_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of discrete multivariate distributions. The
          computation is based on 'support' and 'sum'.

     _o_b_j_e_c_t = "_U_n_i_v_a_r_i_a_t_e_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of 'fun' under univariate distributions using  crude
          Monte-Carlo integration. 

     _o_b_j_e_c_t = "_A_b_s_c_o_n_t_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of 'fun' under absolutely continuous  univariate
          distributions using 'distrExIntegrate'. 

     _o_b_j_e_c_t = "_D_i_s_c_r_e_t_e_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of 'fun' under discrete univariate  distributions
          using 'support' and 'sum'. 

     _o_b_j_e_c_t = "_M_u_l_t_i_v_a_r_i_a_t_e_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of multivariate distributions using crude Monte-Carlo
          integration. 

     _o_b_j_e_c_t = "_D_i_s_c_r_e_t_e_M_V_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_m_i_s_s_i_n_g": expec
          tation of 'fun' under discrete multivariate  distributions.
          The computation is based on 'support' and 'sum'.   

     _o_b_j_e_c_t = "_U_n_i_v_a_r_i_a_t_e_C_o_n_d_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_n_u_m_e_r_i_c": condi
          tional expectation for univariate conditional distributions
          given 'cond'.  The integral is computed using crude
          Monte-Carlo integration. 

     _o_b_j_e_c_t = "_A_b_s_c_o_n_t_C_o_n_d_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_n_u_m_e_r_i_c": condi
          tional expectation for absolutely continuous, univariate 
          conditional distributions given 'cond'. The computation is
          based on 'distrExIntegrate'. 

     _o_b_j_e_c_t = "_D_i_s_c_r_e_t_e_C_o_n_d_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_n_u_m_e_r_i_c": condi
          tional expectation for discrete, univariate conditional 
          distributions given 'cond'. The computation is based  on
          'support' and 'sum'. 

     _o_b_j_e_c_t = "_U_n_i_v_a_r_i_a_t_e_C_o_n_d_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_n_u_m_e_r_i_c": condi
          tional expectation of 'fun' under univariate conditional
          distributions  given 'cond'. The integral is computed using
          crude Monte-Carlo integration. 

     _o_b_j_e_c_t = "_A_b_s_c_o_n_t_C_o_n_d_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_n_u_m_e_r_i_c": condi
          tional expectation of 'fun' under absolutely continuous, 
          univariate conditional distributions given 'cond'. The
          computation is based on 'distrExIntegrate'. 

     _o_b_j_e_c_t = "_D_i_s_c_r_e_t_e_C_o_n_d_D_i_s_t_r_i_b_u_t_i_o_n", _f_u_n = "_f_u_n_c_t_i_o_n", _c_o_n_d = "_n_u_m_e_r_i_c": condi
          tional expectation of 'fun' under discrete, univariate 
          conditional distributions given 'cond'. The computation is
          based on 'support' and 'sum'. 

     _o_b_j_e_c_t = "_B_e_t_a", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": for
          noncentrality 0 exact evaluation using explicit expressions.

     _o_b_j_e_c_t = "_B_i_n_o_m", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_C_a_u_c_h_y", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_C_h_i_s_q", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_D_i_r_a_c", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_E_x_p", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_F_d", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact evaluation
          using explicit expressions.

     _o_b_j_e_c_t = "_G_a_m_m_a_d", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_G_e_o_m", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_H_y_p_e_r", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_L_o_g_i_s", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_L_n_o_r_m", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_N_b_i_n_o_m", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_N_o_r_m", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_P_o_i_s", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_U_n_i_f", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

     _o_b_j_e_c_t = "_T_d", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact evaluation
          using explicit expressions.

     _o_b_j_e_c_t = "_W_e_i_b_u_l_l", _f_u_n = "_m_i_s_s_i_n_g", _c_o_n_d = "_m_i_s_s_i_n_g": exact
          evaluation using explicit expressions.

_A_u_t_h_o_r(_s):

     Matthias Kohl Matthias.Kohl@stamats.de and Peter Ruckdeschel
     peter.ruckdeschel@uni-bayreuth.de

_S_e_e _A_l_s_o:

     'distrExIntegrate', 'm1df', 'm2df', 'Distribution-class'

_E_x_a_m_p_l_e_s:

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

     E(E) ## uses explicit terms
     E(as(E,"AbscontDistribution")) ## uses numerical integration
     E(as(E,"UnivariateDistribution")) ## uses simulations
     E(E, fun = function(x){2*x^2}) ## uses simulations

     # the same operator for discrete distributions:
     P <- Pois(lambda=2)

     E(P) ## uses explicit terms
     E(as(P,"DiscreteDistribution")) ## uses sums
     E(as(P,"UnivariateDistribution")) ## uses simulations
     E(P, fun = function(x){2*x^2}) ## uses simulations

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

     # 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, useApply = FALSE)
     E(Norm(mean=2), function(x){2*x^2})

