variance {HyRiM} | R Documentation |
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 |
Value
the approximate variance value
Note
the function works on the internal probability mass function (which may be different from the empirical distribution in case that the loss distribution has been smoothed during its construction; see lossDistribution
). The function delivers only an approximate variance, whose error is due to numeric roundoff errors (known to occur in Steiner's formula), and the fact that the computation is done on an approximate density (rather than the
empirical distribution).
Author(s)
Stefan Rass
See Also
Examples
x <- c(10,6.4,9,7.9,7.1,9)
ld <- lossDistribution(x)
variance(ld)
var(x)