Heterogeneity & Demographic Analysis

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 different 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    49     0
##  2    51     0
##  3    67     1
##  4    80     0
##  5    78     0
##  6    64     0
##  7    59     1
##  8    45     1
##  9    70     1
## 10    69     1
## # ℹ 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          500.08967163  605.0062810 626.353775 696.8957078
## standard - Effect         10.06345874   24.4991251  27.255222  26.0700521
## standard - Cost Diff.               -            -          -           -
## standard - Effect Diff.             -            -          -           -
## standard - Icer                     -            -          -           -
## np1 - Cost               607.16692250  635.5509751 641.354798 661.7200911
## np1 - Effect              10.13073146   24.8264025  27.540020  26.3353512
## np1 - Cost Diff.        -159.96283707 -122.7948420  15.001022 -35.1756167
## np1 - Effect Diff.         0.05767389    0.1948185   0.220806   0.2652992
## np1 - Icer              -351.98058303 -327.6476693  65.667990  -9.8267942
##                             3rd Qu.         Max.
## standard - Cost         819.1977737  871.1621236
## standard - Effect        29.0596426   30.8545173
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              696.4029317  711.1992865
## np1 - Effect             29.2683350   31.0829546
## np1 - Cost Diff.         30.5446941  107.0772509
## np1 - Effect Diff.        0.3747771    0.4544649
## np1 - Icer              156.7853582 1856.5985016
## 
## * 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 26070.05 696895.7
## np1      26335.35 661720.1
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -35.17562    0.2652992 -132.5885 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    73     0   0.599 
##  2    52     0   0.0205
##  3    58     1   0.919 
##  4    64     1   0.791 
##  5    67     0   0.312 
##  6    58     0   0.208 
##  7    61     1   0.195 
##  8    66     0   0.122 
##  9    64     0   0.824 
## 10    37     1   0.604 
## # ℹ 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.
## 
## * Weights distribution:
## 
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.0002093 0.2240524 0.5423516 0.4985264 0.7658135 0.9722127 
## 
## Total weight: 49.85264
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.       Median        Mean
## standard - Cost          543.46225608  613.9316623  700.2782575 712.1262845
## standard - Effect         10.06345874   24.4991251   27.7806580  26.6666313
## standard - Cost Diff.               -            -            -           -
## standard - Effect Diff.             -            -            -           -
## standard - Icer                     -            -            -           -
## np1 - Cost               618.86571941  637.9767000  662.7502398 665.9992837
## np1 - Effect              10.13073146   24.8264025   27.9754765  26.9482522
## np1 - Cost Diff.        -166.84613181 -122.7948420  -37.5280177 -46.1270008
## np1 - Effect Diff.         0.06727271    0.2086924    0.2291369   0.2816209
## np1 - Icer              -355.21474694 -327.6476693 -177.2782857 -71.6297433
##                             3rd Qu.       Max.
## standard - Cost         819.1977737 880.792467
## standard - Effect        29.6867852  31.808168
## standard - Cost Diff.             -          -
## standard - Effect Diff.           -          -
## standard - Icer                   -          -
## np1 - Cost              696.4029317 713.946335
## np1 - Effect             30.1262538  32.047217
## np1 - Cost Diff.         24.0450377  75.403463
## np1 - Effect Diff.        0.3747771   0.469705
## np1 - Icer              115.2176112 956.915671
## 
## * 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 26666.63 712126.3
## np1      26948.25 665999.3
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1    -46.127    0.2816209 -163.7911 standard

Parallel computing

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

  • Define a cluster with the use_cluster() functions (i.e. use_cluster(4) to use 4 cores).
  • Run the analysis as usual.
  • To stop using parallel computing use the close_cluster() function.

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