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 1
## 2 49 0
## 3 58 1
## 4 57 0
## 5 57 0
## 6 36 1
## 7 59 1
## 8 68 0
## 9 37 1
## 10 44 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.
<- update(res_mod, newdata = tab_indiv) res_h
## 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 450.15881156 613.8364635 630.7010960 708.86267
## standard - Effect 6.14259603 25.5696426 27.7806580 26.40016
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 593.80297968 637.9508204 643.0316939 665.14785
## np1 - Effect 6.16727815 25.9195630 27.9754765 26.68093
## np1 - Cost Diff. -164.88137326 -129.4829089 12.0052043 -43.71482
## np1 - Effect Diff. 0.01752913 0.2051119 0.2334634 0.28077
## np1 - Icer -354.32431375 -333.0519971 51.0908895 110.87071
## 3rd Qu. Max.
## standard - Cost 828.5434528 878.0433890
## standard - Effect 29.9639255 31.5986556
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 699.0605439 713.1620157
## np1 - Effect 30.4095470 31.8353665
## np1 - Cost Diff. 24.1143568 143.6441681
## np1 - Effect Diff. 0.3887769 0.4653403
## 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: 'beginning'.
##
## Values:
##
## utility cost
## standard 26400.16 708862.7
## np1 26680.93 665147.9
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -43.71482 0.28077 -155.6962 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 50 0 0.932
## 2 67 0 0.614
## 3 38 1 0.0936
## 4 59 0 0.997
## 5 55 1 0.942
## 6 52 0 0.429
## 7 56 0 0.668
## 8 56 0 0.172
## 9 53 1 0.688
## 10 67 0 0.0997
## # … with 90 more rows
<- update(res_mod, newdata = tab_indiv_w) res_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.007711 0.242769 0.476103 0.474216 0.688973 0.996561
##
## Total weight: 47.42156
##
## * Values distribution:
##
## Min. 1st Qu. Median Mean
## standard - Cost 530.94590166 613.8364635 629.9316751 697.745811
## standard - Effect 9.32287610 22.7930050 27.7806580 26.098403
## standard - Cost Diff. - - - -
## standard - Effect Diff. - - - -
## standard - Icer - - - -
## np1 - Cost 615.48340627 637.9508204 642.7469056 661.961767
## np1 - Effect 9.38064927 23.0848338 27.9754765 26.365491
## np1 - Cost Diff. -164.88137326 -129.4829089 12.8826060 -35.784043
## np1 - Effect Diff. 0.05777317 0.1948185 0.2214442 0.267088
## np1 - Icer -354.32431375 -333.0519971 59.0362948 -5.828349
## 3rd Qu. Max.
## standard - Cost 828.5434528 878.0433890
## standard - Effect 29.9639255 31.5986556
## standard - Cost Diff. - -
## standard - Effect Diff. - -
## standard - Icer - -
## np1 - Cost 699.0605439 713.1620157
## np1 - Effect 30.4095470 31.8353665
## np1 - Cost Diff. 24.1143568 84.5375046
## np1 - Effect Diff. 0.3887769 0.4653403
## np1 - Icer 115.6325465 1275.2350079
##
## * Combined result:
##
## 2 strategies run for 60 cycles.
##
## Initial state counts:
##
## PrimaryTHR = 1000L
## SuccessP = 0L
## RevisionTHR = 0L
## SuccessR = 0L
## Death = 0L
##
## Counting method: 'beginning'.
##
## Values:
##
## utility cost
## standard 26098.40 697745.8
## np1 26365.49 661961.8
##
## Efficiency frontier:
##
## np1
##
## Differences:
##
## Cost Diff. Effect Diff. ICER Ref.
## np1 -35.78404 0.267088 -133.9785 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.