# [R] On the Use of the nnet Library

yukihiro ishii yukiasais at ybb.ne.jp
Wed Aug 20 13:58:50 CEST 2003

```Dear List,

I am trying to solve a problem by the neural network method(library:
nnet). The problem is to express Weight in terms of Age , Sex and
Height for twenty people(thius is an example given by Tanake in
"Introduction to Neural Networks by NEUROSIM/L"(2003, in Japanese))..
The data frame consists of 20 observations with four variables: Sex, Age,
Height and Weight. Sex is treated as a factor, Age and Weight are
variables normalized to unity, as usual. I wanted to construct a neural
network based on this data, and so I ran the following code:

>library(nnet)
>net1<-nnet(Weight~Age+Sex+Height, size=2, linout=T,maxit=1000)

I repeated this thirteen times.  I used the default initial parameters
unless otherwise noted. The result is as follows, where init and final
mean initial and final RSS's, and NIT means the number of iterations
before reaching convergence or noncovergence:

Run#	init		NIT	final
1	71991.1 	30	995.1
2	70870.0 	370	33.1
3	72755.8 	<10	2134.3
4	69840.6 	<10	2134.3
5	70368.8 	190	39.7
6	70368.8 	270	41.0
7	71101.2 	190	39.7
8	71606.1 	<10	2134.3
9	72076.1 	<10	2134.3
10	72249.1 	300	15.0
11	71424.1 	<10	2134.3
12	68483.8 	130	39.7
13	71435.9 	>1000	4.6

As you can see, the result is far from stable.

My question is:

How can I reach a stable answer?

.I know that initial parameters are crucially important in my case, and I
must choose proper parameter values, but I do not know how I can do that.

My second question is related to the response analysis of this data. I
do not know an effective method to evaluate the response to the
variance of each explanatory variable. Tanabe(2003) mentions "Net Effect
Ratio" defined by the average of dy/dx. Is there such a function in the
library, nnet? Such a function may help me reduce the number of the
explanatory variables.

I wonder if anyone could help me in such elementary questions.

---- It's elementary, Watson!

I remain an obedient Watson, hoping for Holmes' wisdom.

--
Yukihiro Ishii <yukiasais at ybb.ne.jp>