# hpbayes.plot: Bayesian Melding posterior Heligman-Pollard parameter... In HPbayes: Heligman Pollard mortality model parameter estimation using Bayesian Melding with Incremental Mixture Importance Sampling

## Description

This function converts the posterior Heligman-Pollard parameter distribution resulting from a Bayesian Melding procedure to probabilities of death over a specified age range. In addition, this function also calculates and plots a CI over the specified age range. The user can also elect to plot the data (`ndeath`/`nrisk`) from which the model was estimated.

## Usage

 ```1 2 3 4``` ```hpbayes.plot(..., nrisk = NULL, ndeath = NULL, age, hpp, yrange = c(0, 0.8), xrange = c(0, 85), log = FALSE, plotdata = FALSE, plotpost= TRUE, data.type="b", post.type="l", line.col=c("grey", "blue", "red", "dark green"), CI=95) ```

## Arguments

 `...` Arguments to be passes to `par` `nrisk` A vector containing the number of persons at risk at age x `ndeath` A vector containing the number of deaths at age x `age` A vector containing the ages at which the probabilities of death will be calculated and plotted `hpp` A matrix containing the posterior distribution of Heligman-Pollard parameters resulting from the Bayesian Melding procedure `yrange` Same as ylim in `plot()` `xrange` Same as xlim in `plot()` `log` Logical. If TRUE the data will be converted and plotted on the log scale `plotdata` Logical. If TRUE the data (`ndeath`/`nrisk`) will be plotted as well. `plotpost` Logical. If TRUE the posterior output will be plotted. `data.type` Same as `type` in plot. `post.type` Same as `type` in plot. Defines the "type" for plotting the posterior age-specific probabilities of death `line.col` A vector of length four containing either numbers or strings describing the colors of the plot. In order, the vector elements control the color of the posterior output lines (defaults to "grey"), the color of the median line representing the median probability of death at each age (defaults to "blue"), the color of the two lines representing the upper and lower credible interval bounds (defaults to "red"), and the final element in this vector controls the color of the data points if they are plotted (defaults to "dark green"). `CI` Defines the width of the credible interval if plotted (defaults to 95 percent). Setting `CI=95` for example will plot two lines representing the upper and lower bounds of the confidence interval with the upper bound line representing the 97.5th percentile for each age and the lower bound representing the 2.5th percentile for each age.

## Details

If plotdata is TRUE, the user will need to supply the persons at risk at each age x and the number of deaths at age x with the arguments `nrisk` and `ndeath` respectively.

## Value

A plot depicting the posterior distribution of probabilities of death calculated from the posterior parameter distribution resulting from the Bayesian Melding procedure (see `hp.bm.imis`)

## Note

Likely used to plot the `H.final` return from `hp.bm.imis`

## References

Heligman, Larry and John H. Pollard. 1980 "The Age Pattern of Mortality." Journal of the Institute of Actuaries 107:49–80.

`hp.nqx`, `hp.bm.imis`
 ```1 2 3 4 5 6 7 8``` ```#load a prior, age, nrisk and ndeath# data(HPprior) result <- hp.bm.imis(prior=q0, K=10, age=age, nrisk=lx, ndeath=dx) H.final <- result\$H.final hpbayes.plot(nrisk=lx, ndeath=dx, age=age, hpp=H.final, plotdata=TRUE) hpbayes.plot(age=age, hpp=H.final) ```