Compute and visualize the autocorrelation function of a time series.
Usage
ACF(ts, lag.max = length(ts), plot = TRUE, title = NULL)
Arguments
- ts
A numeric vector or time-series object.
- lag.max
An integer specifying the maximum lag to compute ACF. Default is the length of `ts`.
- plot
A logical. If TRUE (default), return a ggplot2 object for visualization.
- title
An optional string to set as plot title.
Value
If `plot = TRUE`, a list with:
- acf
An object of class "acf" with added element `white95ci` (significance threshold).
- plot
A ggplot2 object showing the autocorrelation function.
Otherwise, returns the "acf" object only.