Time inhomogeneous Markov cohort models

2020-05-31

1 Overview

We will illustrate a time inhomogeneous Markov cohort model by replicating the total hip replacement (THR) example from the Decision Modeling for Health Economic Evaluation textbook. The analysis compares two treatment strategies, a “standard” prosthesis and a “new” prosthesis. A probabilistic sensitivity analysis (PSA) will be used to quantify parameter uncertainty.

The model consists 5 health states: (i) primary THR, (ii) successful primary, (iii) revision THR, (iv) successful revision, and (v) death.

The model is time-inhomogeneous because (i) the prosthesis survival time is modeled using a Weibull survival model so that the probability of failure is time-varying and (ii) background mortality rates increase as patients age.

2 Define the model

2.1 Data

We set up the model for two treatment strategies and 10 subgroups defined by age and sex.

library("hesim")
library("data.table")

# Treatment strategies
strategies <- data.table(strategy_id = 1:2,
                         strategy_name = c("Standard prosthesis", "New prosthesis"))

# Patients
ages <- seq(55, 75, 5)
age_weights <- c(.05, .1, .4, .25, .20)
gender_weights <- c(.65, .35)
weights <- rep(age_weights, times = 2) * 
           rep(gender_weights, each = length(ages))
patients <- data.table(patient_id = 1:10,
                       grp_id = 1:10,
                       gender = rep(c("Female", "Male"), each = length(ages)),
                       age = rep(ages, times = 2),
                       patient_wt = weights)
hesim_dat <- hesim_data(strategies = strategies,
                        patients = patients)
print(hesim_dat)
## $strategies
##    strategy_id       strategy_name
## 1:           1 Standard prosthesis
## 2:           2      New prosthesis
## 
## $patients
##     patient_id grp_id gender age patient_wt
##  1:          1      1 Female  55     0.0325
##  2:          2      2 Female  60     0.0650
##  3:          3      3 Female  65     0.2600
##  4:          4      4 Female  70     0.1625
##  5:          5      5 Female  75     0.1300
##  6:          6      6   Male  55     0.0175
##  7:          7      7   Male  60     0.0350
##  8:          8      8   Male  65     0.1400
##  9:          9      9   Male  70     0.0875
## 10:         10     10   Male  75     0.0700
## 
## attr(,"class")
## [1] "hesim_data"

The model will be simulated for each treatment strategy and patient combination. Data containing treatment strategy and patient characteristics can be generated using expand().

data <- expand(hesim_dat, by = c("strategies", "patients"))
head(data)
##    strategy_id patient_id       strategy_name grp_id gender age patient_wt
## 1:           1          1 Standard prosthesis      1 Female  55     0.0325
## 2:           1          2 Standard prosthesis      2 Female  60     0.0650
## 3:           1          3 Standard prosthesis      3 Female  65     0.2600
## 4:           1          4 Standard prosthesis      4 Female  70     0.1625
## 5:           1          5 Standard prosthesis      5 Female  75     0.1300
## 6:           1          6 Standard prosthesis      6   Male  55     0.0175

2.2 Parameters

2.2.1 Transition probabilities

Transition probabilities from state \(i\) (rows) to state \(j\) (columns) are determined using the parameters shown in the table below:

  • C: The complement of other probabilities in a given row
  • omrPTHR: Operative mortality rate following primary THR
  • rr: Revision rate for prosthesis
  • mr: Age and gender-specific mortality rates
  • omrRTHR: Operative mortality rate following revision THR
  • rrr: Re-revision rate
Primary THR Successful primary Revision THR Successful revision Death
Primary THR 0 C 0 0 omrPTHR
Successful primary 0 C rr 0 mr
Revision THR 0 0 0 C omrRTHR + mr
Successful revision 0 0 rrr C mr
Death 0 0 0 0 1

