The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Heterogeneity & Demographic Analysis

2024-09-11

Introduction

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 different 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").

Population characteristics

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    63     1
##  2    53     1
##  3    65     1
##  4    69     0
##  5    53     0
##  6    73     1
##  7    70     1
##  8    58     0
##  9    55     1
## 10    44     0
## # ℹ 90 more rows
library(ggplot2)
ggplot(tab_indiv, aes(x = age)) +
  geom_histogram(binwidth = 2)

Running the analysis

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'...

Interpreting results

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          543.46225608  613.9316623  700.2782575 708.7969316
## standard - Effect         10.06345874   21.9825691   27.7806580  26.0330535
## standard - Cost Diff.               -            -            -           -
## standard - Effect Diff.             -            -            -           -
## standard - Icer                     -            -            -           -
## np1 - Cost               618.86571941  637.9767000  662.7502398 665.0658758
## np1 - Effect              10.13073146   22.2578591   27.9754765  26.3069512
## np1 - Cost Diff.        -163.38052116 -122.7948420  -37.5280177 -43.7310558
## np1 - Effect Diff.         0.06727271    0.2086924    0.2333787   0.2738977
## np1 - Icer              -353.62679735 -327.6476693 -177.2782857 -75.8597661
##                             3rd Qu.       Max.
## standard - Cost         819.1977737 875.943516
## standard - Effect        29.0596426  31.299481
## standard - Cost Diff.             -          -
## standard - Effect Diff.           -          -
## standard - Icer                   -          -
## np1 - Cost              696.4029317 712.562995
## np1 - Effect             29.2683350  31.532860
## np1 - Cost Diff.         24.0450377  75.403463
## np1 - Effect Diff.        0.3747771   0.462014
## np1 - Icer              115.2176112 956.915671
## 
## * 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 26033.05 708796.9
## np1      26306.95 665065.9
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.     ICER     Ref.
## np1  -43.73106    0.2738977 -159.662 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")

Weighted results

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    71     1   0.994 
##  2    50     1   0.488 
##  3    52     1   0.0449
##  4    60     0   0.110 
##  5    62     1   0.964 
##  6    76     1   0.603 
##  7    47     1   0.155 
##  8    69     0   0.467 
##  9    59     0   0.0459
## 10    60     1   0.767 
## # ℹ 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.
## 
## * Weights distribution:
## 
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.007939 0.258975 0.511461 0.518416 0.760677 0.997668 
## 
## Total weight: 51.84163
## 
## * Values distribution:
## 
##                                  Min.      1st Qu.      Median        Mean
## standard - Cost          470.23578695  605.0062810 626.3537753 673.5474236
## standard - Effect          5.05860925   21.9825691  25.9857701  24.7274433
## standard - Cost Diff.               -            -           -           -
## standard - Effect Diff.             -            -           -           -
## standard - Icer                     -            -           -           -
## np1 - Cost               599.19333183  635.5509751 641.3547975 655.1643896
## np1 - Effect               5.07524179   22.2578591  26.1614223  24.9651888
## np1 - Cost Diff.        -165.40882382  -99.5031416  15.0010223 -18.3830340
## np1 - Effect Diff.         0.01663254    0.1756522   0.2116899   0.2377455
## np1 - Icer              -354.56585682 -304.0330575  65.6679900 151.1504992
##                             3rd Qu.         Max.
## standard - Cost         766.7567169  878.7813785
## standard - Effect        29.0596426   31.2994814
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              681.5262323  713.3725547
## np1 - Effect             29.2683350   31.5328601
## np1 - Cost Diff.         30.5446941  128.9575449
## np1 - Effect Diff.        0.2995574    0.4665109
## np1 - Icer              156.7853582 7753.3265967
## 
## * 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 24727.44 673547.4
## np1      24965.19 655164.4
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -18.38303    0.2377455 -77.32231 standard

Parallel computing

Updating can be significantly sped up by using parallel computing. This can be done in the following way:

Results may vary depending on the machine, but we found speed gains to be quite limited beyond 4 cores.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.