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 87 0
## 2 60 1
## 3 52 1
## 4 65 1
## 5 65 0
## 6 65 1
## 7 34 0
## 8 79 0
## 9 32 1
## 10 67 1
## # … 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 450.15881156 613.836464 761.4317051 721.6313517
## standard - Effect 7.47256790 25.569643 27.3769142 26.1326792
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 593.80297968 637.950820 680.0145801 668.7386332
## np1 - Effect 7.49009703 25.829934 27.7656911 26.4202297
## np1 - Cost Diff. -167.83433856 -129.482909 -81.4171250 -52.8927186
## np1 - Effect Diff. 0.01752913 0.208543 0.2918287 0.2875505
## np1 - Icer -355.65308588 -333.051997 -278.9894047 -5.9314266
## 3rd Qu. Max.
## standard - Cost 828.5434528 882.1752204
## standard - Effect 29.0749005 31.7692206
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 699.0605439 714.3408818
## np1 - Effect 29.5008365 32.0078346
## np1 - Cost Diff. 24.1143568 143.6441681
## np1 - Effect Diff. 0.3887769 0.4719046
## np1 - Icer 115.6325465 8194.5991768
##
## * 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 26132.68 721631.4
## np1 26420.23 668738.6
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -52.89272 0.2875505 -183.9424 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 56 0 0.723
## 2 60 0 0.622
## 3 62 0 0.980
## 4 54 1 0.934
## 5 61 1 0.135
## 6 69 0 0.198
## 7 51 1 0.321
## 8 50 0 0.435
## 9 73 1 0.216
## 10 54 0 0.399
## # … 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.01442 0.24555 0.44433 0.48456 0.72400 0.99424
##
## Total weight: 48.4558
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 426.799283002 605.0062810 628.9121661 703.5302567
## standard - Effect 2.546855139 25.6294657 27.3769142 26.4760642
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 587.614226251 635.5509751 642.0508188 663.6040782
## np1 - Effect 2.551285038 25.8299343 27.7656911 26.7509535
## np1 - Cost Diff. -164.881373261 -129.4829089 13.0247725 -39.9261785
## np1 - Effect Diff. 0.004429899 0.1948185 0.2294328 0.2748893
## np1 - Icer -354.324313745 -333.0519971 58.3249840 271.4961764
## 3rd Qu. Max.
## standard - Cost 828.5434528 878.0433890
## standard - Effect 29.0749005 31.3071020
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 699.0605439 713.1620157
## np1 - Effect 29.5008365 31.5405654
## np1 - Cost Diff. 30.5446941 160.8149432
## np1 - Effect Diff. 0.3887769 0.4653403
## np1 - Icer 156.7853582 36302.1702601
##
## * 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 26476.06 703530.3
## np1 26750.95 663604.1
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -39.92618 0.2748893 -145.2446 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.