Skip to contents

Produces visualizations for fitted IRT models. Supports 12 plot types with automatic selection between base R and ggplot2 backends.

Usage

# S3 method for class 'dpmirt_fit'
plot(
  x,
  type = c("density", "items", "trace", "clusters", "dp_density", "icc", "wright_map",
    "parameter_trace", "caterpillar", "density_compare", "info", "pp_check"),
  engine = c("auto", "base", "ggplot2"),
  ...
)

Arguments

x

A dpmirt_fit object.

type

Character. Plot type. One of:

"density"

Kernel density of posterior mean theta.

"items"

Item difficulty estimates with error bars.

"trace"

Log-likelihood MCMC trace.

"clusters"

Cluster count trace and histogram (DPM only).

"dp_density"

DP mixture density with credible band (DPM only; see dpmirt_dp_density for the transformed-scale caveat).

"icc"

Item Characteristic Curves.

"wright_map"

Person-Item map (Wright map).

"parameter_trace"

Individual parameter MCMC traces.

"caterpillar"

Sorted estimates with credible intervals.

"density_compare"

Posterior density vs reference overlay.

"info"

Test Information Function.

"pp_check"

Posterior predictive check.

engine

Character. Plotting backend: "auto" (default) uses ggplot2 if available, "base" forces base R, "ggplot2" requires ggplot2.

...

Additional arguments passed to the specific plotting function.

Value

Invisibly returns a ggplot object when the ggplot2 backend is used; invisibly returns NULL when the base R backend is used.

Details

For type = "dp_density", Rasch/location-shift settings are the most directly interpretable. For transformed-scale 2PL/3PL IRT and SI fits, use the plot as a diagnostic summary because full scale/Jacobian density adjustment is not yet implemented.

Examples

if (FALSE) { # \dontrun{
sim <- dpmirt_simulate(200, 20, model = "rasch", seed = 42)
fit <- dpmirt(sim$response, model = "rasch", prior = "normal",
              niter = 5000, nburnin = 1000, seed = 123)

# Theta density
plot(fit, type = "density")

# Item difficulty estimates
plot(fit, type = "items")

# MCMC trace
plot(fit, type = "trace")

# Force base R backend
plot(fit, type = "density", engine = "base")
} # }