Neural Network

Time Series

Neural Network Method for Time Series Data

Yeongeun Jeon , Jung In Seo
06-05-2020

Introduction

신경망

선형 회귀에 대응되는 단순한 신경망.
4개의 입력값과 1개의 숨은 층에 3개의 숨은 뉴런이 있는 신경망.

\[ \begin{aligned} s(z)=\frac{1}{1+e^{-z}}. \end{aligned} \]

신경망 자기회귀

pacman::p_load("data.table",
               "forecast",
               "ggplot2")

# Data 불러오기 ----------------------------------------------------------------


 Amtrak.data <- fread(paste(getwd(),"Amtrak.csv", sep="/"))

ridership.ts <- ts(Amtrak.data$Ridership, start=c(1991,1), end=c(2004,3), freq=12)

모형 적합

set.seed(10)
fit <- nnetar(ridership.ts,  repeats=200, lambda="auto")  # If lambda="auto", then a transformation is automatically selected using BoxCox.lambda
                                                          # 200 networks to fit with different random starting weights & averaged./ Size : The number of hidden node
autoplot(forecast(fit, h=30)) + ylab("Ridership")

예측구간

sim <- ts(matrix(0, nrow=30L, ncol=9L), 
          start=end(ridership.ts)[1L]+1L) 
set.seed(10)
for(i in seq(9)){
  
  sim[,i] <- simulate(fit, nsim=30L)

}

autoplot(ridership.ts) + autolayer(sim) + ylab("Ridership")

set.seed(10)
fcast <- forecast(fit, PI=TRUE, npaths=1000, h=30) # Npaths : How many simulation/ Normal error 
autoplot(fcast) + ylab("Ridership")

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".