\HeaderA{nnetHess}{Evaluates Hessian for a Neural Network}{nnetHess}
\keyword{neural}{nnetHess}
\begin{Description}\relax
Evaluates the Hessian (matrix of second derivatives) of the specified
neural network. Normally called via argument \code{Hess=TRUE} to \code{nnet} or via
\code{vcov.multinom}.
\end{Description}
\begin{Usage}
\begin{verbatim}
nnetHess(net, x, y, weights)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{net}] object of class \code{nnet} as returned by \code{nnet}.

\item[\code{x}] training data.

\item[\code{y}] classes for training data.

\item[\code{weights}] the (case) weights used in the \code{nnet} fit.

\end{ldescription}
\end{Arguments}
\begin{Value}
square symmetric matrix of the Hessian evaluated at the weights stored
in the net.
\end{Value}
\begin{References}\relax
Ripley, B. D. (1996)
\emph{Pattern Recognition and Neural Networks.} Cambridge.

Venables, W. N. and Ripley, B. D. (2002)
\emph{Modern Applied Statistics with S.} Fourth edition.  Springer.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{nnet}{nnet}}, \code{\LinkA{predict.nnet}{predict.nnet}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(iris3)
# use half the iris data
ir <- rbind(iris3[,,1], iris3[,,2], iris3[,,3])
targets <- matrix(c(rep(c(1,0,0),50), rep(c(0,1,0),50), rep(c(0,0,1),50)),
150, 3, byrow=TRUE)
samp <- c(sample(1:50,25), sample(51:100,25), sample(101:150,25))
ir1 <- nnet(ir[samp,], targets[samp,],size=2, rang=0.1, decay=5e-4, maxit=200)
eigen(nnetHess(ir1, ir[samp,], targets[samp,]), TRUE)$values
\end{ExampleCode}
\end{Examples}

