R: ggplot (Partial) Autocorrelation and Cross-Correlation...

autoplot.acf {forecast} | R Documentation

## ggplot (Partial) Autocorrelation and Cross-Correlation Function Estimation

### Description

Produces a ggplot object of their equivelent Acf, Pacf, Ccf, taperedacf and taperedpacf functions.

If `autoplot` is given an `acf` or `mpacf` function, then an appropriate ggplot object will be created.

### Usage

    ## S3 method for class 'acf'
    autoplot(object, ci=0.95, ...)
    ## S3 method for class 'mpacf'
    autoplot(object, ...)

    ggAcf(x, lag.max = NULL,
        type = c("correlation", "covariance", "partial"),
        plot = TRUE, na.action = na.contiguous, demean=TRUE, ...)
    ggPacf(x, lag.max = NULL,
        plot = TRUE, na.action = na.contiguous, demean=TRUE, ...)
    ggCcf(x, y, lag.max=NULL, type=c("correlation","covariance"),
        plot=TRUE, na.action=na.contiguous, ...)
    ggtaperedacf(x, lag.max=NULL, type=c("correlation", "partial"),
       plot=TRUE, calc.ci=TRUE, level=95, nsim=100, ...)
    ggtaperedpacf(x, ...)

### Arguments

`object` | Object of class “acf”.
`x` | a univariate or multivariate (not Ccf) numeric time series object or a numeric vector or matrix.
`y` | a univariate numeric time series object or a numeric vector.
`ci` | coverage probability for confidence interval. Plotting of the confidence interval is suppressed if ci is zero or negative.
`lag.max` | maximum lag at which to calculate the acf.
`type` | character string giving the type of acf to be computed. Allowed values are "`correlation`" (the default), "`covariance`" or "`partial`".
`plot` | logical. If `TRUE` (the default) the resulting acf, pacf or ccf is plotted.
`na.action` | function to handle missing values. Default is `na.contiguous`. Useful alternatives are `na.pass` and `na.interp`.
`demean` | Should covariances be about the sample means?
`calc.ci` | If `TRUE`, confidence intervals for the ACF/PACF estimates are calculated.
`level` | Percentage level used for the confidence intervals.
`nsim` | The number of bootstrap samples used in estimating the confidence intervals.
`...` | Other plotting parameters to affect the plot.

### Value

None. Function produces a ggplot graph.

### Author(s)

Mitchell O'Hara-Wild

### See Also

`plot.acf`, `Acf`, `acf`, `taperedacf`

### Examples

    library(ggplot2)
    ggAcf(wineind)
    wineind %>% Acf(plot=FALSE) %>% autoplot
    ## Not run:
    wineind %>% taperedacf(plot=FALSE) %>% autoplot
    ggtaperedacf(wineind)
    ggtaperedpacf(wineind)
    ## End(Not run)
    ggCcf(mdeaths, fdeaths)

[Package forecast version 8.0 Index]