Evaluates the Hessian (matrix of second derivatives) of the specified neural network. Normally called via argument Hess=TRUE to nnet or via vcov.multinom.

nnetHess(net, x, y, weights)

Arguments

net

object of class nnet as returned by nnet.

x

training data.

y

classes for training data.

weights

the (case) weights used in the nnet fit.

Value

square symmetric matrix of the Hessian evaluated at the weights stored in the net.

References

Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

See also

Examples

# 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)
#> # weights:  19
#> initial  value 55.594229 
#> iter  10 value 43.213537
#> iter  20 value 24.112975
#> iter  30 value 2.647947
#> iter  40 value 2.413653
#> iter  50 value 2.070039
#> iter  60 value 1.620467
#> iter  70 value 1.498257
#> iter  80 value 1.426569
#> iter  90 value 1.362041
#> iter 100 value 1.356693
#> iter 110 value 1.353109
#> iter 120 value 1.349269
#> iter 130 value 1.346929
#> iter 140 value 1.346188
#> iter 150 value 1.346017
#> iter 160 value 1.345958
#> iter 170 value 1.345905
#> final  value 1.345901 
#> converged
eigen(nnetHess(ir1, ir[samp,], targets[samp,]), TRUE)$values
#>  [1] 7.864661e+02 1.174988e+00 9.539127e-01 2.750021e-01 2.147747e-01
#>  [6] 7.993311e-02 6.880963e-02 2.075167e-02 9.943789e-03 5.276186e-03
#> [11] 2.788052e-03 2.297126e-03 1.914639e-03 1.243827e-03 1.142954e-03
#> [16] 1.111163e-03 1.027852e-03 1.003237e-03 9.321736e-04