% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/adjoint.R
\name{.rxAdjointGrad}
\alias{.rxAdjointGrad}
\title{Adjoint gradient of an objective (single backward sweep)}
\usage{
.rxAdjointGrad(
  object,
  params,
  events,
  calcSens,
  pred,
  obsTimes,
  obs,
  weight = 1,
  errModel = NULL,
  denseBy = 0.01,
  atol = 1e-10,
  rtol = 1e-10
)
}
\arguments{
\item{object}{model definition accepted by \code{\link[=rxode2]{rxode2()}} (text,
\code{rxode2} object, or function/ui).}

\item{params}{named numeric vector of parameter values.}

\item{events}{event table / data used to define dosing.}

\item{calcSens}{character vector of parameter names to differentiate with
respect to.}

\item{pred}{character prediction expression \code{f} (function of states and
parameters), e.g. \code{"center/v"}.}

\item{obsTimes}{numeric observation times.}

\item{obs}{numeric observed values aligned with \code{obsTimes}.}

\item{weight}{numeric scalar or vector of least-squares observation weights
(ignored when \code{errModel} is supplied).}

\item{errModel}{\code{NULL} for least squares, or a list with character entries
\code{add} and/or \code{prop} naming the additive / proportional residual-error
parameters, selecting the FOCEi -2LL objective \code{v = add^2 + (prop*f)^2}.}

\item{denseBy}{grid spacing for the forward checkpoint trajectory; smaller
values reduce the covariate-interpolation error.}

\item{atol, rtol}{solver tolerances used for both the forward checkpoint and
the backward sweeps.}
}
\value{
named numeric vector \code{dG/dtheta} over \code{calcSens}.
}
\description{
Computes \code{dG/dtheta} for every parameter with a single backward sweep.
Supports least squares (default,
\verb{G = sum_i 1/2 weight_i (f_i - obs_i)^2}) or, when \code{errModel} is given, the
FOCEi -2 log-likelihood \verb{G = sum_i r_i^2/v_i + log(v_i)} with
\code{v_i = add^2 + (prop*f_i)^2}.
}
\author{
Matthew L. Fidler
}
\keyword{internal}
