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

fortify.tsmodel {ggfortify} | R Documentation

## 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 class 'tsmodel'
    fortify(model, data = NULL, predict = NULL,
      is.date = NULL, ts.connect = TRUE, ...)

### 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

### Value

data.frame

### Examples

    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)

[Package ggfortify version 0.4.3 Index]