Description Usage Arguments Value Author(s) References Examples
Function for estimating the probability density function starting from a limited number of raw statistical moments. The method is based on Maximum Entropy method \insertCitemead1984MortalityForecast.
1 | find.density(data, x, omega = 110, verbose = FALSE)
|
data |
A numeric vector or a data.frame/matrix with raw moments. |
x |
A numeric vector with ages. The density frequencies are returned only for the specified ages. |
omega |
The maximum age to be used in MaxEnt estimation. The
algorithm is reliable and robust when the underlying distribution is closing
on the right-hand side. In the case of age-at-death distribution, |
verbose |
A logical value. Set |
An object with the estimated densities.
Adam Lenart and Marius D. Pascariu.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Example 1 -- simple case ---------------
x <- 0:120
# Raw moments M0 - M7
raw_moments <- c(1, 68.75099, 4991.724, 371531.9, 28199680,
2176435499, 170477697491, 1.353288e+13)
ed <- find.density(raw_moments, x)
# Example 2 -- estimat for entire table --
x <- 0:110
y <- 1965:2016
dx <- HMD_male$dx$GBRTENW[paste(x), paste(y)]
mom <- find.moments(dx, x, y, n = 7)$raw.moments
dx.hat <- find.density(mom, x)
# Visual check --
yr = "1990"
observed.dx <- dx[, yr]/sum(dx[, yr])
estimated.dx <- dx.hat$density[, yr]
plot(observed.dx, pch = 16, main = yr)
lines(estimated.dx, col = 2)
legend("topleft", legend = c("observed", "estimated"), col = 1:2,
pch = c(16, NA), lty = c(NA, 1), lwd = 2, bty = "n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.