summary_fn: A function to summarise the fitted mortality rates and...

View source: R/summary_fn.R

summary_fnR Documentation

A function to summarise the fitted mortality rates and parameters of stochastic mortality models

Description

Provide summaries (means, standard errors, percentiles) of the fitted mortality rates and parameters, derived using posterior samples stored in "fit_result" object.

Usage

summary_fn(result, pred_int = 0.95)

Arguments

result

object of type either "fit_result" or "BayesMoFo".

pred_int

A numeric value (between 0 and 1) specifying the credible level of uncertainty bands. Default is pred_int=0.95 (95\% intervals).

Value

A list with components: rates_summary=list(mean=rates_mean,std=rates_std),rates_pn=list(lower=rates_lower,median=rates_median,upper=rates_upper),param_summary=list(mean=param_mean,std=param_std),param_pn=param_pn

rates_summary

A list containing 2 components, respectively called "mean" ($rates_summary$mean) and "std" ($rates_summary$std). Both return a 3-dimensional data array (dim 1: strata, dim 2: ages, dim 3: years), with the former giving posterior means of fitted mortality rates while the latter giving standard errors.

rates_pn

A list containing 3 components, respectively called "lower" ($rates_pn$lower), "median" ($rates_pn$median), and "upper" ($rates_pn$upper). All return a 3-dimensional data array (dim 1: strata, dim 2: ages, dim 3: years), representing the respective percentiles for the fitted mortality rates.

param_summary

A list containing 2 components, respectively called "mean" ($param_summary$mean) and "std" ($param_summary$std). Both return a 3-dimensional data array (dim 1: strata, dim 2: ages, dim 3: years), with the former giving posterior means of fitted parameters while the latter giving standard errors.

param_pn

A 2-dimensional matrix containing percentiles of fitted parameters.

Examples


#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,n_iter=1000,models="APCI")

#default summary
summary_runBayesMoFo<-summary_fn(runBayesMoFo_result)

#mean of fitted mortality rates 
summary_runBayesMoFo$rates_summary$mean

#standard errors of fitted mortality rates 
summary_runBayesMoFo$rates_summary$std

#97.5th percentile of fitted mortality rates 
summary_runBayesMoFo$rates_pn$upper

#mean of fitted parameters 
summary_runBayesMoFo$param_summary$mean

#standard errors of fitted parameters 
summary_runBayesMoFo$param_summary$std

#97.5th percentile of fitted parameters 
summary_runBayesMoFo$param_pn[,"upper"]


BayesMoFo documentation built on Aug. 11, 2025, 1:07 a.m.