1
votes

I am trying to running nnet. It keeps giving a fatal error that freezes r and have to restart R environment. I wonder is there a limitation in nnet, or my code is wrong. My data is following.

str(data1)
'data.frame':   40749 obs. of  31 variables:
$ station_nbr: chr  "1" "1" "1" "1" ...
$ date       : Date, format: "2012-01-01" "2012-01-02" ...
$ store_nbr  : chr  "1" "1" "1" "1" ...
$ units      : int  0 0 0 0 0 0 0 0 0 0 ...
$ tmax       : num  52 50 32 28 38 46 57 45 39 47 ...
$ tmin       : num  31 31 11 9 25 25 28 27 23 29 ...
$ tavg       : num  42 41 22 19 32 36 43 36 31 38 ...
$ dewpoint   : int  36 26 4 -1 13 21 28 22 12 24 ...
$ wetbulb    : int  40 35 18 14 25 29 36 32 25 32 ...
$ heat       : num  23 24 43 46 33 29 22 29 34 27 ...
$ cool       : num  0 0 0 0 0 0 0 0 0 0 ...
$ snowfall   : num  0 0 0 0 0 NA 0 0 0 0 ...
$ preciptotal: num  0.05 0.01 0 0 0 0.005 0 0 0 0.005 ...
$ stnpressure: num  29.8 29.4 29.7 29.9 29.7 ...
$ resultspeed: num  3.6 9.8 10.8 6.3 6.9 0.3 3 5.1 2.3 5.4 ...
$ avgspeed   : num  4.6 10.3 11.6 8.3 7.8 2.4 3.6 6.6 4 6.5 ...
$ event      : chr  "0" "0" "0" "0" ...
$ RA         : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 1 1 ...
$ BR         : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 1 1 ...
$ FZ         : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 1 1 ...
$ FG         : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 1 1 ...
$ SN         : Factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 1 1 1 ...
$ TS         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ DZ         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ BL         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ DU         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ SQ         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ FU         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ GR         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ GS         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ weekdays   : Factor w/ 8 levels "holiyday","Friday",..: 6 1 8 4 3 2 7 6 5 8   ...

and nnet code is

library(nnet)
neural.mod = nnet(f, data = data1 , size = c(5,5), decay = 0.001, maxit = 100, rang = 0.05)

where f is

f
units ~ station_nbr + date + store_nbr + tmax + tmin + tavg + 
    dewpoint + wetbulb + heat + cool + snowfall + preciptotal + 
    stnpressure + resultspeed + avgspeed + event + RA + BR + 
    FZ + FG + SN + TS + DZ + BL + DU + SQ + FU + GR + GS + weekdays

Give error in Rstudio without any error message on console.

the error i get

1
Does it actually throw an error, or does it just freeze your environment? - Max Candocia
Yes, and force to quit my environment. So i have to restart it every time. - asbebe
How long does it usually last before you quit? Also, have you looked at how much RAM is being used up while you run it? - Max Candocia
It is not just freezing, it also gives me an fatal error that force me to quit environment. Not very long, depends on cases but usually 20-30 seconds before it occurs the error. RAM usages is 5.09 GB out of 8GB - asbebe
what's the error message? - tospig

1 Answers

0
votes

Are you sure about: neural.mod = nnet(f, data = data1 , size = c(5,5), decay = 0.001, maxit = 100, rang = 0.05)

As I understand the nnet model it is limited to one hidden layer whereas your size = c(5,5) is supplying a vector for two hidden layers like in the neuralnet pkg.

Try something like size = 5 and see how you go.