Skip to contents

Compute and visualize the partial autocorrelation function of a time series.

Usage

PACF(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 PACF. 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:

pacf

An object of class "acf" with type "partial", including `white95ci`.

plot

A ggplot2 object showing the partial autocorrelation function.

Otherwise, returns the PACF object only.