Skip to contents

Bins simulated data using the same cutpoints er_vpc_add_observed() already computed, and summarizes it (mean + a percentile interval across replicates, plus simulated percentile bands for a continuous/count response).

Usage

er_vpc_add_simulated(
  object,
  model = NULL,
  sim = NULL,
  nsim = 100,
  seed = NULL,
  style = er_style_vpc_simulated_mean_errorbar,
  simulate_args = list(),
  ...
)

Arguments

object

Partially constructed VPC (has S3 class er_vpc), which must already have an observed layer (see er_vpc_add_observed()).

model

A fitted model implementing er_simulate() with sim_resp. Mutually exclusive with sim.

sim

Simulated data with matching exposure/response/plot_by columns and sim_id. Mutually exclusive with model.

nsim

Number of simulation replicates, only used with model.

seed

Optional RNG seed, only used with model.

style

A function determining how the simulated layer is drawn; see er_style_vpc_simulated().

simulate_args

A named list of additional arguments forwarded to er_simulate(), only used with model. Distinct from ... the same way er_plot_add_model()'s predict_args is distinct from its own ... – see that function's "Details" for the rationale.

...

Additional named arguments forwarded to style.

Value

object, with object$layer$simulated populated.

Details

sim and model are mutually exclusive; supply exactly one. model is preferred when it implements er_simulate() with sim_resp, since a VPC needs response-level simulated observations rather than only mean predictions – this function errors informatively if sim_resp isn't available.

conf_level/probs are set once on er_vpc() itself (rather than here), so the observed and simulated layers always agree on them.