Heterogeneity & Demographic Analysis

2023-03-21

Introduction

Heterogeneity analysis is a way to explore how the results of a model can vary depending on the characteristics of individuals in a population, and demographic analysis estimates the average values of a model over an entire population.

In practice these two analyses naturally complement each other: heterogeneity analysis runs the model on multiple sets of parameters (reflecting differents characteristics found in the target population), and demographic analysis combines the results.

For this example we will use the result from the assessment of a new total hip replacement previously described in vignette("d-non-homogeneous", "heemod").

Population characteristics

The characteristics of the population are input from a table, with one column per parameter and one row per individual. Those may be for example the characteristics of the indiviuals included in the original trial data.

For this example we will use the characteristics of 100 individuals, with varying sex and age, specified in the data frame tab_indiv:

tab_indiv
## # A tibble: 100 × 2
##      age   sex
##    <dbl> <int>
##  1    71     0
##  2    58     1
##  3    58     0
##  4    60     1
##  5    62     0
##  6    69     1
##  7    46     1
##  8    57     1
##  9    79     1
## 10    55     0
## # … with 90 more rows
library(ggplot2)
ggplot(tab_indiv, aes(x = age)) +
  geom_histogram(binwidth = 2)

Running the analysis

res_mod, the result we obtained from run_model() in the Time-varying Markov models vignette, can be passed to update() to update the model with the new data and perform the heterogeneity analysis.

res_h <- update(res_mod, newdata = tab_indiv)
## No weights specified in update, using equal weights.
## Updating strategy 'standard'...
## Updating strategy 'np1'...

Interpreting results

The summary() method reports summary statistics for cost, effect and ICER, as well as the result from the combined model.

summary(res_h)
## An analysis re-run on 100 parameter sets.
## 
## * Unweighted analysis.
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.      Median       Mean
## standard - Cost          4.254235e+02  611.6289179 629.4680260 694.269716
## standard - Effect        4.554756e+00   25.5696426  27.7806580  26.532292
## standard - Cost Diff.               -            -           -          -
## standard - Effect Diff.             -            -           -          -
## standard - Icer                     -            -           -          -
## np1 - Cost               5.872463e+02  637.3508591 642.2020458 660.970037
## np1 - Effect             4.561086e+00   25.8299343  27.9754765  26.799720
## np1 - Cost Diff.        -1.648814e+02 -110.7286273  13.1000189 -33.299679
## np1 - Effect Diff.       6.330508e-03    0.1948185   0.2214442   0.267428
## np1 - Icer              -3.543243e+02 -316.4394659  63.4214929 261.605811
##                             3rd Qu.         Max.
## standard - Cost         802.3426777 8.780434e+02
## standard - Effect        29.9639255 3.130710e+01
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              691.6140504 7.131620e+02
## np1 - Effect             30.4095470 3.154057e+01
## np1 - Cost Diff.         25.7219412 1.618227e+02
## np1 - Effect Diff.        0.3499204 4.653403e-01
## np1 - Icer              125.9207494 2.556236e+04
## 
## * Combined result:
## 
## 2 strategies run for 60 cycles.
## 
## Initial state counts:
## 
## PrimaryTHR = 1000L
## SuccessP = 0L
## RevisionTHR = 0L
## SuccessR = 0L
## Death = 0L
## 
## Counting method: 'beginning'.
## 
## Values:
## 
##           utility     cost
## standard 26532.29 694269.7
## np1      26799.72 660970.0
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -33.29968     0.267428 -124.5183 standard

The variation of cost or effect can then be plotted.

plot(res_h, result = "effect", binwidth = 5)

plot(res_h, result = "cost", binwidth = 50)

plot(res_h, result = "icer", type = "difference",
     binwidth = 500)

plot(res_h, result = "effect", type = "difference",
     binwidth = .1)

plot(res_h, result = "cost", type = "difference",
     binwidth = 30)

The results from the combined model can be plotted similarly to the results from run_model().

plot(res_h, type = "counts")

Weighted results

Weights can be used in the analysis by including an optional column .weights in the new data to specify the respective weights of each strata in the target population.

tab_indiv_w
## # A tibble: 100 × 3
##      age   sex .weights
##    <dbl> <int>    <dbl>
##  1    81     1   0.109 
##  2    76     0   0.424 
##  3    61     0   0.461 
##  4    58     1   0.303 
##  5    42     1   0.558 
##  6    61     0   0.0293
##  7    57     1   0.865 
##  8    80     1   0.0892
##  9    83     1   0.172 
## 10    54     0   0.0510
## # … with 90 more rows
res_w <- update(res_mod, newdata = tab_indiv_w)
## Updating strategy 'standard'...
## Updating strategy 'np1'...
res_w
## An analysis re-run on 100 parameter sets.
## 
## * Weigths distribution:
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.02251 0.28270 0.46206 0.49745 0.73346 0.99673 
## 
## Total weight: 49.74493
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.      Median        Mean
## standard - Cost          485.85297365  605.0062810 629.4680260 698.4756444
## standard - Effect          9.32287610   25.5696426  27.7806580  26.6638850
## standard - Cost Diff.               -            -           -           -
## standard - Effect Diff.             -            -           -           -
## standard - Icer                     -            -           -           -
## np1 - Cost               603.34263272  635.5509751 642.2020458 662.1621740
## np1 - Effect               9.38064927   25.8299343  27.9754765  26.9353285
## np1 - Cost Diff.        -164.88137326 -129.4829089  13.1000189 -36.3134704
## np1 - Effect Diff.         0.04405769    0.1948185   0.2294328   0.2714434
## np1 - Icer              -354.32431375 -333.0519971  60.8289935  -4.5262903
##                             3rd Qu.         Max.
## standard - Cost         828.5434528  878.0433890
## standard - Effect        29.0749005   31.7692206
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              699.0605439  713.1620157
## np1 - Effect             29.5008365   32.0078346
## np1 - Cost Diff.         30.5446941  117.4896591
## np1 - Effect Diff.        0.3887769    0.4653403
## np1 - Icer              156.7853582 2666.7229585
## 
## * Combined result:
## 
## 2 strategies run for 60 cycles.
## 
## Initial state counts:
## 
## PrimaryTHR = 1000L
## SuccessP = 0L
## RevisionTHR = 0L
## SuccessR = 0L
## Death = 0L
## 
## Counting method: 'beginning'.
## 
## Values:
## 
##           utility     cost
## standard 26663.89 698475.6
## np1      26935.33 662162.2
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -36.31347    0.2714434 -133.7791 standard

Parallel computing

Updating can be significantly sped up by using parallel computing. This can be done in the following way:

Results may vary depending on the machine, but we found speed gains to be quite limited beyond 4 cores.