plot.DLM {BayesMortalityPlus} | R Documentation |
Function that returns a log-scale ggplot of the DLM
and ClosedDLM
objects returned by dlm() and dlm_close() functions.
## S3 method for class 'DLM'
plot(
x,
plotIC = TRUE,
plotData = TRUE,
labels = NULL,
colors = NULL,
linetype = NULL,
prob = 0.95,
age = NULL,
...
)
x |
Object of the class |
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'. |
age |
Vector with the ages to plot the life table. |
... |
Other arguments. |
A 'ggplot' object with fitted life table.
plot.HP()
, plot.BLC()
and plot.PredBLC()
for HP
, 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 log mortality rate of the 1990 male population ranging from 0 to 100 years old
USA1990 = USA[USA$Year == 1990,]
x = 0:100
Ex = USA1990$Ex.Male[x+1]
Dx = USA1990$Dx.Male[x+1]
y = log(Dx/Ex)
## Fitting DLM
fit = dlm(y, ages = 0:100, M = 100, bn = 20, thin = 1)
## Plotting the life tables:
plot(fit)
## Now we are starting from 20 years
fit2 = dlm(y[21:101], Ft = 1, Gt = 1, ages = 20:100, M = 100, bn = 20, thin = 1)
plot(fit2, plotIC = FALSE)
## To plot multiples life tables see ?plot.list
plot(list(fit, fit2), age = 20:100,
plotData = FALSE,
colors = c("red", "blue"),
labels = c("1", "2"))