find.density: Estimate density function based on Maximum Entropy method...

Description Usage Arguments Value Author(s) References Examples

View source: R/find_density.R

Description

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.

Usage

1
find.density(data, x, omega = 110, verbose = FALSE)

Arguments

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, omega should be an old age; otherwise the MaxEnt might fail to converge. Numeric scalar.

verbose

A logical value. Set verbose = FALSE to silent the process that take place inside the function and avoid progress messages.

Value

An object with the estimated densities.

Author(s)

Adam Lenart and Marius D. Pascariu.

References

\insertAllCited

Examples

 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")

mpascariu/MortalityForecast documentation built on Sept. 28, 2020, 2:40 p.m.