Learn R Programming

HyRiM (version 1.0.3)

variance: Computes the approximate variance of a loss distribution.

Description

The computation is based on Steiner's theorem \(\textrm{var}(X) = \textrm{E}(X^2) - (\textrm{E}(X))^2\), where the respective first and second moments are computed using the moment function (from this package). Internally, these functions operate on the approximate kernel density estimation for both, continuous and categorical distributions (see the lossDistribution function for details).

Usage

variance(x)

Arguments

x

an object of class mosg.lossDistribution

Value

the approximate variance value

See Also

moment, lossDistribution

Examples

Run this code
# NOT RUN {
<!-- %##---- Should be DIRECTLY executable !! ---- -->
# }
# NOT RUN {
<!-- %##-- ==>  Define data, use random, -->
# }
# NOT RUN {
<!-- %##--	or do  help(data=index)  for the standard data sets. -->
# }
# NOT RUN {
<!-- % -->
# }
# NOT RUN {
<!-- %## The function is currently defined as -->
# }
# NOT RUN {
<!-- %function (x)  -->
# }
# NOT RUN {
<!-- %{ -->
# }
# NOT RUN {
<!-- %    moment(x, 2) - moment(x, 1)^2 -->
# }
# NOT RUN {
<!-- %  } -->
# }
# NOT RUN {
<!-- %} -->
# }
# NOT RUN {
x <- c(10,6.4,9,7.9,7.1,9)
ld <- lossDistribution(x)
variance(ld)
var(x)
# }

Run the code above in your browser using DataLab