plot.HP {BayesMortalityPlus} | R Documentation |

Function that returns a log-scale ggplot of `HP`

and `ClosedHP`

objects returned by the hp() and hp_close() functions.

```
## S3 method for class 'HP'
plot(
x,
age = NULL,
Ex = NULL,
plotIC = TRUE,
plotData = TRUE,
labels = NULL,
colors = NULL,
linetype = NULL,
prob = 0.95,
...
)
```

`x` |
Object of the class |

`age` |
Vector with the ages to plot the life table. |

`Ex` |
Vector with the exposures of the selected ages. Its length must be equal to the age vector. This argument is only necessary when using poisson and binomial HP models. |

`plotIC` |
Logical. If 'TRUE' (default), shows the predictive intervals. |

`plotData` |
Logical. If 'TRUE' (default), shows crude rate (black dots). |

`labels` |
Vector with the name of the curve label. (Optional). |

`colors` |
Vector with the color of the curve. (Optional). |

`linetype` |
Vector with the line type of the curve. (Optional). |

`prob` |
Coverage probability of the predictive intervals. Default is '0.95'. |

`...` |
Other arguments. |

A 'ggplot' object with fitted life table.

`plot.DLM()`

, `plot.BLC()`

and `plot.PredBLC()`

for `DLM`

, `BLC`

or `PredBLC`

methods.

`plot.list()`

to the `list`

method, adding multiple objects in one single plot.

`plot_chain()`

to plot the chains generated by the MCMC algorithms for the `HP`

and `DLM`

objects.

```
## Selecting the exposure and the death count of the year 1990, ranging from 0 to 90 years old:
USA1990 = USA[USA$Year == 1990,]
x = 0:90
Ex = USA1990$Ex.Male[x+1]
Dx = USA1990$Dx.Male[x+1]
## Fitting the poisson and the lognormal model:
fit = hp(x = x, Ex = Ex, Dx = Dx, model = "poisson",
M = 2000, bn = 1000, thin = 1)
fit2 = hp(x = x, Ex = Ex, Dx = Dx, model = "lognormal",
M = 2000, bn = 1000, thin = 1)
## Plot the life tables:
plot(fit)
plot(fit2, age = 0:110, plotIC = TRUE)
## To plot multiples life tables see ?plot.list
plot(list(fit, fit2),
age = 0:110, Ex = USA1990$Ex.Male,
plotIC = FALSE, colors = c("red", "blue"),
labels = c("Poisson", "Lognormal"))
```

[Package *BayesMortalityPlus* version 0.1.1 Index]