I’m pleased to announce that version 0.1.1 of TSstudio is available now on CRAN and Github.
The TSstudio package provides a set of tools for time series analysis, supporting “ts”, “mts”, “zoo”, and “xts” objects. It includes interactive visualizations tools based on the plotly package for descriptive time series analysis. In addition for the visualization tools, the package provides a set of utility functions for preprocessing time series objects.
A detailed examples of the package’s key functions is available here.
All the visualization tools in the package, support multiple time series objects (“ts”, “mts”, “zoo”, “xts” and model output from the forecast package) without the need of any data transformation. They include the following plots:
Besides the visualization functions, there are set of utility functions:
Note: most of the current functions support only monthly and quarterly frequencies, the plan is to expend the ability to lower frequencies such as daily and hourly in the next release
The main emphasis of the package is simplifying the process, by getting maximum results with minimum effort (and code…). Here are some examples of the key functions of the package with the USgas data set (the US natural gas consumption between 2000 and 2017):
install.packages("TSstudio")
The ts_plot() designed to plot any univariate or multivariate “ts”, “zoo” and “xts” objects:
library(TSstudio)
data(USgas)
ts_plot(USgas)
In addition, this function has controlled parameters that allow the user to add to the plot additional features such as titles, color, line type and width as well as adding a slider. For example, lets add titles for the previous plot and slider:
ts_plot(USgas,
title = "US Natural Gas Consumption 2000 - 2017",
Xtitle = "Source: U.S. Bureau of Transportation Statistics",
Ytitle = "Billion Cubic Feet",
slider = TRUE
)
The package provides a variety of tools for seasonality analysis, which includes cycle box plots, seasonal heatmap, surface and polar plots.
The main function, the ts_seasonal(), has four modes:
The “all” option is my favorite mode for this plot as each plot may provide partial information about the seasonality and the trend of the series. Combining all three plots together allows to connect all the dots and see the full picture. For example, by looking at the basic time series plot above of the USgas dataset, we can see a clear seasonal pattern (which makes sense), however, the seasonal plot reveal additional insights:
ts_seasonal(USgas, type = "all")
The heatmap is another way to look at seasonality. In the output of the ts_heatmap() function below you can notice:
ts_heatmap(USgas)
Another way to look at correlation of a time series data, beside the acf and pacf functions (which are also available in plotly format with the ts_acf() and ts_pacf() functions), is the use of lag plots. The ts_lags() function provides a set of plots of the current series with its previous lags. Setting the number of lags to 15, it is fairly easy to see that the 12 lag is highly correlated with the current series:
ts_lags(USgas, lag.max = 15)
While the main focus in the current and previous releases was on descriptive analysis tools, the next release of the package will focus on tools for predictive analysis such as cross validation and training methods for time series forecasting, automation of forecasting and model selection.