Heterogeneity & Demographic Analysis

2021-10-06

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    59     0
##  2    59     1
##  3    55     0
##  4    59     1
##  5    70     1
##  6    66     0
##  7    72     1
##  8    71     0
##  9    57     0
## 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          485.85297365  605.0062810 621.9893893 681.6219649
## standard - Effect         11.78433667   25.5696426  27.7806580  26.4450860
## standard - Cost Diff.               -            -           -           -
## standard - Effect Diff.             -            -           -           -
## standard - Icer                     -            -           -           -
## np1 - Cost               603.34263272  635.5509751 640.1676766 657.3713565
## np1 - Effect              11.82839436   25.8299343  27.9754765  26.6994945
## np1 - Cost Diff.        -164.88137326 -110.7286273  18.1782873 -24.2506084
## np1 - Effect Diff.         0.04405769    0.1948185   0.2122929   0.2544085
## np1 - Icer              -354.32431375 -316.4394659  82.0897023  21.6181531
##                             3rd Qu.         Max.
## standard - Cost         802.3426777  878.0433890
## standard - Effect        29.0531899   31.5986556
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              691.6140504  713.1620157
## np1 - Effect             29.3160811   31.8353665
## np1 - Cost Diff.         30.5446941  117.4896591
## np1 - Effect Diff.        0.3499204    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 26445.09 681622.0
## np1      26699.49 657371.4
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -24.25061    0.2544085 -95.32152 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    66     0  0.00317
##  2    53     0  0.389  
##  3    69     0  0.740  
##  4    74     1  0.767  
##  5    62     0  0.409  
##  6    59     1  0.722  
##  7    71     1  0.338  
##  8    88     1  0.826  
##  9    74     1  0.705  
## 10    48     1  0.189  
## # … 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.00317 0.37252 0.61302 0.54870 0.74733 0.99125 
## 
## Total weight: 54.87033
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.      Median        Mean
## standard - Cost          485.85297365  605.0062810 648.6200608 694.0752934
## standard - Effect          6.14259603   22.7930050  27.3769142  25.3423117
## standard - Cost Diff.               -            -           -           -
## standard - Effect Diff.             -            -           -           -
## standard - Icer                     -            -           -           -
## np1 - Cost               603.34263272  635.5509751 647.7147932 660.9684689
## np1 - Effect               6.16727815   23.0848338  27.7656911  25.6023681
## np1 - Cost Diff.        -167.83433856 -110.7286273 -15.8494795 -33.1068245
## np1 - Effect Diff.         0.02468212    0.1948185   0.2214442   0.2600564
## np1 - Icer              -355.65308588 -316.4394659 -76.1065687  91.9770058
##                             3rd Qu.         Max.
## standard - Cost         802.3426777  882.1752204
## standard - Effect        29.0459530   31.7692206
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              691.6140504  714.3408818
## np1 - Effect             29.2544960   32.0078346
## np1 - Cost Diff.         30.5446941  117.4896591
## np1 - Effect Diff.        0.3499204    0.4719046
## np1 - Icer              156.7853582 4648.5141231
## 
## * 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 25342.31 694075.3
## np1      25602.37 660968.5
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -33.10682    0.2600564 -127.3063 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.