Three parameters of the transition probability matrix are assumed to be constant in the model: (i) the operative mortality rate following primary THR, omrPTHR, (ii) the operative mortality rate following revision THR, omrRTHR, and the re-revision rate, rrr. In a sample of 100 patients receiving primary THR 2 died implying that omrPTHR can be characterized by a beta distribution with \(\alpha = 2\) and \(\beta = 98\). Similarly, in a sample of 100 patients experiencing a revision procedure, four patients had another procedure within one year suggesting that rrr can be characterized by a beta distribution with \(\alpha = 4\) and \(\beta = 96\). Finally. there was information available for omrRTHR, so it assumed to follow the same beta distribution (\(\alpha = 2\) and \(\beta = 98\)) as omrPTHR.

The remaining parameters, rr and mr, are time-varying. The yearly mortality rates, mr, are stratified by age and sex.

print(mort_tbl)
##   age_lower age_upper    male  female
## 1        35        45 0.00151 0.00099
## 2        45        55 0.00393 0.00260
## 3        55        65 0.01090 0.00670
## 4        65        75 0.03160 0.01930
## 5        75        85 0.08010 0.05350
## 6        85       Inf 0.18790 0.15480

Revision rates, rr, were modeled using a proportional hazards Weibull model. The scale parameter was modeled as a function of age and indicators for male sex and and whether a new prosthesis was used. That is, given a scale parameter \(\lambda\) and a shape parameter \(\gamma\), the survival function is,

\[ S(t) = \exp(-\lambda t^\gamma) \\ \lambda = \exp(\beta_0 + \beta_1 \cdot age + \beta_2 \cdot male + \beta_3 \cdot new) \\ \]

Note that this Weibull distribution corresponds to the distribution implemented in flexsurv::pweibullPH() with \(a = \gamma\) and \(m = \lambda\). It can be shown (see Appendix below) that the transition probabilities (with a one-year model cycle) are given by,

\[ 1 - \exp \left\{\lambda\left[(t-1)^\gamma - t^\gamma \right] \right\} \] The coefficients from the regression model and the variance-covariance matrix used for the PSA are stored in rr_coef and rr_vcov, respectively.

print(rr_coef)
##    lngamma       cons        age       male        np1 
##  0.3740968 -5.4909350 -0.0367022  0.7685360 -1.3444740
print(rr_vcov)
##              lngamma        cons           age        male        np1
## lngamma  0.002251512 -0.00569100  2.800000e-08  0.00000510  0.0002590
## cons    -0.005691000  0.04321908 -7.830000e-04 -0.00724700 -0.0006420
## age      0.000000028 -0.00078300  2.715661e-05  0.00003300 -0.0001110
## male     0.000005100 -0.00724700  3.300000e-05  0.01189539  0.0001840
## np1      0.000259000 -0.00064200 -1.110000e-04  0.00018400  0.1463686

2.2.2 Utility

The mean (standard error) of utility was estimated to be 0.85 (0.03), 0.30 (0.03), and 0.75 (0.04) in the successful primary, revision, and successful revision health states, respectively.

2.2.3 Costs

The largest costs are the cost of the prostheses themselves. The standard prosthesis costs \(£394\) while the new prosthesis costs \(£579\). Both are assumed to be known with certainty.

The model assumes that there are no ongoing medical costs. The only remaining cost is therefore the cost of the revision procedure, which was estimated to have a mean of \(£5,294\) and standard error of \(£1,487\).

2.2.4 Combining all parameters

All underlying parameter estimates are stored in a list.

