% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ppc.R
\name{predict.bdeb_fit}
\alias{predict.bdeb_fit}
\alias{bdeb_predict}
\title{Predict from a BDEB Fit}
\usage{
\method{predict}{bdeb_fit}(object, newdata = NULL, n_draws = 200, dt = 0.5, seed = NULL, ...)

bdeb_predict(fit, newdata = NULL, n_draws = 200, dt = 0.5, seed = NULL)
}
\arguments{
\item{object}{A \code{\link[=bdeb_fit]{bdeb_fit()}} object.}

\item{newdata}{Optional named list with new conditions.  Supported
fields:
\describe{
\item{\code{t_predict}}{Numeric vector of prediction time points (days).
Required when \code{newdata} is not \code{NULL}.}
\item{\code{f_food}}{Scaled functional response (default: value from
the fitted model).}
\item{\code{concentration}}{External toxicant concentration (scalar;
only for \code{"debtox"} models; default 0).}
}}

\item{n_draws}{Number of posterior draws to use. Default 200.}

\item{dt}{Euler step size for forward simulation (days). Default 0.5.}

\item{seed}{Integer seed for reproducible draw selection.
Default \code{NULL} (no seed).}

\item{...}{Ignored.}

\item{fit}{A \code{\link[=bdeb_fit]{bdeb_fit()}} object.}
}
\value{
A \code{bdeb_prediction} object with components \code{t} (time vector),
\code{L_hat} (matrix: draws x time points), \code{n_draws}, \code{model_type}.
}
\description{
When \code{newdata = NULL}, extracts the fitted trajectories (\code{L_hat})
from the Stan posterior (exact).  When \code{newdata} is provided, performs
\strong{R-side forward simulation} (Euler integration) from the posterior
draws under new environmental conditions or extended time horizons.
The Euler integrator is an \strong{approximation} — for quantitative
results at the original data conditions, prefer \code{newdata = NULL}.
}
\examples{
\donttest{
if (requireNamespace("cmdstanr", quietly = TRUE) &&
    nzchar(tryCatch(cmdstanr::cmdstan_path(), error = function(e) ""))) {
  data(eisenia_growth)
  dat <- bdeb_data(growth = eisenia_growth[eisenia_growth$id == 1, ])
  fit <- bdeb_fit(bdeb_model(dat, type = "individual"),
                  chains = 2, iter_warmup = 200, iter_sampling = 200,
                  refresh = 0)
  pred <- predict(fit, n_draws = 200)
  summary(pred); plot(pred)
}
}
}
