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 53 0
## 2 54 0
## 3 58 0
## 4 67 1
## 5 62 0
## 6 53 0
## 7 57 0
## 8 43 1
## 9 57 1
## 10 54 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 621.9893893 683.020235
## standard - Effect 9.32287610 22.7930050 27.3769142 25.793407
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 603.34263272 635.5509751 640.1676766 657.809481
## np1 - Effect 9.38064927 23.0848338 27.7656911 26.045903
## np1 - Cost Diff. -164.88137326 -110.7286273 18.1782873 -25.210754
## np1 - Effect Diff. 0.04405769 0.1948185 0.2214442 0.252496
## np1 - Icer -354.32431375 -316.4394659 82.0897023 52.050519
## 3rd Qu. Max.
## standard - Cost 802.3426777 878.0433890
## standard - Effect 29.0749005 31.3071020
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6140504 713.1620157
## np1 - Effect 29.5008365 31.5405654
## 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 25793.41 683020.2
## np1 26045.90 657809.5
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -25.21075 0.252496 -99.84616 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 65 1 0.340
## 2 58 0 0.361
## 3 71 0 0.124
## 4 54 0 0.592
## 5 61 1 0.214
## 6 66 1 0.0579
## 7 66 1 0.478
## 8 54 0 0.879
## 9 56 1 0.527
## 10 58 0 0.526
## # … 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.01272 0.28239 0.50943 0.51475 0.78662 0.98334
##
## Total weight: 51.47463
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 425.423548617 621.989389 629.9316751 695.1304320
## standard - Effect 4.554755990 22.793005 27.3769142 25.8265292
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 587.246292893 640.167677 643.0316939 661.1863552
## np1 - Effect 4.561086498 23.084834 27.7656911 26.0873039
## np1 - Cost Diff. -164.881373261 -110.728627 13.1000189 -33.9440768
## np1 - Effect Diff. 0.006330508 0.208543 0.2276855 0.2607747
## np1 - Icer -354.324313745 -316.439466 63.4214929 64.0786331
## 3rd Qu. Max.
## standard - Cost 802.3426777 878.0433890
## standard - Effect 30.2219909 31.3071020
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6140504 713.1620157
## np1 - Effect 30.4434351 31.5405654
## np1 - Cost Diff. 18.1782873 161.8227443
## np1 - Effect Diff. 0.3499204 0.4653403
## np1 - Icer 99.5924938 25562.3626587
##
## * 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 25826.53 695130.4
## np1 26087.30 661186.4
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -33.94408 0.2607747 -130.1663 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.