params <- list(
  # Transition probabilities
  ## Operative mortality following primary THR
  omrPTHR_shape1 = 2, 
  omrPTHR_shape2 = 98,
  
  ## Revision rate for prosthesis
  rr_coef = rr_coef,
  rr_vcov = rr_vcov,
    
  ## Mortality_rates
  mr = mort_tbl,
  
  ## Operative mortality following revision THR
  omrRTHR_shape1 = 2,
  omrRTHR_shape2 = 98,
  
  ## re-revision rate
  rrr_shape1 = 4,
  rrr_shape2 = 96,
  
  # Utility
  u_mean = c(PrimaryTHR = 0, SuccessP = .85, Revision = .30, SuccessR = .75),
  u_se = c(PrimaryTHR = 0, SuccessP = .03, Revision = .03, SuccessR = .04),
  
  # Costs
  c_med_mean = c(PrimaryTHR = 0, SuccessP = 0, Revision = 5294, SuccessR = 0),
  c_med_se = c(PrimaryTHR = 0, SuccessP = 0, Revision = 1487, SuccessR = 0),
  c_Standard = 394,
  c_NP1 = 579
)

2.3 Random number generation

As noted above, omrPTHR, omrRTHR, and rrr are drawn from beta distributions with \(\alpha\) and \(\beta\) (i.e. shape1 and shape2) specified. Similarly, utility is drawn from a beta distribution, but shape1 and shape2 are derived from the mean and standard error using the method of moments. The mortality rate and the cost of the prostheses are assumed to be known with certainty. The medical costs associated with health states are drawn from a gamma distribution, for which, like utility, the underlying parameters are derived from the mean and standard error using the method of moments. Finally, the parameters of the Weibull survival model are drawn from a multivariate normal distribution using the point estimates and the variance-covariance matrix. 500 samples will be drawn for the PSA.

rng_def <- define_rng({
  list( 
    omrPTHR = beta_rng(shape1 = omrPTHR_shape1, shape2 = omrPTHR_shape2),
    rr_coef = multi_normal_rng(mu = rr_coef, Sigma = rr_vcov),
    mr_male = fixed(mr$male, names = mr$age_lower),
    mr_female = fixed(mr$female, names = mr$age_lower),
    omrRTHR = beta_rng(shape1 = omrRTHR_shape1, shape2 = omrRTHR_shape2),
    rrr = beta_rng(shape1 = rrr_shape1, shape2 = rrr_shape2),
    u = beta_rng(mean = u_mean, sd = u_se),
    c_med = gamma_rng(mean = c_med_mean, sd = c_med_se),
    c_Standard = c_Standard,
    c_NP1 = c_NP1
  )
}, n = 500)

2.4 Transformed parameters

The sampled parameter values are “transformed” as a function of the input data. When evaluating the define_tparams() expression, operations are vectorized and performed for each combination of the sampled parameters, input data, and time periods. The model will be simulated for 60 model cycles (i.e., 60 years) so we will create 60 time intervals of length 1.

Separate transformation functions are used for the transition model and the cost/utility models. This is done for computational efficiency since only the transition model depends on cycle time. In the transition model, the revision rate (rr) depends on the scale and the shape parameters, which, in turn, depend on the sampled values of the parameters from the Weibull model. The mortality rate depends on gender and a patient’s age during each model cycle.

transitions_def <- define_tparams({
  # Regression for revision risk
  male <- ifelse(gender == "Female", 0, 1)
  np1 <- ifelse(strategy_name == "Standard prosthesis", 0, 1)
  scale <- exp(rr_coef$cons + rr_coef$age * age + rr_coef$male * male + 
                 rr_coef$np1 * np1)
  shape <- exp(rr_coef$lngamma)
  rr <- 1 - exp(scale * ((time - 1)^shape - time^shape))
    
  # Mortality rate
  age_new <- age + time
  mr <- mr_female[["35"]] * (gender == "Female" & age_new >= 35 & age_new < 45) +
        mr_female[["45"]] * (gender == "Female" & age_new >= 45 & age_new < 55) +
        mr_female[["55"]] * (gender == "Female" & age_new >= 55 & age_new < 65) +
        mr_female[["65"]] * (gender == "Female" & age_new >= 65 & age_new < 75) +
        mr_female[["75"]] * (gender == "Female" & age_new >= 75 & age_new < 85) +
        mr_female[["85"]] * (gender == "Female" & age_new >= 85) +
        
        mr_male[["35"]] * (gender == "Male" & age_new >= 35 & age_new < 45) +
        mr_male[["45"]] * (gender == "Male" & age_new >= 45 & age_new < 55) +
        mr_male[["55"]] * (gender == "Male" & age_new >= 55 & age_new < 65) +
        mr_male[["65"]] * (gender == "Male" & age_new >= 65 & age_new < 75) +
        mr_male[["75"]] * (gender == "Male" & age_new >= 75 & age_new < 85) +
        mr_male[["85"]] * (gender == "Male" & age_new >= 85)
  
  list(
    tpmatrix = tpmatrix(
      0, C, 0, 0, omrPTHR,
      0, C, rr, 0, mr,
      0, 0, 0, C, omrRTHR + mr,
      0, 0, rrr, C, mr,
      0, 0, 0, 0, 1)
  )
}, times = 1:60)

