Original link:tecdat.cn/?p=19980

 

Feedforward neural networks with a single hidden layer and lagged input can be used to predict univariate time series. The neural network model is fitted to the time series with the lag value as the input. Therefore, it is a nonlinear model, and it is impossible to get a prediction interval.

So we use simulation.

Read data for visualization:

## # A tibble: 6 x 2 ## Date Actual ## <dttm> <dbl> ## 1 2016-01-11 26 ## 2 2016-01-18 27 ## 3 2016-01-25 28 ## 4 2016-02-01 22 ## 5 2016-02-08 27 ## 6 2016-02-1531Copy the code

 

Dat %>%ggplot(AES (Date,Actual))+ LABS (title = "Durability vehicle forecast ", x =" time ", y = "durability vehicle number ", subtitle =" 2016/2017 data ") +Copy the code

 

Dat %>%dplyr::rename(Date=Week)%>%na.omit() dat_ts = ts(dat[" actual number "])Copy the code

 

Nn (data, lambda = 0.5)Copy the code
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.2705Copy the code

I used the Box-Cox transform, where λ=0.5,

Make sure the residual homovariance.

The model can be written as:

Where YT-1 = (YT-1, YT-2,… and YT-8) is the vector containing the lag value of the sequence, f is a neural network with four hidden nodes in a single layer.

By randomly generating ϵt values from normal distributions or resamping from historical values, we can iteratively simulate the future sample paths of the model.

Therefore, if {ϵ ∗ T + 1} is randomly extracted from the error distribution at time T + 1, then

It is a probability derived from the prediction distribution of yT + 1. Set up the

Y * T + 1 = (y * T + 1, yT… yT-6) and then we can repeat the process to get it

We can iteratively model future sample paths. By repeatedly simulating the sample path, we establish the distribution of all future values based on the fitted neural network. This is a simulation of nine possible future sampling paths for the data. Each sample path covers the next 20 years after the observations.

plot(dat_ts) + autolayer(sim)
Copy the code

If you do this hundreds or thousands of times, you get a good idea of the prediction distribution. Forecast interval:

 

plot(fcast)
Copy the code

The number of simulations is 1000. By default, the error comes from the normal distribution.

 

 


Most welcome insight

1. Python for NLP: Classification using Keras’s multi-label text LSTM neural network

2. In Python, LSTM is used for time series predictive analysis — predicting power consumption data

3. Python uses LSTM in Keras to solve sequence problems

4.Python uses PyTorch machine learning classification to predict bank customer churn model

5.R language multivariate Copula GARCH model time series prediction

6. Use GAM (Generalized additive Model) in R language for power load time series analysis

7. ARMA, ARIMA (Box-Jenkins), SARIMA and ARIMAX models in R language are used to predict time series numbers

8. Empirical study on time series estimation of time-varying VAR model with R language

9. Time series analysis was carried out using the generalized additive model GAM