Description Usage Arguments Details Value Author(s) Examples
Plotly method working on time series analysis. This is a more general function that can work on any fitted ARIMA(X) model with any time format. Also, a list of time series data can be applied into this function so that new time lines can be directly drawn in the plot without referring to the result of ADDline function.
1 2 3 4 5 6 |
origin_t |
Number of periods of original time series data you wish to include in the plot write all if all periods should be included |
ARIMAmodel |
ARIMA model created by function |
XREG |
if using ARIMAX model, put in the regularized X matrix |
NEWtitle |
title for this plot |
Ylab |
label of Y axis |
Xlab |
label of X axis |
plot_labels |
To include a specific labels for each time point of all training time series data and
predicted ARIMA(X) result. A vector should be applied to this parameter that has the same length of chosen
periods of training time series data (i.e. parameter |
ts_original |
label for original time series line |
ts_forecast |
label for forecasted time series line |
title_size |
size of the title |
ts_list |
applying this function can help you draw more time lines into the original plot. A list should
be applied to this parameter which contains all extra time series data that you wish to draw on the original
plot. Each element on this list should be created by function |
ts_labels |
when drawing extra time lines with parameter |
ts_names |
Creating labels for each extra time lines you draw. Labels will appear on the legend of the plot. |
COLO |
Specifying colors for each new lines that is drawn. |
The function TSplot_gen
is based on package plotly
. It applies plot_ly
function to create
interactive plot for time-series analysis result. It requires a fitted model by function auto.arima
.
If you are fitting an ARIMA model with external regressors (i.e. Xreg
), then you must put inside the
external regressors again.
a plot result created by plot_ly() function
SOCR team <http://socr.umich.edu/people/>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Creating time labels
require(zoo)
require(forecast)
require(plotly)
tl1<-as.yearmon(time(modArima_train$x))[(length(modArima_train$x)-48+1):length(modArima_train$x)]
tl2<-as.yearmon(time(forecast(modArima_train,xreg = as.matrix(X_test))$mean))
tl<-as.character(c(tl1,tl2))
# Creating list and other information for new lines
TSlist<-list(MCSI_Data_monthAvg_ts_Y_test)
TSlabel<-list(as.character(as.yearmon(time(TSlist[[1]]))))
TSname<-c("Original result")
# Put them into related parameters
TSplot_gen(48,modArima_train,as.matrix(X_test),title_size = 8,ts_original = "Original time series",
ts_forecast = "Predicted time series",plot_labels = tl, #labels of original plot
ts_list = TSlist,ts_names = TSname,ts_labels = TSlabel,COLO = "black")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.