statevals_def <- define_tparams({
  c_prosthesis <- ifelse(strategy_name == "Standard prosthesis",
                         c_Standard,
                         c_NP1)
  list(
    utility = u,
    costs = list(
            prosthesis = c_prosthesis,
      medical = c_med
    )
  )
})

2.5 The model

The model is defined by specifying parameter estimates, a random number generation expression for the PSA, and the transformed parameter expressions.

mod_def <- define_model(tparams_def = list(transitions_def, 
                                           statevals_def),
                        rng_def = rng_def, 
                        params = params)

3 Simulation

The economic model is created from the input data and the defined model. Arguments for instantiating the cost models (a list of objects of class StateVals) can be specified with a named list containing the values of arguments to pass to StateVals$new(). In this case, we note that the model for the cost of the prostheses is based on one-time costs accrued at the start of the model (with no discounting); conversely, medical costs accrue by weighting state values by time spent in the health states (in the current model simply the cost of revision over 1 year).

cost_args <- list(
  prosthesis = list(method = "starting"),
  medical = list(method = "wlos")
)
econmod <- create_CohortDtstm(mod_def, data,
                              cost_args = cost_args)

3.1 Health state probabilities

Health state probabilities are simulated for 60 model cycles.

econmod$sim_stateprobs(n_cycles = 60)

The expected number of patients per 1,000 in each health state is plotted below. The counts in the plot are for patient_id = 2, a 60 year old female as in the original textbook example. Since a PSA was performed both mean values and 95 percent credible intervals can be displayed. Patients are more likely to have a revision with a standard prosthesis than with the new prosthesis.

3.2 Costs and QALYs

To again be consistent with the textbook example, QALYs and costs are simulated with discount rates of .015 and 0.06, respectively. QALYs and costs (when method = "wlos") are computed with a right Riemann sum, meaning that they are measured at the right endpoint of each model cycle.

econmod$sim_qalys(dr = .015, integrate_method = "riemann_right")
econmod$sim_costs(dr = .06, integrate_method = "riemann_right")

4 Decision analysis

4.1 Subgroup analysis

Subgroup analyses can be performed with $sim_summarize() using the by_grp = TRUE option. Cost-effectiveness analyses are then performed for each subgroup (grp_id) from input data. We will begin by reporting results for the 60-year old female, which are consistent with those from the textbook.

ce_sim <- econmod$summarize(by_grp = TRUE)
wtp <- seq(0, 25000, 500)
icea_pw_out <- icea_pw(ce_sim, comparator = 1, dr_qalys = 0.015, dr_costs = .06,
                       k = wtp)

ce_sim$qalys[grp_id == 2, 
              .(mean = mean(qalys)),
                by = c("strategy_id", "grp_id")]
##    strategy_id grp_id     mean
## 1:           1      2 14.64449
## 2:           2      2 14.68825
ce_sim$costs[grp_id == 2 & category == "total", 
            .(mean = mean(costs)),
              by = c("strategy_id", "grp_id")]
