When I make a forecast for the univariate time series $x_1=1, x_2=2, \dots, x_{14} = 14$, why does the nnetar() function in R (which uses a neural network) not calculate correct results, whereas ets() (which uses exponential smoothing) does?

df <- (1:14)


Result: 14.75729410 15.37348413 15.85274344 16.21147877 16.47188350 16.65653700 16.78524210 16.87385438 16.93433975 16.97538111

fit2 <- ets(df)
fc <- forecast(fit2,h=10)

Result: 15 16 17 18 19 20 21 22 23 24

Which is the appropriate neuronal network / function for time series prediction? Please consider that the above example is just a simplified data-example.


2 Answers 2


which is the appropriate neuronal network / function for time series prediction? Please consider, that above example is just a simplified data-example.

Well, this totally depends on your data. In your example data you have

  • a small univariate time series (only 14 observations)
  • a linear trend
  • no white noise
  • no seasonality
  • no cycle
  • non non-linearity


Neural networks are generally very data savvy/ data hungry. That means that you need a lot of data to implement an accurate forecast. 14 observations are definitely not enough you rather need some ten or hundred thousands. In general, I do not recommend using neural networks for forecasting univariate time series. One benefit of neural networks is that they can capture nonlinearities, but your data does not exhibit any nonlinearity. Note that nnetar() uses a feed-forward neural network; in recent time series forecasting many researchers use recurrent neural networks instead of feed-forward neural networks.

You can also read this discussion. As far as I know nnetar() is based on the discussion here

If you print fit you will see the model. It is an average of 20 different neural networks and therefore not deterministic.

Series: df 
Model:  NNAR(1,1) 
Call:   nnetar(y = df)

Average of 20 networks, each of which is
a 1-1-1 network with 4 weights
options were - linear output units 

sigma^2 estimated as 0.003636


This function uses exponential smoothing. Exponential smoothing models require fewer parameters. Therefore they perform better on your tiny dataset.

It might help to have a closer look at the equations of simple exponential smoothing:

$s_0 = x_0$

$s_t = \alpha x_t + (1- \alpha) s_{t-1}$

In your case $s_0$ and $x_0$ are 0.

If you print fit2 you can see that the information criteria are all equal to minus infinity which states that there is no better model than the one you have chosen.


 ets(y = df) 

  Smoothing parameters:
    alpha = 0.5445 
    beta  = 0.1009 

  Initial states:
    l = 0 
    b = 1 

  sigma:  0

-Inf -Inf -Inf 
  • $\begingroup$ what is s? s=y? $\endgroup$
    – flobrr
    Nov 15, 2017 at 18:19
  • $\begingroup$ s=y. In other words s is the output of the exponential smoothing algorithm. $\endgroup$
    – Ferdi
    Nov 15, 2017 at 18:25
  • 1
    $\begingroup$ sorry, my fault. you are right. its NNAR(1,1) $\endgroup$
    – flobrr
    Nov 15, 2017 at 18:32
  • 1
    $\begingroup$ @flobrr "not deterministic": the model assumptions behind the nnetar do not model the process, so the differences between predictions and observed values are taken (incorrectly) to be noise in the model. $\endgroup$
    – AdamO
    Nov 15, 2017 at 18:43
  • 2
    $\begingroup$ +1, nice answer! When you write that NNs are "data savvy", do you mean "data hungry" or "greedy"? $\endgroup$ Nov 15, 2017 at 18:56

That's because the data generating process is a deterministic model. This is a special case of an ARIMA(0,1,1) process, also known as exponential smoothing. Therefore the exponential smoothing model generates forecasts that match your expectation. The autoregressive neural network does not model this type of process.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.