Tools for time series analysis and forecasting
Switch branches/tags
Clone or download

README.md

TSstudio

The TSstudio package provides a set of functions for time series analysis. That includes interactive data visualization tools based on the plotly package engine, supporting multiple time series objects such as ts, xts, and zoo. In addition, the package provides a set of utility functions for preprocessing time series data, and as well backtesting applications for forecasting models from the forecast, forecastHybrid and bsts packages.

Installation

Install the stable version from CRAN:

install.packages("TSstudio")

or install the development version from Github:

# install.packages("devtools")
devtools::install_github("RamiKrispin/TSstudio")

Usage

library(TSstudio)
data(USgas)

# Ploting time series object
ts_plot(USgas)

# Seasonal plot
ts_seasonal(USgas, type = "all")

# Lags plot
ts_lags(USgas, lags = 1:12)

# Seasonal lags plot
ts_lags(USgas, lags = c(12, 24, 36, 48))

# Heatmap plot
ts_heatmap(USgas)

# Forecasting applications
# Setting training and testing partitions
USgas_s <- ts_split(ts.obj = USgas, sample.out = 12)
train <- USgas_s$train
test <- USgas_s$test

# Forecasting with auto.arima
library(forecast)
md <- auto.arima(train)
fc <- forecast(md, h = 12)

# Plotting actual vs. fitted and forecasted
test_forecast(actual = USgas, forecast.obj = fc, test = test)

# Plotting the forecast 
plot_forecast(fc)

# Forecasting with backtesting 
USgas_backtesting <- ts_backtesting(USgas, 
                                    models = "abehntw", 
                                    periods = 6, 
                                    error = "RMSE", 
                                    window_size = 12, 
                                    h = 12)