Computes incremental effect for all treatment strategies on outcome variables from a probabilistic sensitivity analysis relative to a comparator.

incr_effect(x, comparator, sample, strategy, grp = NULL, outcomes)

Arguments

x

A data.frame or data.table containing simulation output with information on outcome variables for each randomly sampled parameter set from a PSA. Each row should denote a randomly sampled parameter set and treatment strategy.

comparator

The comparator strategy. If the strategy column is a character variable, then must be a character; if the strategy column is an integer variable, then must be an integer.

sample

Character name of column denoting a randomly sampled parameter set.

strategy

Character name of column denoting treatment strategy.

grp

Character name of column denoting subgroup. If NULL, then it is assumed that there is only one group.

outcomes

Name of columns to compute incremental changes for.

Value

A data.table containing the differences in the values of each variable specified in outcomes between each treatment strategy and the comparator.

Examples

# simulation output
n_samples <- 100
sim <- data.frame(sample = rep(seq(n_samples), 4),
             c = c(rlnorm(n_samples, 5, .1), rlnorm(n_samples, 5, .1),
                    rlnorm(n_samples, 11, .1), rlnorm(n_samples, 11, .1)),
             e = c(rnorm(n_samples, 8, .2), rnorm(n_samples, 8.5, .1),
                   rnorm(n_samples, 11, .6), rnorm(n_samples, 11.5, .6)),
             strategy = rep(paste0("Strategy ", seq(1, 2)),
                           each = n_samples * 2),
             grp = rep(rep(c("Group 1", "Group 2"),
                           each = n_samples), 2)
)
# calculate incremental effect of Strategy 2 relative to Strategy 1 by group
ie <- incr_effect(sim, comparator = "Strategy 1", sample = "sample",
                        strategy = "strategy", grp = "grp", outcomes = c("c", "e"))
head(ie)
#>    sample   strategy     grp       ic       ie
#>     <int>     <char>  <char>    <num>    <num>
#> 1:      1 Strategy 2 Group 1 65827.82 2.516667
#> 2:      1 Strategy 2 Group 2 58907.17 2.247874
#> 3:      2 Strategy 2 Group 1 57389.52 2.139747
#> 4:      2 Strategy 2 Group 2 63251.77 2.711067
#> 5:      3 Strategy 2 Group 1 68718.28 3.708635
#> 6:      3 Strategy 2 Group 2 59492.99 2.150093