Skip to contents

Generates up to four diagnostic panels:

Usage

# S3 method for class 'admFit'
plot(x, which = c("mean", "cov", "nll", "par"), n_sim = NULL, seed = 1L, ...)

Arguments

x

An admFit object returned by nlmixr2() with est = "admc" or est = "adirmc".

which

Character vector selecting which panel types to produce. Any subset of c("mean", "cov", "nll", "par"). Defaults to all four.

n_sim

Number of MC samples for the final prediction. Defaults to the value used during fitting. Only used when "mean" or "cov" is in which.

seed

Random seed for reproducibility.

...

Unused.

Value

A named list of ggplot2 objects, invisibly. Prints each selected plot.

Details

  1. "mean" – Observed vs predicted mean per study (2x2 grid). Upper row: observed and predicted mean lines with +/-1 SD ribbon on a shared y scale (black throughout). Lower row: raw residual lollipop with +/-2 SE band and standardised residual z-scores with +/-1.96 reference lines.

  2. "cov" – Observed vs predicted (co)variance heatmaps per study (2x2 grid). Upper row shares a common colour scale (blue-white-red). Lower row uses distinct diverging scales: residual (red-white-green) and standardised residual (gold-white-purple). Significance stars overlaid on the standardised residual panel.

  3. "nll" – NLL trace per restart over optimizer evaluations. Restarts coloured with the Okabe-Ito palette.

  4. "par" – Parameter trace per restart on the natural scale (struct thetas back-transformed, sigma as SD, omega diagonal as variance labelled V(eta.x)). Facets ordered as in the model ini() block. Restarts coloured with the Okabe-Ito palette.

Examples

if (FALSE) { # \dontrun{
fit <- nlmixr2(model, admData(), est = "admc", control = admControl(...))

# All panels (default)
plots <- plot(fit)

# Only mean and covariance diagnostics
plot(fit, which = c("mean", "cov"))

# Only traces (no MC simulation needed -- fast)
plot(fit, which = c("nll", "par"))

# Access a specific panel from the returned list
plots$mean_study1   # mean diagnostics for the study named "study1"
plots$cov_study1    # covariance heatmap for "study1"
plots$nll_trace     # NLL trace
plots$par_trace     # parameter trace
} # }