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").
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:
## # A tibble: 100 × 2
## age sex
## <dbl> <int>
## 1 58 0
## 2 59 0
## 3 79 1
## 4 51 1
## 5 71 0
## 6 69 1
## 7 54 0
## 8 57 1
## 9 53 1
## 10 75 0
## # ℹ 90 more rows
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.
## No weights specified in update, using equal weights.
## Updating strategy 'standard'...
## Updating strategy 'np1'...
The summary() method reports summary statistics for
cost, effect and ICER, as well as the result from the combined
model.
## An analysis re-run on 100 parameter sets.
##
## * Unweighted analysis.
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 470.23578695 611.7003169 700.278258 708.7423760
## standard - Effect 5.05860925 24.4991251 26.729786 25.7140557
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 599.19333183 637.3702687 662.750240 665.1141721
## np1 - Effect 5.07524179 24.8264025 27.104563 25.9888998
## np1 - Cost Diff. -166.84613181 -122.7948420 -37.528018 -43.6282039
## np1 - Effect Diff. 0.01663254 0.1948185 0.230908 0.2748441
## np1 - Icer -355.21474694 -327.6476693 -177.278286 92.1906969
## 3rd Qu. Max.
## standard - Cost 819.1977737 880.792467
## standard - Effect 29.0596426 31.529255
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 696.4029317 713.946335
## np1 - Effect 29.2683350 31.765192
## np1 - Cost Diff. 25.6699518 128.957545
## np1 - Effect Diff. 0.3747771 0.469705
## np1 - Icer 125.6095479 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 25714.06 708742.4
## np1 25988.90 665114.2
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -43.6282 0.2748441 -158.738 standard
The variation of cost or effect can then be plotted.
The results from the combined model can be plotted similarly to the
results from run_model().
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.
## # A tibble: 100 × 3
## age sex .weights
## <dbl> <int> <dbl>
## 1 64 1 0.263
## 2 73 1 0.854
## 3 50 0 0.733
## 4 60 1 0.363
## 5 62 0 0.164
## 6 68 0 0.442
## 7 70 1 0.177
## 8 63 1 0.00996
## 9 60 1 0.303
## 10 71 1 0.0321
## # ℹ 90 more rows
## Updating strategy 'standard'...
## Updating strategy 'np1'...
## An analysis re-run on 100 parameter sets.
##
## * Weights distribution:
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.003892 0.176564 0.413413 0.455308 0.713927 0.990316
##
## Total weight: 45.53083
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 470.23578695 605.0062810 626.35378 689.9345488
## standard - Effect 5.05860925 24.4991251 26.72979 25.8428611
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 599.19333183 635.5509751 641.35480 659.7716455
## np1 - Effect 5.07524179 24.8264025 27.10456 26.1020370
## np1 - Cost Diff. -168.13918777 -99.5031416 15.00102 -30.1629033
## np1 - Effect Diff. 0.01663254 0.1948185 0.22725 0.2591759
## np1 - Icer -355.78704166 -304.0330575 65.66799 137.7704585
## 3rd Qu. Max.
## standard - Cost 786.6690449 882.6017906
## standard - Effect 29.0596426 31.5292548
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 687.1659033 714.4626028
## np1 - Effect 29.2683350 31.7651919
## np1 - Cost Diff. 30.5446941 128.9575449
## np1 - Effect Diff. 0.3272774 0.4725838
## np1 - Icer 156.7853582 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 25842.86 689934.5
## np1 26102.04 659771.6
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -30.1629 0.2591759 -116.38 standard
Updating can be significantly sped up by using parallel computing. This can be done in the following way:
use_cluster() functions
(i.e. use_cluster(4) to use 4 cores).close_cluster() function.Results may vary depending on the machine, but we found speed gains to be quite limited beyond 4 cores.