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

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

# S3 method for 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 usefull 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 automatillcally 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 + markov_cycle ), 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) ) ndt2 <- update(res, newdata = new_tab2)
#> Updating strategy 'I'...
#> Updating strategy 'II'...
summary(ndt2)
#> An analysis re-run on 6 parameter sets. #> #> * Weigths distribution: #> #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.01953 0.16782 0.31989 0.35622 0.46751 0.84416 #> #> Total weight: 2.137309 #> #> * Values distribution: #> #> Min. 1st Qu. Median Mean #> II - Cost 24622.032937 25095.199985 25890.720452 25580.831389 #> II - Effect 4.332100 4.364122 4.417958 4.396986 #> II - Cost Diff. - - - - #> II - Effect Diff. - - - - #> II - Icer - - - - #> I - Cost 5533.254653 5551.137584 5581.203579 5569.491595 #> I - Effect 6.025414 6.089456 6.197128 6.155185 #> I - Cost Diff. -21705.360572 -20951.480377 -20309.516874 -20011.339794 #> I - Effect Diff. 1.693313 1.725335 1.779171 1.758199 #> I - Icer -11561.740443 -11484.257702 -11414.894343 -11378.357105 #> 3rd Qu. Max. #> II - Cost 26557.899395 27341.390963 #> II - Effect 4.463108 4.516131 #> II - Cost Diff. - - #> II - Effect Diff. - - #> II - Icer - - #> I - Cost 5606.419018 5636.030391 #> I - Effect 6.287430 6.393474 #> I - Cost Diff. -19544.062401 -19088.778285 #> I - Effect Diff. 1.824322 1.877344 #> I - Icer -11327.543060 -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 5569.492 6.155185 #> II 25580.831 4.396986 #> #> Efficiency frontier: #> #> I #> #> Differences: #> #> Cost Diff. Effect Diff. ICER Ref. #> I -20011.34 1.758199 -11381.72 II