- Notifications
You must be signed in to change notification settings - Fork65
Tools for time series analysis and forecasting
License
Unknown, MIT licenses found
Licenses found
Unknown
LICENSEMIT
LICENSE.mdNotificationsYou must be signed in to change notification settings
RamiKrispin/TSstudio
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
TheTSstudio package provides a set of tools descriptive and predictive analysis of time series data. That includes utility functions for preprocessing time series data, interactive visualization functions based on theplotly package engine, and set of tools for training and evaluating time series forecasting models from theforecast,forecastHybrid, andbsts packages.
More information available on the packagevignettes.
Install the stable version fromCRAN:
install.packages("TSstudio")or install the development version fromGithub:
# install.packages("devtools")devtools::install_github("RamiKrispin/TSstudio")
library(TSstudio)data(USgas)# Ploting time series objectts_plot(USgas,title="US Monthly Natural Gas Consumption",Ytitle="Billion Cubic Feet")
# Seasonal plotts_seasonal(USgas,type="all")
# Heatmap plotts_heatmap(USgas)
# ACF and PACF plotsts_cor(USgas,lag.max=60)
# Lags plotts_lags(USgas,lags=1:12)
# Seasonal lags plotts_lags(USgas,lags= c(12,24,36,48))
# Forecasting applications# Setting training and testing partitionsUSgas_s<- ts_split(ts.obj=USgas,sample.out=12)train<-USgas_s$traintest<-USgas_s$test# Forecasting with auto.arimalibrary(forecast)md<- auto.arima(train)fc<- forecast(md,h=12)# Plotting actual vs. fitted and forecastedtest_forecast(actual=USgas,forecast.obj=fc,test=test)
# Plotting the forecastplot_forecast(fc)
# Run horse race between multiple modelsmethods<-list(ets1=list(method="ets",method_arg=list(opt.crit="lik"),notes="ETS model with opt.crit = lik"),ets2=list(method="ets",method_arg=list(opt.crit="amse"),notes="ETS model with opt.crit = amse"),arima1=list(method="arima",method_arg=list(order= c(2,1,0)),notes="ARIMA(2,1,0)"),arima2=list(method="arima",method_arg=list(order= c(2,1,2),seasonal=list(order= c(1,1,1))),notes="SARIMA(2,1,2)(1,1,1)"),hw=list(method="HoltWinters",method_arg=NULL,notes="HoltWinters Model"),tslm=list(method="tslm",method_arg=list(formula=input~trend+season),notes="tslm model with trend and seasonal components"))# Training the models with backtestingmd<- train_model(input=USgas,methods=methods,train_method=list(partitions=6,sample.out=12,space=3),horizon=12,error="MAPE")# A tibble: 6 x 7model_idmodelnotesavg_mapeavg_rmse`avg_coverage_80%``avg_coverage_95%`<chr><chr><chr><dbl><dbl><dbl><dbl>1arima2arima SARIMA(2,1,2)(1,1,1)0.0557167.0.5830.8062hwHoltWintersHoltWintersModel0.0563163.0.7360.8893ets1etsETSmodelwithopt.crit=lik0.0611172.0.6810.9034ets2etsETSmodelwithopt.crit=amse0.0666186.0.4580.8335tslmtslmtslmmodelwithtrendandseasonalcomponents0.0767220.0.4170.6676arima1arima ARIMA(2,1,0)0.188598.0.8750.958
# Plot the performance of the different models on the testing partitionsplot_model(md)
# Holt-Winters tunning parameters with grid searchhw_grid<- ts_grid(USgas,model="HoltWinters",periods=6,window_space=6,window_test=12,hyper_params=list(alpha= seq(0,1,0.1),beta= seq(0,1,0.1),gamma= seq(0,1,0.1))) plot_grid(hw_grid,type="3D")
About
Tools for time series analysis and forecasting
Topics
Resources
License
Unknown, MIT licenses found
Licenses found
Unknown
LICENSEMIT
LICENSE.mdUh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.










