Skip to contents

Given a table of new parameter values with a new parameter set per line, runs iteratively Markov models over these sets.

Usage

# S3 method for class 'run_model'
update(object, newdata, ...)

# S3 method for class 'updated_model'
plot(
  x,
  type = c("simple", "difference", "counts", "ce", "values"),
  result = c("cost", "effect", "icer"),
  strategy = NULL,
  ...
)

Arguments

object

The result of run_model().

newdata

A data.frame of new parameter sets, one column per parameter and one row per parameter set. An optional .weights column can be included for a weighted analysis.

...

Additional arguments passed to geom_histogram. Especially useful to specify binwidth.

x

Updated model to plot.

type

Plot simple values or differences?

result

The the result to plot (see details).

strategy

A model index, character or numeric.

Value

A data.frame with one row per model/value.

Details

newdata must be a data.frame with the following properties: the column names must be parameter names used in define_parameters(); and an optional column .weights can give the respective weight of each row in the target population.

Weights are automatically scaled. If no weights are provided equal weights are used for each strata.

For the plotting function, the type argument can take the following values: "cost", "effect" or "icer" to plot the heterogeneity of the respective values. Furthermore "ce" and "count" can produce from the combined model plots similar to those of run_model().

Warning

Histograms do not account for weights. On the other hand summary results do.

Examples

mod1 <-
  define_strategy(
    transition = define_transition(
      .5, .5,
      .1, .9
    ),
    define_state(
      cost = 543 + age * 5,
      ly = 1
    ),
    define_state(
      cost = 432 + age,
      ly = 1 * age / 100
    )
  )
#> No named state -> generating names.
#> No named state -> generating names.

mod2 <-
  define_strategy(
    transition = define_transition(
      .5, .5,
      .1, .9
    ),
    define_state(
      cost = 789 * age / 10,
      ly = 1
    ),
    define_state(
      cost = 456 * age / 10,
      ly = 1 * age / 200
    )
  )
#> No named state -> generating names.
#> No named state -> generating names.

res <- run_model(
  mod1, mod2,
  parameters = define_parameters(
    age_init = 60,
    age = age_init + model_time
  ),
  init = 1:0,
  cycles = 10,
  cost = cost,
  effect = ly
)
#> No named model -> generating names.

# generating table with new parameter sets
new_tab <- data.frame(
  age_init = 40:45
)

# with run_model result
ndt <- update(res, newdata = new_tab)
#> No weights specified in update, using equal weights.
#> Updating strategy 'I'...
#> Updating strategy 'II'...

summary(ndt)
#> An analysis re-run on 6 parameter sets.
#> 
#> * Unweighted analysis.
#> 
#> * Values distribution:
#> 
#>                            Min.       1st Qu.        Median          Mean
#> II - Cost          24622.032937  25301.872444  25981.711950  25981.711950
#> II - Effect            4.332100      4.378108      4.424115      4.424115
#> II - Cost Diff.               -             -             -             -
#> II - Effect Diff.             -             -             -             -
#> II - Icer                     -             -             -             -
#> I - Cost            5533.254653   5558.948587   5584.642522   5584.642522
#> I - Effect             6.025414      6.117429      6.209444      6.209444
#> I - Cost Diff.    -21705.360572 -21051.215000 -20397.069428 -20397.069428
#> I - Effect Diff.       1.693313      1.739321      1.785329      1.785329
#> I - Icer          -11561.740443 -11494.795100 -11424.530031 -11421.356676
#>                         3rd Qu.          Max.
#> II - Cost          26661.551457  27341.390963
#> II - Effect            4.470123      4.516131
#> II - Cost Diff.               -             -
#> II - Effect Diff.             -             -
#> II - Icer                     -             -
#> I - Cost            5610.336457   5636.030391
#> I - Effect             6.301459      6.393474
#> I - Cost Diff.    -19742.923856 -19088.778285
#> I - Effect Diff.       1.831336      1.877344
#> I - Icer          -11350.699496 -11273.033445
#> 
#> * Combined result:
#> 
#> 2 strategies run for 10 cycles.
#> 
#> Initial state counts:
#> 
#> A = 1L
#> B = 0L
#> 
#> Counting method: 'life-table'.
#> 
#>  
#> 
#> Counting method: 'beginning'.
#> 
#>  
#> 
#> Counting method: 'end'.
#> 
#> Values:
#> 
#>         cost       ly
#> I   5584.643 6.209444
#> II 25981.712 4.424115
#> 
#> Efficiency frontier:
#> 
#> I
#> 
#> Differences:
#> 
#>   Cost Diff. Effect Diff.      ICER Ref.
#> I  -20397.07     1.785329 -11424.83   II

# using weights

new_tab2 <- data.frame(
  age_init = 40:45,
  .weights = runif(6)
)

#'\dontrun{
#'ndt2 <- update(res, newdata = new_tab2)
#'
#'summary(ndt2)
#'}