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
:
tab_indiv
## # A tibble: 100 × 2
## age sex
## <dbl> <int>
## 1 48 0
## 2 41 0
## 3 60 0
## 4 43 1
## 5 68 0
## 6 45 1
## 7 51 0
## 8 58 0
## 9 52 0
## 10 45 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 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.
summary(res_h)
## An analysis re-run on 100 parameter sets.
##
## * Unweighted analysis.
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 530.94590166 605.0062810 621.9893893 690.819781
## standard - Effect 14.30828698 25.5696426 27.7806580 27.036103
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 615.48340627 635.5509751 640.1676766 659.957450
## np1 - Effect 14.43982318 25.8971558 27.9754765 27.302218
## np1 - Cost Diff. -167.83433856 -110.7286273 18.1782873 -30.862331
## np1 - Effect Diff. 0.09203743 0.1948185 0.2214442 0.266115
## np1 - Icer -355.65308588 -316.4394659 82.0897023 -13.482389
## 3rd Qu. Max.
## standard - Cost 802.3426777 882.1752204
## standard - Effect 29.0749005 31.3071020
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6140504 714.3408818
## np1 - Effect 29.5008365 31.6126413
## np1 - Cost Diff. 30.5446941 84.5375046
## np1 - Effect Diff. 0.3499204 0.4719046
## np1 - Icer 156.7853582 918.5122572
##
## * 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'.
##
## Values:
##
## utility cost
## standard 27036.10 690819.8
## np1 27302.22 659957.4
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -30.86233 0.266115 -115.9737 standard
The variation of cost or effect can then be plotted.
plot(res_h, result = "effect", binwidth = 5)
plot(res_h, result = "cost", binwidth = 50)
plot(res_h, result = "icer", type = "difference",
binwidth = 500)
plot(res_h, result = "effect", type = "difference",
binwidth = .1)
plot(res_h, result = "cost", type = "difference",
binwidth = 30)
The results from the combined model can be plotted similarly to the results from run_model()
.
plot(res_h, type = "counts")
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 66 0 0.55272818
## 2 61 1 0.40775074
## 3 75 1 0.76490015
## 4 47 0 0.06054413
## 5 59 1 0.51861366
## 6 55 0 0.57235881
## 7 49 1 0.42416105
## 8 39 0 0.93200582
## 9 63 0 0.47428143
## 10 50 1 0.10827813
## # ... with 90 more rows
res_w <- update(res_mod, newdata = tab_indiv_w)
## Updating strategy 'standard'...
## Updating strategy 'np1'...
res_w
## An analysis re-run on 100 parameter sets.
##
## * Weigths distribution:
##
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.005555 0.393600 0.567400 0.561800 0.794400 0.981100
##
## Total weight: 56.17992
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 530.94590166 605.0062810 629.7415598 695.4517627
## standard - Effect 17.56922957 25.5696426 27.3769142 26.2696949
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 615.48340627 635.5509751 642.5234906 661.3131936
## np1 - Effect 17.66126700 25.8299343 27.7656911 26.5352387
## np1 - Cost Diff. -155.93829747 -110.7286273 13.9560193 -34.1385691
## np1 - Effect Diff. 0.09203743 0.1948185 0.2261571 0.2655438
## np1 - Icer -349.93447295 -316.4394659 74.4349668 -13.4798285
## 3rd Qu. Max.
## standard - Cost 802.3426777 871.8854128
## standard - Effect 29.0570960 31.7692206
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 691.6140504 711.4055539
## np1 - Effect 29.3493218 32.0078346
## np1 - Cost Diff. 30.5446941 84.5375046
## np1 - Effect Diff. 0.3499204 0.4556047
## np1 - Icer 156.7853582 918.5122572
##
## * 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'.
##
## Values:
##
## utility cost
## standard 26269.69 695451.8
## np1 26535.24 661313.2
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -34.13857 0.2655438 -128.561 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.