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 59 0
## 2 50 0
## 3 53 1
## 4 54 0
## 5 91 1
## 6 58 1
## 7 66 1
## 8 64 1
## 9 41 0
## 10 55 1
## # ℹ 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 619.6748473 700.2782575 714.9123509
## standard - Effect 5.05860925 24.4991251 26.7297859 25.7832368
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 599.19333183 639.5383123 662.7502398 666.8106344
## np1 - Effect 5.07524179 24.8264025 27.1045630 26.0612642
## np1 - Cost Diff. -163.38052116 -122.7948420 -37.5280177 -48.1017165
## np1 - Effect Diff. 0.01663254 0.2086924 0.2346579 0.2780274
## np1 - Icer -353.62679735 -327.6476693 -177.2782857 -23.8482711
## 3rd Qu. Max.
## standard - Cost 819.1977737 875.943516
## standard - Effect 29.0596426 31.529255
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 696.4029317 712.562995
## np1 - Effect 29.2683350 31.765192
## np1 - Cost Diff. 19.8634650 128.957545
## np1 - Effect Diff. 0.3747771 0.462014
## np1 - Icer 91.5391332 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 25783.24 714912.4
## np1 26061.26 666810.6
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -48.10172 0.2780274 -173.0107 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 58 0 0.373
## 2 69 0 0.980
## 3 69 0 0.101
## 4 51 1 0.157
## 5 52 1 0.880
## 6 55 0 0.574
## 7 49 1 0.928
## 8 59 1 0.364
## 9 64 1 0.549
## 10 61 0 0.995
## # ℹ 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.004403 0.253393 0.482372 0.515749 0.807083 0.998088
##
## Total weight: 51.57485
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 470.23578695 592.3687128 621.5892423 684.2078516
## standard - Effect 5.05860925 23.8944033 27.0352021 26.0413267
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 599.19333183 632.1186231 640.0588497 658.1308286
## np1 - Effect 5.07524179 24.1295078 27.3576776 26.2959986
## np1 - Cost Diff. -163.38052116 -99.5031416 18.4696074 -26.0770230
## np1 - Effect Diff. 0.01663254 0.1756522 0.2116899 0.2546719
## np1 - Icer -353.62679735 -304.0330575 83.6463073 18.0332377
## 3rd Qu. Max.
## standard - Cost 786.6690449 875.943516
## standard - Effect 29.0596426 31.299481
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 687.1659033 712.562995
## np1 - Effect 29.2683350 31.532860
## np1 - Cost Diff. 39.7499103 128.957545
## np1 - Effect Diff. 0.3272774 0.462014
## np1 - Icer 226.2989208 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 26041.33 684207.9
## np1 26296.00 658130.8
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -26.07702 0.2546719 -102.3946 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.