The TSstudio package provides a set of interactive visualization tools for time series analysis supporting ts, mts, zoo and xts objects. That includes several visualization functions such as forecasting model performance (forecasted vs. actual), time series interactive plots (single and multiple series) and seasonality plots utilizing the visualization applications of the Plotly package. First version available on CRAN or Github.
Install the stable version from CRAN:
install.packages("TSstudio")or install the development version from Github:
# install.packages("devtools")
devtools::install_github("RamiKrispin/TSstudio")library(TSstudio)
library(forecast)
# Load the AirPassengers dataset
data("AirPassengers")
# set the forecast horizon for 12 months
h <- 12
# Split the data into training and testing sets (leaving the last 12 months for testing)
train <- window(AirPassengers,
start = time(AirPassengers)[1],
end = time(AirPassengers)[length(AirPassengers) - h])
test <- window(AirPassengers,
start = time(AirPassengers)[length(AirPassengers) - h + 1],
end = time(AirPassengers)[length(AirPassengers)])
# Using auto.arima to train and forecast the last 12 months on the series
fc <- forecast(auto.arima(train, lambda = BoxCox.lambda(train)), h = h)
# Plotting the series vs the fitted and the forecasted
fortest_ly(actual = AirPassengers, forecast.obj = fc, train = train, test = test)seasonal_ly(AirPassengers)# Simple plot
ts.plot_ly(AirPassengers)# Adding slider and markers, changing the color to green
ts.plot_ly(AirPassengers,
slider = TRUE,
line.mode = "lines+markers",
color = "green",
width = 2)#plotting the acf and the pacf estimation
# setting the lags to 60 and the level of significant to 0.01
acf_ly(AirPassengers, lag.max = 60, ci = 0.99)pacf_ly(AirPassengers, lag.max = 60, ci = 0.99)