% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/recovery.R
\name{recovery_plot}
\alias{recovery_plot}
\title{Parameter recovery plot}
\usage{
recovery_plot(fit, dat, level = 0.95)
}
\arguments{
\item{fit}{A \code{smoothbp_fit} object.}

\item{dat}{The data frame used to fit \code{fit}, which must carry a
\code{"true_params"} attribute (returned by \code{\link{simulate_smoothbp}}).}

\item{level}{Credible interval width.  Default \code{0.95}.}
}
\value{
A \code{ggplot} object.
}
\description{
Compares posterior estimates against the known data-generating values stored
in \code{attr(dat, "true_params")} (as produced by
\code{\link{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.
}
\details{
The function looks for population-level intercept parameters only.  If the
fitted model has covariates in a given component (e.g.
\code{omega = ~ 1 + group}) the function still extracts the
\code{(Intercept)} term for comparison against the scalar true value from
the simulation.
}
\examples{
\dontrun{
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)
}

}
