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:
tab_indiv
## # A tibble: 100 × 2
## age sex
## <dbl> <int>
## 1 57 0
## 2 64 0
## 3 60 1
## 4 67 0
## 5 60 1
## 6 59 1
## 7 72 1
## 8 67 1
## 9 53 1
## 10 40 0
## # ... with 90 more rows
library(ggplot2)
ggplot(tab_indiv, aes(x = age)) +
geom_histogram(binwidth = 2)
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.
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 530945.90166 605006.2810 629931.67506 697311.53897
## standard - Effect 9322.87610 24875.4832 27376.91420 25884.63272
## standard - Δ Cost - - - -
## standard - Δ Effect - - - -
## standard - Icer - - - -
## np1 - Cost 615483.40627 635550.9751 642889.29978 661844.51663
## np1 - Effect 9380.64927 25143.6592 27765.69106 26149.47135
## np1 - Δ Cost -164881.37326 -129482.9089 12917.01934 -35467.02234
## np1 - Δ Effect 57.77317 194.8185 221.44419 264.83863
## np1 - Icer -354.32431 -333.0520 58.98272 -14.04167
## 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 84537.5046
## np1 - Δ Effect 388.7769 465.3403
## np1 - Icer 156.7854 1275.2350
##
## * Combined result:
##
## 2 strategies run for 60 cycles.
##
## Initial state counts:
##
## N
## PrimaryTHR 1000
## SuccessP 0
## RevisionTHR 0
## SuccessR 0
## Death 0
##
## Counting method: 'end'.
##
## utility cost
## standard 25884.63 697311.5
## np1 26149.47 661844.5
##
## Efficiency frontier:
##
## standard -> np1
##
## Model difference:
##
## Cost Effect ICER
## np1 -35.46702 0.2648386 -133.9194
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_model()
.
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 63 1 0.26106990
## 2 63 0 0.02011410
## 3 64 0 0.65787614
## 4 81 0 0.65259655
## 5 73 1 0.51075826
## 6 50 1 0.63915094
## 7 60 0 0.38027776
## 8 38 0 0.38838420
## 9 58 1 0.21805770
## 10 85 1 0.02083434
## # ... 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.004782 0.246200 0.457500 0.479000 0.720600 0.986400
##
## Total weight: 47.89952
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 485852.97365 605006.2810 629931.67506 689962.2074
## standard - Effect 11784.33667 22793.0050 27376.91420 25471.6095
## standard - Δ Cost - - - -
## standard - Δ Effect - - - -
## standard - Icer - - - -
## np1 - Cost 603342.63272 635550.9751 642874.99205 659797.9678
## np1 - Effect 11828.39436 23084.8338 27765.69106 25728.8255
## np1 - Δ Cost -146895.67206 -110728.6273 13752.59815 -30164.2396
## np1 - Δ Effect 44.05769 194.8185 221.44419 257.2160
## np1 - Icer -344.87737 -316.4395 71.81771 490.1787
## 3rd Qu. Max.
## standard - Cost 806918.3855 875515.5476
## standard - Effect 29074.9005 31532.9044
## standard - Δ Cost - -
## standard - Δ Effect - -
## standard - Icer - -
## np1 - Cost 692914.5073 712441.3735
## np1 - Effect 29500.8365 31782.8994
## np1 - Δ Cost 30544.6941 161822.7443
## np1 - Δ Effect 356.7063 461.3809
## np1 - Icer 156.7854 25562.3627
##
## * Combined result:
##
## 2 strategies run for 60 cycles.
##
## Initial state counts:
##
## N
## PrimaryTHR 1000
## SuccessP 0
## RevisionTHR 0
## SuccessR 0
## Death 0
##
## Counting method: 'end'.
##
## utility cost
## standard 25471.61 689962.2
## np1 25728.83 659798.0
##
## Efficiency frontier:
##
## standard -> np1
##
## Model difference:
##
## Cost Effect ICER
## np1 -30.16424 0.257216 -117.272