% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data_prep.R
\name{bdeb_data}
\alias{bdeb_data}
\title{Prepare Data for BDEB Models}
\usage{
bdeb_data(growth = NULL, reproduction = NULL, concentration = NULL, f_food = 1)
}
\arguments{
\item{growth}{A data frame with columns: \code{id}, \code{time} (days),
\code{length} (\strong{structural} length in cm, i.e., \eqn{L = V^{1/3}}).
If your data are \strong{physical (observed) lengths}, multiply by the
shape coefficient: \eqn{L = \delta_M \times L_w}.  See the
package vignette for guidance on \eqn{\delta_M}.}

\item{reproduction}{A data frame with columns: \code{id}, \code{t_start}, \code{t_end},
\code{count} (number of offspring in the interval).
For cumulative counts use \code{\link[=repro_to_intervals]{repro_to_intervals()}} first.}

\item{concentration}{Optional named numeric vector or data frame mapping
individual/group id to external toxicant concentration \eqn{C_w}
(for DEBtox models; see \code{\link[=bdeb_tox]{bdeb_tox()}}).}

\item{f_food}{Scaled functional response \eqn{f \in [0,1]}, the ratio
of actual to maximum ingestion rate (Kooijman, 2010, Eq. 2.3).
Default 1 (ad libitum feeding).}
}
\value{
A \code{bdeb_data} object (S3 list) ready for \code{\link[=bdeb_model]{bdeb_model()}}.
}
\description{
Converts long-format data frames into the structured list required by
the BayesianDEB Stan programs.  Growth observations are matched to the
DEB state variable \eqn{L = V^{1/3}} (structural length); reproduction
records are interval counts of offspring over \eqn{[t_{\mathrm{start}},
t_{\mathrm{end}})}.  The function validates column names, rejects
negative times/lengths, sorts by individual and time, and (for
hierarchical models) pads ragged observation vectors into matrices with
\code{NaN} fill, as required by Stan's fixed-size array declarations.
}
\examples{
# Simple growth data
df <- data.frame(
  id = rep(1, 10),
  time = seq(0, 45, by = 5),
  length = c(0.1, 0.15, 0.22, 0.30, 0.38, 0.44, 0.49, 0.52, 0.54, 0.55)
)
dat <- bdeb_data(growth = df)
}
\references{
Kooijman, S.A.L.M. (2010). \emph{Dynamic Energy Budget Theory for Metabolic
Organisation}. 3rd edition. Cambridge University Press.
\doi{10.1017/CBO9780511805400}
}
