TSplot: 'TSplot'

Description Usage Arguments Details Value Author(s) Examples

View source: R/TSplot.R

Description

Plotly method working on time series analysis. Work only for month & year dataset(i.e. dataset that can satisfy the format required by function as.yearmon from package zoo)

Usage

1
2
3
4
TSplot(origin_t, ARIMAmodel, XREG = NULL, NEWtitle = "Result",
  Ylab = "Value", Xlab = "Time(Month/Year)",
  ts_original = "original time series",
  ts_forecast = "forecasted time series", title_size = 10)

Arguments

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 auto.arima()

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

ts_original

label for original time series line

ts_forecast

label for forecasted time series line

title_size

size of the title

Details

The function TSplot 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.

Value

a plot result created by plot_ly() function

Author(s)

SOCR team <http://socr.umich.edu/people/>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require(forecast)
require(zoo)
require(plotly)

# Creating time series data
MCSI_Data_monthAvg_ts_Y <- ts(Y, start=c(1978,1), end=c(2018, 12), frequency = 12)

# Applying ARIMAX model
modArima <- auto.arima(MCSI_Data_monthAvg_ts_Y, xreg=X)

# Creating plot_ly results
## 48 means that there will be 48 periods from the original
## time series dataset that is included in the plot result.
## You could also change this to "all" to see all original dataset in a single plot.
TSplot(48,modArima,X_new,title_size = 8,ts_original = "Original time series",
ts_forecast = "Predicted time series")

TSplotly documentation built on Aug. 2, 2019, 5:04 p.m.