Plot bootstrap parameter distributions
plot_bootstrap.RdCreates a faceted density + histogram plot showing the distribution of parameter estimates across bootstrap samples. Optionally overlays the original (fitted) parameter estimate and confidence interval lines.
Arguments
- bootstrap_results
Bootstrap results object returned by
call_pharmpy_tool(tool = "bootstrap"). Must expose aparameter_estimatesattribute (a pandas DataFrame that reticulate auto-converts to an R data.frame).- original_estimates
Named numeric vector of original parameter estimates (e.g. from
run_nlme()results) to overlay as a solid vertical line on each panel. Names must match column names ofbootstrap_results$parameter_estimates. Parameters not found are silently ignored. PassNULL(default) to suppress.- ci
Numeric confidence level for the displayed credible interval (e.g.
0.95draws the 2.5th and 97.5th percentile as dashed lines). PassNULLto suppress CI lines.- parameters
Character vector of parameter names to include.
NULL(default) includes all parameters.
Value
A ggplot2::ggplot() object. Use ggplot2::ggsave() to save it.
Examples
if (FALSE) { # \dontrun{
# After running bootstrap:
bs <- call_pharmpy_tool(
id = "run1",
model = model,
tool = "bootstrap",
options = list(samples = 200)
)
# Basic plot
plot_bootstrap(bs)
# With original estimates overlaid
orig <- c(POP_CL = 4.5, POP_V = 32.1, IIV_CL = 0.09)
p <- plot_bootstrap(bs, original_estimates = orig, ci = 0.95)
ggplot2::ggsave("bootstrap_params.png", p, width = 10, height = 8)
} # }