-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c0ec0e1
Showing
7 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Package: stlELM | ||
Type: Package | ||
Title: Hybrid Forecasting Model Based on STL Decomposition and ELM | ||
Version: 0.1.0 | ||
Authors@R: | ||
c(person(given = "Girish Kumar", | ||
family = "Jha", | ||
role = c("aut", "cre"), | ||
email = "girish.stat@gmail.com"), | ||
person(given = "Ronit", | ||
family = "Jaiswal", | ||
role = c("aut", "ctb")), | ||
person(given = "Kapil", | ||
family = "Choudhary", | ||
role = "ctb"), | ||
person(given = "Rajeev Ranjan", | ||
family = "Kumar", | ||
role = "ctb")) | ||
Maintainer: Girish Kumar Jha <girish.stat@gmail.com> | ||
Description: Univariate time series forecasting with STL decomposition based Extreme Learning Machine hybrid model. For method details see Xiong T, Li C, Bao Y (2018). <doi:10.1016/j.neucom.2017.11.053>. | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.1.1 | ||
Imports: forecast, nnfor | ||
Depends: R (>= 2.10) | ||
NeedsCompilation: no | ||
Packaged: 2021-02-19 11:25:25 UTC; Rajeev-PC | ||
Author: Girish Kumar Jha [aut, cre], | ||
Ronit Jaiswal [aut, ctb], | ||
Kapil Choudhary [ctb], | ||
Rajeev Ranjan Kumar [ctb] | ||
Repository: CRAN | ||
Date/Publication: 2021-02-22 11:10:02 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b8f537a5c031e9678a52d6274f72759f *DESCRIPTION | ||
33d4a5bbc7143488f1affd7ef7e8a362 *NAMESPACE | ||
ebfacfe9ca25d6d6a5d1ad816c0f347b *R/STLELM.R | ||
0fe36bd2282e5094deb5fc4ac37d4ac6 *data/Data_potato.rda | ||
bf7ba1580a1ca934a59bb9e2718ee37c *man/Data_potato.Rd | ||
a7e72f2575a11a59ee2f80f61c82f1df *man/STLELM.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(STLELM) | ||
importFrom(forecast,mstl) | ||
importFrom(graphics,plot) | ||
importFrom(nnfor,elm) | ||
importFrom(stats,as.ts) | ||
importFrom(stats,ts) | ||
importFrom(utils,head) | ||
importFrom(utils,tail) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' @importFrom forecast mstl | ||
#' @importFrom nnfor elm | ||
#' @importFrom utils head tail | ||
#' @importFrom graphics plot | ||
#' @importFrom stats as.ts ts | ||
#' @export | ||
#' | ||
STLELM <- function(data, stepahead=10){ | ||
STLcomp <- mstl(data) | ||
STLcomp_plots<-plot(STLcomp) | ||
data_trn <- ts(head(data, round(length(data) - stepahead))) | ||
data_test <- ts(tail(data, stepahead)) | ||
STLcomp_trn <- STLcomp[-c(((length(data)-stepahead)+1):length(data)),] | ||
Fcast_STLcomp <- NULL | ||
for (STLcomp in 2:ncol(STLcomp_trn)) { | ||
Indcomp <- NULL | ||
Indcomp <- STLcomp_trn[ ,STLcomp] | ||
stlELMFit <- nnfor::elm(as.ts(Indcomp)) | ||
stlELM_fcast=forecast::forecast(stlELMFit, h=stepahead) | ||
stlELM_fcast_Mean=stlELM_fcast$mean | ||
Fcast_STLcomp <- cbind(Fcast_STLcomp, as.matrix(stlELM_fcast_Mean)) | ||
} | ||
FinalstlELM_fcast <- ts(rowSums(Fcast_STLcomp, na.rm = T)) | ||
MAE_stlELM=mean(abs(data_test - FinalstlELM_fcast)) | ||
MAPE_stlELM=mean(abs(data_test - FinalstlELM_fcast)/data_test) | ||
rmse_stlELM=sqrt(mean((data_test - FinalstlELM_fcast)^2)) | ||
return(list(data_test=data_test, STLcomp_forecast=Fcast_STLcomp, | ||
FinalSTLcomp_forecast=FinalstlELM_fcast, MAE_stlELM=MAE_stlELM, | ||
MAPE_stlELM=MAPE_stlELM, rmse_stlELM=rmse_stlELM, | ||
STLcomp_plots=STLcomp_plots)) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
\name{Data_potato} | ||
\alias{Data_potato} | ||
\docType{data} | ||
\title{ | ||
Normalized Monthly Average Potato Price of India | ||
} | ||
\description{ | ||
Normalized Monthly Average Potato Price of India from January 2010 to July 2020. | ||
} | ||
\usage{data("Data_potato")} | ||
\format{ | ||
A time series data with 127 observations. | ||
\describe{ | ||
\item{\code{price}}{a time series} | ||
} | ||
} | ||
\details{ | ||
Dataset contains 127 observations of normalized monthly average potato price of India. It is obtained from World Bank "Pink sheet". | ||
} | ||
\source{ | ||
Department of Consumer Affairs, Govt. of India | ||
} | ||
\references{ | ||
https://consumeraffairs.nic.in/ | ||
} | ||
\examples{ | ||
data(Data_potato) | ||
} | ||
\keyword{datasets} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
\name{STLELM} | ||
\alias{STLELM} | ||
\title{ | ||
STL Based ELM Forecasting Model | ||
} | ||
\description{ | ||
The STLELM function forecasts a time series using a hybrid model made of a decomposition technique called seasonal trend decomposition based on loess (STL) and a neural network based forecasting technique called extreme learning machine (ELM). The function further computes the values of different forecasting evaluation criteria. | ||
} | ||
\usage{ | ||
STLELM(data, stepahead=10) | ||
} | ||
|
||
\arguments{ | ||
\item{data}{ | ||
Input univariate time series (ts) data. | ||
} | ||
\item{stepahead}{ | ||
The forecast horizon. | ||
} | ||
} | ||
\details{ | ||
This function decomposes a nonlinear, nonstationary and seasonal time series into trend-cycle, seasonal and remainder component using STL (Cleveland et al., 1990). Extreme learning machine (ELM) is used to forecast these components individually (Huang et al., 2006, Xiong et al. 2018). Finally, the prediction results of all the three components are aggregated to formulate an ensemble output for the input time series. | ||
} | ||
\value{ | ||
\item{data_test }{Testing set used to measure the out of sample performance.} | ||
\item{STLcomp_forecast }{Forecasted value of all individual components.} | ||
\item{FinalstlELM_forecast }{Final forecasted value of the stlELM model. It is obtained by combining the forecasted value of all individual components.} | ||
\item{MAE_stlELM }{Mean Absolute Error (MAE) for stlELM model.} | ||
\item{SMAPE_stlELM }{Mean Absolute Percentage Error (MAPE) for stlELM model.} | ||
\item{RMSE_stlELM }{Root Mean Square Error (RMSE) for stlELM model.} | ||
} | ||
\references{ | ||
Cleveland, R.B., Cleveland, W.S., McRae, J.E., Terpenning, I. (1990). STL: A seasonal-trend decomposition procedure based on loess, Journal of Official Statistics, 6, 3--73. | ||
Huang, G., Zhu, Q., Siew, C. (2006). Extreme learning machine: theory and applications, Neurocomputing,70, 489--501. | ||
Xiong, T., Li, C., Bao, Y. (2018). Seasonal forecasting of agricultural commodity price using a hybrid STL and ELM method: Evidence from the vegetable market in China. Neurocomputing 275, 2831--2844 | ||
} | ||
|
||
\examples{ | ||
\donttest{ | ||
data("Data_potato") | ||
STLELM(Data_potato) | ||
} | ||
} | ||
\keyword{ stl } |