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")
.
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 x 2
## age sex
## <dbl> <int>
## 1 74 0
## 2 69 1
## 3 52 0
## 4 52 1
## 5 69 0
## 6 58 1
## 7 64 0
## 8 68 0
## 9 42 0
## 10 72 0
## # … with 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 485.85297365 605.0062810 626.9720129 674.2306303
## standard - Effect 11.78433667 22.7930050 27.5787861 25.8426593
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 603.34263272 635.5509751 641.5229814 655.2935917
## np1 - Effect 11.82839436 23.0848338 27.8705838 26.0866538
## np1 - Cost Diff. -155.93829747 -81.4171250 14.5509685 -18.9370386
## np1 - Effect Diff. 0.04405769 0.1948185 0.2122929 0.2439946
## np1 - Icer -349.93447295 -278.9894047 72.7555976 47.2384973
## 3rd Qu. Max.
## standard - Cost 761.4317051 865.5323779
## standard - Effect 29.0749005 31.5986556
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 680.0145801 709.5940804
## np1 - Effect 29.5008365 31.8353665
## np1 - Cost Diff. 30.5446941 117.4896591
## np1 - Effect Diff. 0.2918287 0.4456214
## np1 - Icer 156.7853582 2666.7229585
##
## * Combined result:
##
## 2 strategies run for 60 cycles.
##
## Initial state counts:
##
## PrimaryTHR = 1000L
## SuccessP = 0L
## RevisionTHR = 0L
## SuccessR = 0L
## Death = 0L
##
## Counting method: 'end'.
##
## Values:
##
## utility cost
## standard 25842.66 674230.6
## np1 26086.65 655293.6
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -18.93704 0.2439946 -77.61255 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 x 3
## age sex .weights
## <dbl> <int> <dbl>
## 1 44 0 0.602
## 2 67 1 0.386
## 3 56 0 0.373
## 4 69 1 0.635
## 5 49 1 0.517
## 6 60 0 0.646
## 7 47 1 0.417
## 8 51 1 0.225
## 9 70 0 0.881
## 10 61 1 0.616
## # … with 90 more rows
## Updating strategy 'standard'...
## Updating strategy 'np1'...
## An analysis re-run on 100 parameter sets.
##
## * Weigths distribution:
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.006855 0.339071 0.563446 0.522450 0.719654 0.982565
##
## Total weight: 52.24502
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 485.85297365 605.0062810 629.4680260 680.492765
## standard - Effect 9.32287610 22.7930050 27.3769142 25.719891
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 603.34263272 635.5509751 642.2020458 657.088901
## np1 - Effect 9.38064927 23.0848338 27.7656911 25.969404
## np1 - Cost Diff. -155.93829747 -110.7286273 13.1000189 -23.403864
## np1 - Effect Diff. 0.04405769 0.1721907 0.2214442 0.249513
## np1 - Icer -349.93447295 -316.4394659 63.4214929 47.593822
## 3rd Qu. Max.
## standard - Cost 802.3426777 865.5323779
## standard - Effect 29.0749005 31.5986556
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6140504 709.5940804
## np1 - Effect 29.5008365 31.8353665
## np1 - Cost Diff. 30.5446941 117.4896591
## np1 - Effect Diff. 0.3499204 0.4456214
## np1 - Icer 156.7853582 2666.7229585
##
## * Combined result:
##
## 2 strategies run for 60 cycles.
##
## Initial state counts:
##
## PrimaryTHR = 1000L
## SuccessP = 0L
## RevisionTHR = 0L
## SuccessR = 0L
## Death = 0L
##
## Counting method: 'end'.
##
## Values:
##
## utility cost
## standard 25719.89 680492.8
## np1 25969.40 657088.9
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -23.40386 0.249513 -93.79817 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.