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    59     1
##  2    56     1
##  3    56     0
##  4    54     1
##  5    50     1
##  6    56     1
##  7    27     0
##  8    55     0
##  9    68     1
## 10    65     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 636.5440850 700.1868729
## standard - Effect         13.56976193   24.2050060  26.7297859  26.1336632
## standard - Cost Diff.               -            -           -           -
## standard - Effect Diff.             -            -           -           -
## standard - Icer                     -            -           -           -
## np1 - Cost               607.16692250  635.5509751 644.8774403 662.6481086
## np1 - Effect              13.62743581   24.4874532  27.1045630  26.4019315
## np1 - Cost Diff.        -165.40882382 -122.7948420   8.3333553 -37.5387642
## np1 - Effect Diff.         0.05767389    0.1948185   0.2284374   0.2682682
## np1 - Icer              -354.56585682 -327.6476693  46.0297074 -23.6706472
##                             3rd Qu.         Max.
## standard - Cost         819.1977737  878.7813785
## standard - Effect        29.0596426   31.8081680
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              696.4029317  713.3725547
## np1 - Effect             29.2683350   32.0472170
## np1 - Cost Diff.         30.5446941  107.0772509
## np1 - Effect Diff.        0.3747771    0.4665109
## 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 26133.66 700186.9
## np1      26401.93 662648.1
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.    ICER     Ref.
## np1  -37.53876    0.2682682 -139.93 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    60     1   0.551 
##  2    61     1   0.954 
##  3    42     0   0.0456
##  4    51     0   0.556 
##  5    74     1   0.537 
##  6    61     0   0.140 
##  7    58     1   0.137 
##  8    59     1   0.427 
##  9    74     1   0.975 
## 10    52     0   0.283 
## # ℹ 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.006339 0.361987 0.550849 0.543349 0.769366 0.992799 
## 
## Total weight: 54.33489
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.     Median        Mean
## standard - Cost          470.23578695  608.9108842 629.415647 693.4287975
## standard - Effect          5.05860925   24.4991251  26.729786  25.7781948
## standard - Cost Diff.               -            -          -           -
## standard - Effect Diff.             -            -          -           -
## standard - Icer                     -            -          -           -
## np1 - Cost               599.19333183  636.6121615 642.187795 660.7307352
## np1 - Effect               5.07524179   24.8264025  27.104563  26.0383842
## np1 - Cost Diff.        -166.84613181  -99.5031416  12.772148 -32.6980622
## np1 - Effect Diff.         0.01663254    0.1948185   0.220806   0.2601894
## np1 - Icer              -355.21474694 -304.0330575  60.195636  48.9701128
##                             3rd Qu.        Max.
## standard - Cost         786.6690449  880.792467
## standard - Effect        29.0596426   31.299481
## standard - Cost Diff.             -           -
## standard - Effect Diff.           -           -
## standard - Icer                   -           -
## np1 - Cost              687.1659033  713.946335
## np1 - Effect             29.2683350   31.532860
## np1 - Cost Diff.         30.5446941  128.957545
## np1 - Effect Diff.        0.3272774    0.469705
## np1 - Icer              156.7853582 7753.326597
## 
## * 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 25778.19 693428.8
## np1      26038.38 660730.7
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -32.69806    0.2601894 -125.6702 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.