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("non-homogeneous", package = "heemod")
.
The characteristics of the population are input from a table, with one column per parameter and one row per individul. Those may be per 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:
tab_indiv
## # A tibble: 100 × 2
## age sex
## <dbl> <int>
## 1 68 1
## 2 53 0
## 3 69 1
## 4 51 0
## 5 58 1
## 6 56 0
## 7 62 1
## 8 62 0
## 9 56 1
## 10 59 1
## # ... with 90 more rows
library(ggplot2)
ggplot(tab_indiv, aes(x = age)) +
geom_histogram(binwidth = 2)
res_mod
, the result we obtained from run_models()
in the Time-varying Markov models vignette, can be passed to update()
to update the model woth the new data and perform the heterogeneity analysis.
res_h <- update(res_mod, newdata = tab_indiv)
## No weights specified in model update, using equal weights.
## Updating model 'standard'...
## Updating model 'np1'...
The summary()
method reports summary statistics for cost, effect and ICER, as well as the result from the combined model.
summary(res_h)
## An analysis re-run on 100 parameter sets.
##
## * Unweighted analysis.
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 485852.97365 605006.2810 629468.02596 696751.856036
## standard - Effect 11784.33667 22793.0050 27578.78609 26385.856281
## standard - Δ Cost - - - -
## standard - Δ Effect - - - -
## standard - Icer - - - -
## np1 - Cost 603342.63272 635550.9751 642202.04577 661671.304738
## np1 - Effect 11828.39436 23084.8338 27870.58379 26653.304443
## np1 - Δ Cost -164881.37326 -129482.9089 12734.01981 -35080.551298
## np1 - Δ Effect 44.05769 194.8185 229.43277 267.448162
## np1 - Icer -354.32431 -333.0520 54.54396 4.617731
## 3rd Qu. Max.
## standard - Cost 828543.4528 878043.3890
## standard - Effect 29074.9005 31598.6556
## standard - Δ Cost - -
## standard - Δ Effect - -
## standard - Icer - -
## np1 - Cost 699060.5439 713162.0157
## np1 - Effect 29500.8365 31835.3665
## np1 - Δ Cost 30544.6941 117489.6591
## np1 - Δ Effect 388.7769 465.3403
## np1 - Icer 156.7854 2666.7230
##
## * Combined result:
##
## 2 Markov models run for 60 cycles.
##
## Initial states:
##
## N
## PrimaryTHR 1000
## SuccessP 0
## RevisionTHR 0
## SuccessR 0
## Death 0
##
## Counting method: 'end'.
##
## utility cost
## standard 26385.86 696751.9
## np1 26653.30 661671.3
##
## Efficiency frontier:
##
## standard np1
##
## Model difference:
##
## Cost Effect ICER
## np1 -35.08055 0.2674482 -131.1677
The variation of the incremental differences in cost, effect or ICER can then be plotted.
plot(res_h, type = "icer", model = "np1", binwidth = 500)
plot(res_h, type = "effect", model = "np1", binwidth = 50)
plot(res_h, type = "cost", model = "np1", binwidth = 25000)
The results from the combined model can be plotted similarly to the results from run_models()
.
plot(res_h, type = "counts", model = "np1")
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.
tab_indiv_w
## # A tibble: 100 × 3
## age sex .weights
## <dbl> <int> <dbl>
## 1 64 1 0.34386349
## 2 70 1 0.98740624
## 3 63 0 0.32383772
## 4 71 1 0.04471101
## 5 55 0 0.85404708
## 6 74 0 0.98496043
## 7 56 0 0.96513131
## 8 52 0 0.11708605
## 9 68 1 0.72040239
## 10 49 1 0.38014489
## # ... with 90 more rows
res_w <- update(res_mod, newdata = tab_indiv_w)
## Updating model 'standard'...
## Updating model 'np1'...
res_w
## An analysis re-run on 100 parameter sets.
##
## * Weigths distribution:
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.01639 0.32490 0.57520 0.55100 0.81200 0.99650
##
## Total weight: 55.10398
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 451929.91015 613836.4635 633614.16232 688839.6225
## standard - Effect 7472.56790 22521.1145 25657.74359 25035.5850
## standard - Δ Cost - - - -
## standard - Δ Effect - - - -
## standard - Icer - - - -
## np1 - Cost 594291.10290 637950.8204 644063.94579 659497.1486
## np1 - Effect 7490.09703 22739.4487 25919.56300 25289.2626
## np1 - Δ Cost -160479.85885 -110728.6273 14550.96853 -29342.4739
## np1 - Δ Effect 17.52913 208.5430 221.44419 253.6775
## np1 - Icer -352.23489 -316.4395 63.42149 258.2954
## 3rd Qu. Max.
## standard - Cost 802342.6777 871885.4128
## standard - Effect 29062.6841 30944.2824
## standard - Δ Cost - -
## standard - Δ Effect - -
## standard - Icer - -
## np1 - Cost 691614.0504 711405.5539
## np1 - Effect 29396.8763 31173.7151
## np1 - Δ Cost 24114.3568 143644.1681
## np1 - Δ Effect 349.9204 455.6047
## np1 - Icer 115.6325 13472.7451
##
## * Combined result:
##
## 2 Markov models run for 60 cycles.
##
## Initial states:
##
## N
## PrimaryTHR 1000
## SuccessP 0
## RevisionTHR 0
## SuccessR 0
## Death 0
##
## Counting method: 'end'.
##
## utility cost
## standard 25035.59 688839.6
## np1 25289.26 659497.1
##
## Efficiency frontier:
##
## standard np1
##
## Model difference:
##
## Cost Effect ICER
## np1 -29.34247 0.2536775 -115.6684