[R] nnet learning

Samuel Kemp sam.kemp2 at ntlworld.com
Mon Oct 18 14:31:57 CEST 2004


Hi,

I am trying to make a neural network learning a "noisy sine wave". 
Suppose I generate my data like so..

x <- seq(-2*pi, 2*pi, length=500)
y <- sin(x) + rnorm(500, sd=sqrt(0.075))

I then train the neural net on the first 400 points using

c <- nnet(as.matrix(x[1:400]),as.matrix(y[1:400]), size=3, maxit=10000, 
abstol=0.075, decay=0.007)

Inspecting the fit of the training set against the actual values using:

pmat<- plot(y[1:400])
lines(c$fitted.values, col="blue", lwd=2)

It seems as though neural net is not learning the negative values. I 
have tried running nnet several times, but each time I get the same 
problem. I have also tried upsampling, but no joy.

I suspect that I am not using nnet correctly. Can anyone provide any 
hints/solutions?

Any help appreciated.

Kind Regards,

Samuel Kemp.




More information about the R-help mailing list