zero predictions from nnet function - R

70 Views Asked by At

I obtain 0 fitted values when using nnet function as below:

nnet(realized1~ann_t1+ann_t2+ann_t3, data=df2_input, size=2)

Output is

> str(nnet(realized1~ann_t1+ann_t2+ann_t3, data=df2_input, size=2))
# weights:  11
initial  value 134.845214 
final  value 0.147077 
converged
List of 18
 $ n            : num [1:3] 3 2 1
 $ nunits       : int 7
 $ nconn        : num [1:8] 0 0 0 0 0 4 8 11
 $ conn         : num [1:11] 0 1 2 3 0 1 2 3 0 4 ...
 $ nsunits      : int 7
 $ decay        : num 0
 $ entropy      : logi FALSE
 $ softmax      : logi FALSE
 $ censored     : logi FALSE
 $ value        : num 0.147
 $ wts          : num [1:11] 14.815 -69.862 0.244 -0.456 -5.638 ...
 $ convergence  : int 0
 $ fitted.values: num [1:800, 1] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:800] "1601" "1602" "1603" "1604" ...
  .. ..$ : NULL
 $ residuals    : num [1:800, 1] 0.004267 0.000401 0.002404 0.022561 0.001354 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:800] "1601" "1602" "1603" "1604" ...
  .. ..$ : NULL
 $ call         : language nnet.formula(formula = realized1 ~ ann_t1 + ann_t2 + ann_t3, data = df2_input, size = 2)
 $ terms        :Classes 'terms', 'formula'  language realized1 ~ ann_t1 + ann_t2 + ann_t3
  .. ..- attr(*, "variables")= language list(realized1, ann_t1, ann_t2, ann_t3)
  .. ..- attr(*, "factors")= int [1:4, 1:3] 0 1 0 0 0 0 1 0 0 0 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : chr [1:4] "realized1" "ann_t1" "ann_t2" "ann_t3"
  .. .. .. ..$ : chr [1:3] "ann_t1" "ann_t2" "ann_t3"
  .. ..- attr(*, "term.labels")= chr [1:3] "ann_t1" "ann_t2" "ann_t3"
  .. ..- attr(*, "order")= int [1:3] 1 1 1
  .. ..- attr(*, "intercept")= int 1
  .. ..- attr(*, "response")= int 1
  .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
  .. ..- attr(*, "predvars")= language list(realized1, ann_t1, ann_t2, ann_t3)
  .. ..- attr(*, "dataClasses")= Named chr [1:4] "numeric" "numeric" "numeric" "numeric"
  .. .. ..- attr(*, "names")= chr [1:4] "realized1" "ann_t1" "ann_t2" "ann_t3"
 $ coefnames    : chr [1:3] "ann_t1" "ann_t2" "ann_t3"
 $ xlevels      : Named list()
 - attr(*, "class")= chr [1:2] "nnet.formula" "nnet"

Input data frame is as below:

> str(df2_input)
'data.frame':   800 obs. of  4 variables:
 $ realized1: num  0.004267 0.000401 0.002404 0.022561 0.001354 ...
 $ ann_t1   : num  -4.4 -4.19 -4.3 -4.48 -4.6 ...
 $ ann_t2   : num  0 -0.002996 -0.000298 -0.001964 -0.01963 ...
 $ ann_t3   : num  0 -0.01662 0.00165 -0.01089 -0.10887 ...

Why do I get zero predictions and how can I fix it?

Thanks a lot.

0

There are 0 best solutions below