Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sluacf

Computes autocorrelations (ACF) for a time series


Description

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

Usage

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)

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.

Value

An object of class "acf"

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="")

Stat2Data

Datasets for Stat2

v2.0.0
GPL-3
Authors
Ann Cannon, George Cobb, Bradley Hartlaub, Julie Legler, Robin Lock, Thomas Moore, Allan Rossman, Jeffrey Witmer
Initial release
2018-12-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.