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 55 0
## 2 65 1
## 3 53 0
## 4 64 1
## 5 57 1
## 6 77 1
## 7 56 0
## 8 57 0
## 9 59 1
## 10 64 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 691.940773
## standard - Effect 9.32287610 22.7930050 27.3769142 25.532387
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 603.34263272 635.5509751 641.5229814 660.356719
## np1 - Effect 9.38064927 23.0848338 27.7656911 25.791088
## np1 - Cost Diff. -164.88137326 -110.7286273 14.5509685 -31.584054
## np1 - Effect Diff. 0.04405769 0.1948185 0.2122929 0.258701
## np1 - Icer -354.32431375 -316.4394659 72.7555976 32.400386
## 3rd Qu. Max.
## standard - Cost 802.3426777 878.0433890
## standard - Effect 29.0459530 30.9442824
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6140504 713.1620157
## np1 - Effect 29.2544960 31.3132009
## np1 - Cost Diff. 30.5446941 117.4896591
## np1 - Effect Diff. 0.3499204 0.4653403
## 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: 'beginning'.
##
## Values:
##
## utility cost
## standard 25532.39 691940.8
## np1 25791.09 660356.7
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -31.58405 0.258701 -122.0871 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 49 0 0.882
## 2 66 1 0.883
## 3 75 1 0.911
## 4 67 1 0.743
## 5 55 1 0.0765
## 6 62 1 0.126
## 7 70 0 0.876
## 8 62 1 0.0933
## 9 67 1 0.901
## 10 51 0 0.370
## # … 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.0215 0.2020 0.4698 0.4825 0.7760 0.9944
##
## Total weight: 48.24692
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 530.94590166 613.836464 638.6710815 708.0011537
## standard - Effect 14.30828698 23.480103 27.7806580 26.5960181
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 615.48340627 637.950820 650.7357177 664.8192812
## np1 - Effect 14.43982318 23.413651 27.9754765 26.8729584
## np1 - Cost Diff. -160.47985885 -129.482909 -12.4092934 -43.1818725
## np1 - Effect Diff. 0.09203743 0.208543 0.2294328 0.2769403
## np1 - Icer -352.23489020 -333.051997 -61.2926562 -73.2504402
## 3rd Qu. Max.
## standard - Cost 828.5434528 871.8854128
## standard - Effect 29.9639255 31.5986556
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 699.0605439 711.4055539
## np1 - Effect 30.4095470 31.8353665
## np1 - Cost Diff. 24.1143568 84.5375046
## np1 - Effect Diff. 0.3887769 0.4556047
## np1 - Icer 115.6325465 918.5122572
##
## * 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 26596.02 708001.2
## np1 26872.96 664819.3
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -43.18187 0.2769403 -155.9248 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.