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 49 1
## 2 57 0
## 3 65 1
## 4 39 0
## 5 72 0
## 6 58 1
## 7 60 1
## 8 55 0
## 9 56 1
## 10 47 0
## # ℹ 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 438.70535048 605.0062810 621.589242 683.2237991
## standard - Effect 5.05860925 24.4991251 27.780658 26.3457276
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 590.76054210 635.5509751 640.058850 657.8358957
## np1 - Effect 5.07524179 24.8264025 27.975477 26.6017928
## np1 - Cost Diff. -159.96283707 -99.5031416 18.469607 -25.3879034
## np1 - Effect Diff. 0.01159912 0.1948185 0.220806 0.2560652
## np1 - Icer -351.98058303 -304.0330575 83.646307 198.7461029
## 3rd Qu. Max.
## standard - Cost 786.6690449 8.711621e+02
## standard - Effect 29.0596426 3.152925e+01
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 687.1659033 7.111993e+02
## np1 - Effect 29.2683350 3.176519e+01
## np1 - Cost Diff. 30.5446941 1.520552e+02
## np1 - Effect Diff. 0.3272774 4.544649e-01
## np1 - Icer 156.7853582 1.310920e+04
##
## * 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 26345.73 683223.8
## np1 26601.79 657835.9
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -25.3879 0.2560652 -99.14626 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 57 1 0.0102
## 2 61 0 0.495
## 3 71 1 0.666
## 4 49 1 0.936
## 5 49 1 0.387
## 6 79 1 0.233
## 7 65 0 0.895
## 8 61 1 0.686
## 9 55 0 0.701
## 10 60 1 0.533
## # ℹ 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.003172 0.251257 0.541292 0.510826 0.753942 0.992491
##
## Total weight: 51.08255
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 500.08967163 605.0062810 684.5319673 694.8918701
## standard - Effect 10.06345874 24.4991251 25.9857701 25.5972990
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 607.16692250 635.5509751 658.3345507 661.1555528
## np1 - Effect 10.13073146 24.8264025 26.1614223 25.8570922
## np1 - Cost Diff. -159.96283707 -99.5031416 -12.4380622 -33.7363174
## np1 - Effect Diff. 0.05767389 0.1948185 0.2324224 0.2597931
## np1 - Icer -351.98058303 -304.0330575 -90.1547672 -15.5133867
## 3rd Qu. Max.
## standard - Cost 786.6690449 871.1621236
## standard - Effect 28.5543952 31.6837747
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 687.1659033 711.1992865
## np1 - Effect 28.9688773 31.9214350
## np1 - Cost Diff. 30.5446941 107.0772509
## np1 - Effect Diff. 0.3272774 0.4544649
## 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 25597.30 694891.9
## np1 25857.09 661155.6
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -33.73632 0.2597931 -129.8584 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.