##    strategy_id grp_id     mean
## 1:           1      2 513.7642
## 2:           2      2 612.4975

We can then compute incremental cost-effectiveness ratios for each subgroup. There is considerable variation which is not unexpected since the the revision rate for prostheses (rr) depends on covariates.

icer_tbl(icea_pw_out, output = "data.table")
##     strategy_id grp_id            iqalys         icosts                  inmb
##  1:           2      1 0.07 (0.03, 0.13)  65 (-53, 134)  3,471 (1,286, 6,479)
##  2:           2      2 0.04 (0.02, 0.08)   99 (13, 149)    2,089 (744, 4,013)
##  3:           2      3 0.03 (0.01, 0.05)  125 (64, 160)    1,182 (377, 2,365)
##  4:           2      4 0.02 (0.01, 0.03) 145 (102, 169)      609 (132, 1,302)
##  5:           2      5 0.01 (0.00, 0.02) 159 (131, 175)         266 (-8, 669)
##  6:           2      6 0.11 (0.04, 0.21) -33 (-232, 95) 5,667 (2,159, 10,461)
##  7:           2      7 0.07 (0.03, 0.13) 31 (-113, 123)  3,392 (1,316, 6,342)
##  8:           2      8 0.04 (0.02, 0.07)  80 (-19, 143)    1,929 (722, 3,681)
##  9:           2      9 0.02 (0.01, 0.04)  115 (48, 158)    1,029 (321, 2,057)
## 10:           2     10 0.01 (0.00, 0.02)  141 (95, 168)       499 (94, 1,083)
##          icer     conclusion
##  1:       917 Cost-effective
##  2:     2,256 Cost-effective
##  3:     4,785 Cost-effective
##  4:     9,610 Cost-effective
##  5:    18,735 Cost-effective
##  6: Dominates Cost-effective
##  7:       449 Cost-effective
##  8:     1,985 Cost-effective
##  9:     5,038 Cost-effective
## 10:    10,985 Cost-effective

4.2 Overall

Estimates aggregated across all patients can also be computed with $sim_summarize() by using by_grp = FALSE. In this case, overall costs and QALYs are a weighted average (using the column patient_wt) of costs and QALYs for each patient in the input data.

ce_sim <- econmod$summarize(by_grp = FALSE)
icea_pw_out <- icea_pw(ce_sim, comparator = 1, dr_qalys = .015, dr_costs = .06,
                       k = wtp)
icer_tbl(icea_pw_out)
##                   1   2                   
## Incremental QALYs "-" "0.03 (0.01, 0.05)" 
## Incremental costs "-" "117 (55, 157)"     
## Incremental NMB   "-" "1,302 (447, 2,510)"
## ICER              "-" "4,117"             
## Conclusion        "-" "Cost-effective"

5 Appendix: Transition probabilities from a Weibull survival model

In general, the transition probability of an event given a model cycle is the probability a patient has an event during the cycle conditional on not having an event up until that cycle. That is, given a survivor function, \(S(t)\) and a cycle of length \(u\), the transition probability, \(tp(t_u)\) of an event is,

\[ \begin{align} tp(t_u) &= \frac{1 - S(t)}{S(t-u)} \\ &= \frac{1 - exp\{-H(t)\}}{exp\{-H(t-u)\}} \\ &= 1 - exp\{H(t-u) - H(t)\}, \end{align} \]

where \(H(t)\) is the cumulative hazard function.

The proportional hazard Weibull distribution with scale parameter \(\lambda\) and shape parameter, \(\gamma\) has the cumulative hazard function,

\[ H(t) = \lambda t^\gamma \] The transition probability of an event for the Weibull model is thus,

\[ \begin{align} tp(t_u) &= 1 - exp\{\lambda (t-u)^\gamma -\lambda t^\gamma\} \\ &= 1 - exp\{\lambda[(t-u)^\gamma - t^\gamma]\} \end{align} \]