Heterogeneity & Demographic Analysis

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    66     1
##  2    58     1
##  3    70     1
##  4    53     0
##  5    71     0
##  6    67     0
##  7    70     0
##  8    72     0
##  9    62     0
## 10    55     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          438.70535048  605.0062810 633.769097 687.1845122
## standard - Effect          5.05860925   21.9825691  26.357778  25.0011339
## standard - Cost Diff.               -            -          -           -
## standard - Effect Diff.             -            -          -           -
## standard - Icer                     -            -          -           -
## np1 - Cost               590.76054210  635.5509751 643.747357 659.0359888
## np1 - Effect               5.07524179   22.2578591  26.632993  25.2536944
## np1 - Cost Diff.        -165.40882382  -99.5031416   9.978261 -28.1485234
## np1 - Effect Diff.         0.01159912    0.1756522   0.220806   0.2525605
## np1 - Icer              -354.56585682 -304.0330575  57.461391 372.2290911
##                             3rd Qu.         Max.
## standard - Cost         786.6690449 8.787814e+02
## standard - Effect        29.0596426 3.152925e+01
## standard - Cost Diff.             -            -
## standard - Effect Diff.           -            -
## standard - Icer                   -            -
## np1 - Cost              687.1659033 7.133726e+02
## np1 - Effect             29.2683350 3.176519e+01
## np1 - Cost Diff.         30.5446941 1.520552e+02
## np1 - Effect Diff.        0.3272774 4.665109e-01
## np1 - Icer              156.7853582 1.310920e+04
## 
## * 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 25001.13 687184.5
## np1      25253.69 659036.0
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -28.14852    0.2525605 -111.4526 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    53     1   0.349 
##  2    73     0   0.568 
##  3    68     0   0.300 
##  4    60     1   0.578 
##  5    52     1   0.592 
##  6    76     0   0.584 
##  7    53     0   0.805 
##  8    40     1   0.677 
##  9    61     1   0.0746
## 10    56     1   0.486 
## # ℹ 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.02548 0.29179 0.47368 0.49498 0.73593 0.99836 
## 
## Total weight: 49.49808
## 
## * Values distribution:
## 
##                                 Min.      1st Qu.     Median        Mean
## standard - Cost          543.4622561  605.0062810 630.994108 693.6883416
## standard - Effect         14.7166852   24.4991251  26.729786  26.3925562
## standard - Cost Diff.              -            -          -           -
## standard - Effect Diff.            -            -          -           -
## standard - Icer                    -            -          -           -
## np1 - Cost               618.8657194  635.5509751 642.617274 660.7639175
## np1 - Effect              14.8551230   24.8264025  27.104563  26.6553320
## np1 - Cost Diff.        -168.1391878  -99.5031416  11.623166 -32.9244240
## np1 - Effect Diff.         0.1076059    0.1948185   0.220806   0.2627758
## np1 - Icer              -355.7870417 -304.0330575  60.195636 -46.7739449
##                             3rd Qu.        Max.
## standard - Cost         786.6690449 882.6017906
## standard - Effect        29.0596426  31.5292548
## standard - Cost Diff.             -           -
## standard - Effect Diff.           -           -
## standard - Icer                   -           -
## np1 - Cost              687.1659033 714.4626028
## np1 - Effect             29.2683350  31.7651919
## np1 - Cost Diff.         30.5446941  75.4034633
## np1 - Effect Diff.        0.3272774   0.4725838
## np1 - Icer              156.7853582 700.7370158
## 
## * 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 26392.56 693688.3
## np1      26655.33 660763.9
## 
## Efficiency frontier:
## 
## np1
## 
## Differences:
## 
##     Cost Diff. Effect Diff.      ICER     Ref.
## np1  -32.92442    0.2627758 -125.2947 standard

Parallel computing

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

  • Define a cluster with the use_cluster() functions (i.e. use_cluster(4) to use 4 cores).
  • Run the analysis as usual.
  • To stop using parallel computing use the close_cluster() function.

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