Skip to contents

Calculate the predicted mortality rate over a given interval.

Usage

pred_mortality_rate(
  lifelihoodResults,
  interval_width,
  newdata = NULL,
  max_time = NULL,
  groupby = NULL
)

Arguments

lifelihoodResults

output of lifelihood()

interval_width

The interval width used to calculate the mortality rate. For instance, if the time unit for deaths in the original dataset is days and interval_width is set to 10, the mortality rate will be calculated every 10 days for each group.

newdata

Data for prediction. If absent, predictions are for the subjects used in the original fit.

max_time

The maximum time for calculating the mortality rate. If set to NULL, the time of the last observed death is used.

groupby

covariate(s) over which mortality rate should be computed (default is NULL).

  • If NULL, calculates a single overall mortality rate.

  • If "all", calculates mortality rate over each combination of covariates listed in thelifelihoodData object provided.

  • Otherwise must be a character ("covariate1") or a character vector (c("covariate1", "covariate2")).

Value

A dataframe with 3 columns:

  • Interval (time interval, based on interval_width value)

  • Group (identifier of a given subgroup, or "Overall" if groupby = FALSE)

  • MortalityRate (mortality rate at this time).