View source: R/plot_deaths_fn.R
plot_deaths_fn | R Documentation |
Plot the median fitted and forecast number of deaths, accompanied by credible intervals (user-specified level), using posterior samples stored in "fit_result" object.
plot_deaths_fn(
result,
expo_forecast = NULL,
pred_int = 0.95,
plot_type = "age",
plot_ages = NULL,
plot_years = NULL,
legends = TRUE
)
result |
object of type either "fit_result" or "BayesMoFo". |
expo_forecast |
An optional 3-dimensional array (of dimensions |
pred_int |
A numeric value (between 0 and 1) specifying the credible level of uncertainty bands. Default is |
plot_type |
A character string ( |
plot_ages |
A numeric vector specifying which range of ages to plot for visualisation. If not specified, use whatever ages that were used to fit the model (i.e. |
plot_years |
A numeric vector specifying which range of years to plot for visualisation. If not specified, use whatever years that were used to fit the model (i.e. |
legends |
A logical value to indicate if legends of the plots should be shown (default) or suppressed (e.g. to aid visibility). |
A plot illustrating the median fitted and forecast number of deaths, accompanied by credible intervals.
#load and prepare data
data("dxt_array_product");data("Ext_array_product")
death<-preparedata_fn(dxt_array_product,strat_name = c("ACI","DB","SCI"),ages=35:65)
expo<-preparedata_fn(Ext_array_product,strat_name = c("ACI","DB","SCI"),ages=35:65)
#fit any mortality model
runBayesMoFo_result<-runBayesMoFo(death=death,expo=expo,models="APCI",n_iter=1000,forecast=TRUE)
#default plot
plot_deaths_fn(runBayesMoFo_result)
#plot by age and changing pre-specified arguments
plot_deaths_fn(runBayesMoFo_result,pred_int=0.8,plot_ages=40:60,plot_years=c(2017,2020))
#plot by time/year
plot_deaths_fn(runBayesMoFo_result,plot_type="time",plot_ages=c(40,50,60))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.