ADDline: ‘ADDline’

Description Usage Arguments Details Value Author(s) Examples

View source: R/ADDline.R

Description

create a list of line data based on ARIMA(X) predicted result or ts function result(i.e. time series data)

Usage

1
2
ADDline(ARIMAmodel = NULL, XREG = NULL, TS = NULL, linetype = "TS",
  Name = NULL)

Arguments

ARIMAmodel

ARIMA model created by function auto.arima()

XREG

if using ARIMAX model, put in the regularized X matrix

TS

data created by ts() function

linetype

"TS" for time series data, "ARIMA" for ARIMA(X) predicted data

Name

title for this line

Details

This function ADDline is used to conduct a data transformation. It can take in original time-series data generated by function ts or fitted ARIMA(X) model generated by function auto.arima then take out four elements from those result to create a list which contains content that can be put in function add_lines or add_trace. So that we could add new lines in our plotly plot more easily.

Value

a list contains 4 elements:

X

data put in parameter "x" of plot_ly function

TEXT

rename the lable of variable X

Y

data put in parameter "y" of plot_ly function

NAME

title of the new line

Author(s)

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

Examples

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

#Firstly create a base plotly plot
Tempplot<-TSplot(48,modArima_train,as.matrix(X_test),title_size = 8,
ts_original = "Original time series",ts_forecast = "Predicted time series")

# Generate a new line with ADDline function
newline<-ADDline(TS = MCSI_Data_monthAvg_ts_Y_test,linetype = "TS",Name = "Original Result")

## Put the new line into our plot
Tempplot%>%
  add_lines(x=newline$X,text=newline$TEXT,y=newline$Y,name=newline$NAME,line=list(color="grey"))

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