Learn R Programming

ggfortify (version 0.4.17)

fortify.tsmodel: Convert time series models (like AR, ARIMA) to data.frame

Description

Convert time series models (like AR, ARIMA) to data.frame

Usage

# S3 method for tsmodel
fortify(
  model,
  data = NULL,
  predict = NULL,
  is.date = NULL,
  ts.connect = TRUE,
  ...
)

Value

data.frame

Arguments

model

Time series model instance

data

original dataset, needed for stats::ar, stats::Arima

predict

Predicted stats::ts If not provided, try to retrieve from current environment using variable name.

is.date

Logical frag indicates whether the stats::ts is date or not. If not provided, regard the input as date when the frequency is 4 or 12.

ts.connect

Logical frag indicates whether connects original time-series and predicted values

...

other arguments passed to methods

Examples

Run this code
if (FALSE) {
fortify(stats::ar(AirPassengers))
fortify(stats::arima(UKgas))
fortify(stats::arima(UKgas), data = UKgas, is.date = TRUE)
fortify(forecast::auto.arima(austres))
fortify(forecast::arfima(AirPassengers))
fortify(forecast::nnetar(UKgas))
fortify(stats::HoltWinters(USAccDeaths))

data(LPP2005REC, package = 'timeSeries')
x = timeSeries::as.timeSeries(LPP2005REC)
d.Garch = fGarch::garchFit(LPP40 ~ garch(1, 1), data = 100 * x, trace = FALSE)
fortify(d.Garch)
}

Run the code above in your browser using DataLab