[R] Time Series with Neural Networks
Emre Karagülle
karagullemre at gmail.com
Tue Dec 26 09:36:01 CET 2017
Hi,
I am would like to ask few questions.
I am trying to forecast hourly electricity prices by 24 hours ahead.
I have hourly data starting from 2015*12*18 to 2017-10-24
and I have defined the data as time series as written in the code below.
Then I am trying do neural network with 23 non-seasonal dummies and 1 seasonal dummy.
But I don’t know whether training set is enough.( Guess it is 50 hours in here?)
The problem is that I couldn’t 24 for output here. How can I make such forecast?
And my MASE score (6.95 in the Test set) is not good. Could be related to shortness of training set?
The Code:
library(zoo)
library(readxl)
setwd("C:/Users/emrek/Dropbox/2017-2018 Master Thesis/DATA")
epias <- read_excel("eski.epias.xlsx")
nPTF <- epias$`PTF (TL/MWh)`
nSMF<- epias$`SMF(TL/MWh)`
nC<- epias$`TT(MWh)`
nEAK<- epias$`EAK-Toplam (MWh)`
nTP<- epias$`Toplam (MWh)`
times <- seq(from=as.POSIXct("2015-12-18 00:00:00"), to=as.POSIXct("2017-10-24 23:00:00"), by="hour")
mydata <- rnorm(length(times))
PTF <- zoo(nPTF, order.by=times )
SMF <- zoo(nSMF, order.by=times )
C <- zoo(nC, order.by=times )
EAK <- zoo(nEAK, order.by=times )
TP<- zoo(nTP, order.by=times )
SH <- (EAK-TP)
epias <- cbind(PTF,C,SH)
View(epias)
#neural networks
library(forecast)
set.seed(201)
epias.nn <- nnetar(PTF, repeats = 50, p=23, P=1, size =12)
summary(epias.nn$model[[1]])
epias.pred <- forecast(epias.nn, h= 24)
accuracy(epias.pred, 24)
plot(PTF, ylim=c(0,500) , ylab= , xlab= , bty="l", xaxt="n", xlim=c(as.POSIXct("2017-10-20 00:00:00"),as.POSIXct("2017-10-25 23:00:00")) , lty=1 )
lines(epias.pred$fitted,lwd = 2,col="blue")
Best Regards,
--
Emre
[[alternative HTML version deleted]]
More information about the R-help
mailing list