\Header{LDEsysMat}{Generate system matrix for LDEs}
\keyword{models}{LDEsysMat}
\begin{Description}\relax
Generate the system matrix for the linear differential equations
determined by a compartment model.\end{Description}
\begin{Usage}
\begin{verbatim}
LDEsysMat(pars, incidence)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{pars}] a numeric vector of parameter values.
\item[\code{incidence}] an integer matrix with columns named \code{From},
\code{To}, and \code{Par}.  Values in the \code{Par} column must
be in the range 1 to \code{length(pars)}.  
Values in the \code{From}
column must be between 1 and the number of compartments.
Values in the \code{To}
column must be between 0 and the number of compartments.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A compartment model describes material transfer between \code{k}
in a system of \code{k} compartments to a linear system of differential
equations. Given a description of the system and a vector of parameter
values this function returns the system matrix.

This function is intended for use in a general system for solving
compartment models, as described in Bates and Watts (1988).\end{Details}
\begin{Value}
A \code{k} by \code{k} numeric matrix.\end{Value}
\begin{Author}\relax
Douglas Bates \email{bates@stat.wisc.edu}\end{Author}
\begin{References}\relax
Bates, D. M. and Watts, D. G. (1988), \emph{Nonlinear Regression
Analysis and Its Applications}, Wiley, New York.\end{References}
\begin{Examples}
\begin{ExampleCode}
# incidence matrix for a two compartment open system
incidence <-
  matrix(c(1,1,2,2,2,1,3,2,0), ncol = 3, byrow = TRUE,
   dimnames = list(NULL, c("Par", "From", "To")))
incidence
LDEsysMat(c(1.2, 0.3, 0.4), incidence)
\end{ExampleCode}
\end{Examples}

