R/acf.R

Defines functions acf acf.ts acf.default acf.xts pacf.xts check.xts.stats

Documented in acf acf.default acf.ts acf.xts pacf.xts

acf <- function(x, ...) UseMethod("acf")

# Why do we need this? Shouldn't this dispatch to acf.default?
acf.ts <- function(x, ...) stats::acf(x, ...)

acf.default <- function(x, ...) stats::acf(x, ...)

acf.xts <- function(x, ...){
  check.xts.stats(x)
  
  acf(coredata(x[,1, drop = FALSE]), ...)
}

pacf.xts <- function(x, lag.max, plot, na.action, ...){
  check.xts.stats(x)
  
  stats::pacf.default(coredata(x[,1, drop = FALSE]), lag.max, plot, na.action, ...)
}

check.xts.stats <- function(x){
  if(!is.regular(x)) warning("Input series is not regular -- treating as such, but results may be unreliable.")
  
  if(NCOL(x) > 1L) warning("Using only the first column.")
}
joshuaulrich/xtsExtra documentation built on May 19, 2019, 9:40 p.m.