Heterogeneity & Demographic Analysis

2023-07-18

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    75     1
##  2    67     0
##  3    58     0
##  4    63     0
##  5    55     1
##  6    60     1
##  7    68     0
##  8    63     1
##  9    66     0
## 10    76     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          470.23578695  613.9316623  700.278258 704.5466169
## standard - Effect          5.05860925   24.2050060   27.255222  25.9194304
## standard - Cost Diff.               -            -           -           -
## standard - Effect Diff.             -            -           -           -
## standard - Icer                     -            -           -           -
## np1 - Cost               599.19333183  637.9767000  662.750240 663.8741848
## np1 - Effect               5.07524179   24.4874532   27.540020  26.1897501
## np1 - Cost Diff.        -165.40882382 -105.3260667  -37.528018 -40.6724321
## np1 - Effect Diff.         0.01663254    0.1948185    0.230908   0.2703197
## np1 - Icer              -354.56585682 -309.9367104 -177.278286  10.1345801
##                             3rd Qu.         Max.
## standard - Cost         794.8012271  878.7813785
## standard - Effect        29.2164282   31.5292548
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              689.4751604  713.3725547
## np1 - Effect             29.4828147   31.7651919
## np1 - Cost Diff.         24.0450377  128.9575449
## np1 - Effect Diff.        0.3391523    0.4665109
## np1 - Icer              115.2176112 7753.3265967
## 
## * 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 25919.43 704546.6
## np1      26189.75 663874.2
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -40.67243    0.2703197 -150.4605 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    57     0    0.467
##  2    54     0    0.783
##  3    62     1    0.638
##  4    63     0    0.776
##  5    68     1    0.864
##  6    60     0    0.336
##  7    54     0    0.102
##  8    64     0    0.380
##  9    63     0    0.908
## 10    47     1    0.541
## # ℹ 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.002444 0.208542 0.520190 0.507997 0.792633 0.996271 
## 
## Total weight: 50.79967
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.     Median        Mean
## standard - Cost          470.23578695  605.0062810 633.703456 691.7877979
## standard - Effect          5.05860925   24.4991251  26.729786  25.4356749
## standard - Cost Diff.               -            -          -           -
## standard - Effect Diff.             -            -          -           -
## standard - Icer                     -            -          -           -
## np1 - Cost               599.19333183  635.5509751 643.518623 660.3053583
## np1 - Effect               5.07524179   24.8264025  27.104563  25.6940475
## np1 - Cost Diff.        -163.38052116 -102.7776207   9.607599 -31.4824396
## np1 - Effect Diff.         0.01663254    0.1948185   0.220806   0.2583727
## np1 - Icer              -353.62679735 -307.3529333  54.342778 212.4876176
##                             3rd Qu.        Max.
## standard - Cost         786.6690449  875.943516
## standard - Effect        29.0596426   31.808168
## standard - Cost Diff.             -           -
## standard - Effect Diff.           -           -
## standard - Icer                   -           -
## np1 - Cost              687.1659033  712.562995
## np1 - Effect             29.2683350   32.047217
## np1 - Cost Diff.         30.5446941  128.957545
## np1 - Effect Diff.        0.3272774    0.462014
## 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 25435.67 691787.8
## np1      25694.05 660305.4
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.     ICER     Ref.
## np1  -31.48244    0.2583727 -121.849 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.