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 67 1
## 2 40 1
## 3 50 0
## 4 44 0
## 5 67 1
## 6 60 1
## 7 61 0
## 8 47 0
## 9 63 1
## 10 58 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_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 485852.97365 605006.2810 629699.85051 694099.0410
## standard - Effect 9322.87610 22793.0050 27376.91420 25384.5899
## standard - Δ Cost - - - -
## standard - Δ Effect - - - -
## standard - Icer - - - -
## np1 - Cost 603342.63272 635550.9751 642616.86984 660984.1287
## np1 - Effect 9380.64927 23084.8338 27765.69106 25645.0357
## np1 - Δ Cost -164881.37326 -110728.6273 13100.01886 -33114.9123
## np1 - Δ Effect 44.05769 194.8185 221.44419 260.4458
## np1 - Icer -354.32431 -316.4395 63.42149 49.3021
## 3rd Qu. Max.
## standard - Cost 802342.6777 878043.3890
## standard - Effect 29074.9005 31307.1020
## standard - Δ Cost - -
## standard - Δ Effect - -
## standard - Icer - -
## np1 - Cost 691614.0504 713162.0157
## np1 - Effect 29500.8365 31540.5654
## np1 - Δ Cost 30544.6941 117489.6591
## np1 - Δ Effect 349.9204 465.3403
## np1 - Icer 156.7854 2666.7230
##
## * 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 25384.59 694099.0
## np1 25645.04 660984.1
##
## Efficiency frontier:
##
## standard -> np1
##
## Model difference:
##
## Cost Effect ICER
## np1 -33.11491 0.2604458 -127.1471
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 58 1 0.257142175
## 2 59 1 0.233707460
## 3 37 0 0.502128315
## 4 50 1 0.413410924
## 5 78 0 0.653694508
## 6 58 0 0.848250724
## 7 39 0 0.005358921
## 8 80 1 0.142529890
## 9 70 1 0.312865614
## 10 54 0 0.951281772
## # ... 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.005359 0.224100 0.491500 0.481700 0.696400 0.961000
##
## Total weight: 48.16557
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 485852.97365 613836.4635 700765.42198 697054.7275
## standard - Effect 9322.87610 22793.0050 27376.91420 25584.0926
## standard - Δ Cost - - - -
## standard - Δ Effect - - - -
## standard - Icer - - - -
## np1 - Cost 603342.63272 637950.8204 662887.36828 661804.4659
## np1 - Effect 9380.64927 23084.8338 27765.69106 25848.0165
## np1 - Δ Cost -155938.29747 -110728.6273 -9727.98242 -35250.2617
## np1 - Δ Effect 44.05769 208.5430 221.44419 263.9238
## np1 - Icer -349.93447 -316.4395 -48.98015 183.6297
## 3rd Qu. Max.
## standard - Cost 812146.4091 865532.3779
## standard - Effect 29963.9255 31769.2206
## standard - Δ Cost - -
## standard - Δ Effect - -
## standard - Icer - -
## np1 - Cost 694400.3581 709594.0804
## np1 - Effect 30409.5470 32007.8346
## np1 - Δ Cost 24114.3568 143644.1681
## np1 - Δ Effect 364.4596 445.6214
## np1 - Icer 115.6325 13472.7451
##
## * 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 25584.09 697054.7
## np1 25848.02 661804.5
##
## Efficiency frontier:
##
## standard -> np1
##
## Model difference:
##
## Cost Effect ICER
## np1 -35.25026 0.2639238 -133.5622