recovery_plot: Parameter recovery plot

View source: R/recovery.R

recovery_plotR Documentation

Parameter recovery plot

Description

Compares posterior estimates against the known data-generating values stored in attr(dat, "true_params") (as produced by simulate_smoothbp). For each matched parameter the plot shows the posterior mean, a credible interval, and the true value, coloured by whether the interval contains the truth.

Usage

recovery_plot(fit, dat, level = 0.95)

Arguments

fit

A smoothbp_fit object.

dat

The data frame used to fit fit, which must carry a "true_params" attribute (returned by simulate_smoothbp).

level

Credible interval width. Default 0.95.

Details

The function looks for population-level intercept parameters only. If the fitted model has covariates in a given component (e.g. omega = ~ 1 + group) the function still extracts the (Intercept) term for comparison against the scalar true value from the simulation.

Value

A ggplot object.

Examples

## Not run: 
dat <- simulate_smoothbp(n_subj = 20, n_obs = 8, seed = 42)
fit <- smoothbp(y ~ tau, b0 = ~ 1 + (1 | subject), data = dat,
                priors = smoothbp_priors(omega = prior_normal(3, 2, lb = 0)),
                chains = 4L, iter = 2000L, warmup = 1000L, seed = 42L)
recovery_plot(fit, dat)

## End(Not run)


smoothbp documentation built on June 14, 2026, 9:06 a.m.