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 81 0
## 2 82 0
## 3 57 0
## 4 81 0
## 5 68 1
## 6 61 1
## 7 52 1
## 8 65 0
## 9 57 0
## 10 53 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 500.08967163 605.0062810 700.278258 695.5355743
## standard - Effect 13.56976193 21.9825691 25.985770 24.8940131
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 607.16692250 635.5509751 662.750240 661.3979465
## np1 - Effect 13.62743581 22.2578591 26.161422 25.1515166
## np1 - Cost Diff. -165.40882382 -99.5031416 -37.528018 -34.1376278
## np1 - Effect Diff. 0.05767389 0.1756522 0.220806 0.2575035
## np1 - Icer -354.56585682 -304.0330575 -177.278286 20.8292726
## 3rd Qu. Max.
## standard - Cost 786.6690449 878.7813785
## standard - Effect 29.0596426 31.2994814
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 687.1659033 713.3725547
## np1 - Effect 29.2683350 31.5328601
## np1 - Cost Diff. 30.5446941 107.0772509
## np1 - Effect Diff. 0.3272774 0.4665109
## np1 - Icer 156.7853582 1856.5985016
##
## * 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 24894.01 695535.6
## np1 25151.52 661397.9
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -34.13763 0.2575035 -132.5715 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 67 0 0.231
## 2 59 0 0.0732
## 3 65 1 0.265
## 4 64 0 0.0871
## 5 48 0 0.00752
## 6 63 1 0.580
## 7 48 0 0.825
## 8 63 0 0.230
## 9 83 0 0.503
## 10 48 0 0.625
## # ℹ 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.001804 0.246019 0.503252 0.500331 0.739258 0.999305
##
## Total weight: 50.03312
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 500.08967163 613.9316623 700.2782575 702.8832067
## standard - Effect 10.06345874 22.0260285 26.7297859 25.6004266
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 607.16692250 637.9767000 662.7502398 663.4252858
## np1 - Effect 10.13073146 22.2971890 27.1045630 25.8674337
## np1 - Cost Diff. -153.12466085 -118.4730359 -37.5280177 -39.4579210
## np1 - Effect Diff. 0.05767389 0.2086924 0.2358131 0.2670072
## np1 - Icer -348.43140114 -323.2659465 -177.2782857 -22.5792255
## 3rd Qu. Max.
## standard - Cost 802.5717594 861.5969314
## standard - Effect 29.0596426 31.6837747
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6817215 708.4722705
## np1 - Effect 29.2683350 31.9214350
## np1 - Cost Diff. 24.0450377 107.0772509
## np1 - Effect Diff. 0.3504991 0.4394686
## np1 - Icer 115.2176112 1856.5985016
##
## * 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 25600.43 702883.2
## np1 25867.43 663425.3
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -39.45792 0.2670072 -147.7785 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.