# Chapter 8 Neural Networks in Time Series Analysis

NNAR-Neural Network Autoregression Model- has two components, $$p \ \& \ k$$. $$p$$ denotes the number of lagged values that are used as inputs. $$k$$ denotes the number of hidden nodes that are present. Output is denoted by $$NNAR(p, k)$$. If the dataset is seasonal then also the notation is pretty similar, i.e., $$NNAR(p, P, k)$$ where $$P$$ denotes the number of seasonal lags. $$p$$ is choosen based on the information criterion, like AIC. Neural nets has inherent random component. Therefore, it is suggested that the neural net model is run several times, 20 is the minimum requirement. Final result is then presented as mean or median. Also neural nets are known to not work well with the trend data. We should therefore, de-trend or differnce the data before running neural net model.

Looking at the data we see that the relationship between appliances and watt is unidirectional as the number of appliances impact the electricity consumption and not vice versa. Therefore, appliances can be used as an external regressor in the model. Moreover, since electricity consumption fluctuates a lot daily, we will use daily frequency. Most models are not good at handling large frequency data. One way out of this problem is to use the aggregation. But this might lead to over smoothening in the data. We also check for all the columns to have same length and all of them being numeric. There are many packages that allows one to compute neural net models. However, $$nnetar()$$ from forecast is most user friendly. One handy thing about $$nnetar()$$ is automatic selection of parameters. For more advanced implementation of the neural nets one can look at $$mlp()$$ function form nnfor package.

## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
##   X1 = col_double(),
##   watt = col_double(),
##   appliances = col_double()
## )

For forecast of neural net models with external regressor, we need to have future values of the external regressor to be fed in the forecast function. More than one external regressors can be used in the forecast of the neural net models.