Skip to contents

Convert hazard ratios to differences in remaining life expectancy at a given age (defaults to age 65)

Usage

convert_hazards_to_ex(
  df,
  age = 65,
  upper_age = 120,
  M = 80,
  b = 0.075,
  use_model_estimates = FALSE
)

Arguments

df

Dataframe of results given by gompertz_mle() function

age

Age at which to calculate remaining life expectancy

upper_age

Maximal age to use in life table calculation

M

Gompertz parameter modal age at death

b

Gompertz mortality slope parameter

use_model_estimates

Use estimates of the Gompertz Parameters from the model, rather than defaults

Value

A dataframe of hazards ratios and corresponding e(x) estimates and confidence intervals

Examples

#model hazards as function of birthplace using bunmd_demo data
demo_dataset <- dplyr::filter(bunmd_demo, bpl_string %in% c("Poland", "England")) %>%
dplyr::sample_frac(0.1)

#run gompertz_mle()
bpl <- gompertz_mle(formula = death_age ~ bpl_string, left_trunc = 1988,
                    right_trunc = 2005, data = demo_dataset)

#convert to difference in life expectancy
convert_hazards_to_ex(df = bpl$results, use_model_estimates = FALSE)
#> # A tibble: 1 × 10
#>   parameter   coef coef_lower coef_upper    hr hr_lower hr_upper   e65 e65_lower
#>   <chr>      <dbl>      <dbl>      <dbl> <dbl>    <dbl>    <dbl> <dbl>     <dbl>
#> 1 bpl_stri… -0.101     -0.288     0.0850 0.904    0.750     1.09 0.855    -0.699
#> # ℹ 1 more variable: e65_upper <dbl>