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 57 0
## 2 66 0
## 3 45 1
## 4 46 1
## 5 77 0
## 6 66 1
## 7 61 0
## 8 45 1
## 9 47 1
## 10 54 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 438.70535048 613.9316623 724.8014149 712.4086104
## standard - Effect 6.12465030 24.4991251 26.7297859 26.2572129
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 590.76054210 637.9767000 669.6696256 666.1073560
## np1 - Effect 6.13624942 24.8264025 27.1045630 26.5367561
## np1 - Cost Diff. -159.96283707 -122.7948420 -55.1317893 -46.3012544
## np1 - Effect Diff. 0.01159912 0.2086924 0.2543343 0.2795432
## np1 - Icer -351.98058303 -327.6476693 -220.7462904 40.6646363
## 3rd Qu. Max.
## standard - Cost 819.1977737 8.711621e+02
## standard - Effect 29.0596426 3.129948e+01
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 696.4029317 7.111993e+02
## np1 - Effect 29.2683350 3.153286e+01
## np1 - Cost Diff. 24.0450377 1.520552e+02
## np1 - Effect Diff. 0.3747771 4.544649e-01
## np1 - Icer 115.2176112 1.310920e+04
##
## * 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 26257.21 712408.6
## np1 26536.76 666107.4
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -46.30125 0.2795432 -165.6318 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 72 0 0.328
## 2 74 0 0.0487
## 3 66 1 0.722
## 4 63 0 0.137
## 5 65 1 0.862
## 6 81 0 0.593
## 7 41 0 0.887
## 8 55 0 0.112
## 9 72 1 0.311
## 10 62 0 0.404
## # ℹ 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.003025 0.195726 0.515662 0.474016 0.708737 0.993275
##
## Total weight: 47.40158
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 470.23578695 592.3687128 613.9316623 659.7703622
## standard - Effect 5.05860925 23.3226486 26.7297859 25.3853784
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 599.19333183 632.1186231 637.9767000 651.2325411
## np1 - Effect 5.07524179 23.4706053 27.1045630 25.6155801
## np1 - Cost Diff. -163.38052116 -72.7355609 24.0450377 -8.5378211
## np1 - Effect Diff. 0.01663254 0.1756522 0.2086924 0.2302017
## np1 - Icer -353.62679735 -264.2142952 115.2176112 225.9036903
## 3rd Qu. Max.
## standard - Cost 749.32457 875.943516
## standard - Effect 29.05964 31.529255
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 676.58901 712.562995
## np1 - Effect 29.26833 31.765192
## np1 - Cost Diff. 39.74991 128.957545
## np1 - Effect Diff. 0.27529 0.462014
## np1 - Icer 226.29892 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 25385.38 659770.4
## np1 25615.58 651232.5
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -8.537821 0.2302017 -37.08844 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.