\Header{numericDeriv}{Evaluate derivatives numerically}
\keyword{models}{numericDeriv}
\begin{Description}\relax
\code{numericDeriv} numerically evaluates the gradient of an expression.
\end{Description}
\begin{Usage}
\begin{verbatim}
numericDeriv(expr, theta, rho=parent.frame())
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{expr}] The expression to be differentiated.  The value of this
expression should be a numeric vector.
\item[\code{theta}] A character vector of names of variables used in \code{expr}
\item[\code{rho}] An environment containing all the variables needed to
evaluate \code{expr}
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This is a front end to the C function \code{numeric\_deriv}, which is
described in \emph{Writing R Extensions}.
\end{Details}
\begin{Value}
The value of \code{eval(expr, env = rho)} plus a matrix
attribute called \code{gradient}.  The columns of this matrix are
the derivatives of the value with respect to the variables listed in
\code{theta}.
\end{Value}
\begin{Author}\relax
Saikat DebRoy \email{saikat@stat.wisc.edu}
\end{Author}
\begin{Examples}
\begin{ExampleCode}
myenv <- new.env()
assign("mean", 0., env = myenv)
assign("sd", 1., env = myenv)
assign("x", seq(-3., 3., len = 31), env = myenv)
numericDeriv(quote(pnorm(x, mean, sd)), c("mean", "sd"), myenv)
\end{ExampleCode}
\end{Examples}

