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 (seeer_vpc_add_observed()).- model
A fitted model implementing
er_simulate()withsim_resp. Mutually exclusive withsim.- sim
Simulated data with matching exposure/response/
plot_bycolumns andsim_id. Mutually exclusive withmodel.- 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 withmodel. Distinct from...the same wayer_plot_add_model()'spredict_argsis distinct from its own...– see that function's "Details" for the rationale.- ...
Additional named arguments forwarded to
style.
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.