sluacf function

Computes autocorrelations (ACF) for a time series

Computes autocorrelations (ACF) for a time series

This function computes autocorrelations for various lags of a time series.

sluacf(series, lags = 1, maxlag = NULL, ndiff = 0, sdiff = 0)

Arguments

  • series: a time series object
  • lags: a multiplier for the lag. For example, use lag=12 for monthly data.
  • maxlag: maximum number of lags to compute
  • ndiff: number of regular differences to take before finding the ACF
  • sdiff: number of seasonal differences (with seasonal period specified by lags)

Returns

An object of class "acf"

Details

This is is a wrapper for the acf function which allows for specifying regular (ndiff) and seasonal (sdiff) differences. The lags parameter specifies the seasonal lag and adjusts the default lags in the returned acf object to go 1, 2, ..., rather than showing fractional lags (for example, 1/12, 2/12, ... for monthly data). The lag 0 autocorrelation is set to NA (rather than 1) so that it won;t show when acf is plotted.

Examples

data(SeaIce) ExtentY=ts(SeaIce$Extent,start=1979) sluacf(ExtentY) sluacf(ExtentY, maxlag=8,ndiff=1) data(Inflation) CPIts=ts(Inflation$CPI,start=c(2009,1),frequency=12) CPIacf=sluacf(CPIts,maxlag=36,lags=12) plot(CPIacf,lwd=2,ci.type="ma",xlim=c(1,36),xaxp=c(0,36,6),main="")
  • Maintainer: Robin Lock
  • License: GPL-3
  • Last published: 2019-01-04