acf_max: Maximum ACF, PACF and CCF

Description Usage Arguments Examples

View source: R/acf_max.R

Description

Find lag that maximizes correlation

Usage

1
2
3
4
5
6
7
8
acf_max(x, ..., plot = FALSE, show = plot, ci = 0.95, ma.ci = TRUE,
  max.type = c("pos", "neg", "abs"), most.signif = FALSE)

pacf_max(x, ..., plot = FALSE, show = plot, ci = 0.95,
  max.type = c("pos", "neg", "abs"))

ccf_max(x, y, ..., plot = FALSE, show = plot, ci = 0.95,
  max.type = c("pos", "neg", "abs"))

Arguments

x, y

univariate numeric vector or time series

...

further arguments passed to acf, pacf, ccf

plot

logical; return a plot

show

indicate on the plot the maximum correlation

ci

confidence interval used, by default 95%

ma.ci

should the confidence limits assume an MA input (TRUE, the default), or white noise as is default for plot.acf?

max.type

what maximum should be returned, the positive (default), negative, or absolute maximum?

most.signif

should the most significant correlation be returned. Only applicable if ma.ci=TRUE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
x <- c(5, 5, 3, 6, 3, 6, 9, 6, 3, 1, 3, 2, 8, 9, 4, 3, 6, 6,
       6, 7, 5, 2, 5, 1, 5, 5, 0, 3, 7, 3, 6, 6, 2, 2, 6, 5)
y <- c(8, 9, 7, 5, 3, 5, 6, 9, 6, 3, 4, 5, 9, 7, 8, 5, 5, 7, 
       4, 7, 7, 2, 5, 6, 5, 7, 5, 3, 5, 6, 7, 0, 5, 3, 8, 4)

acf_max(x, plot=TRUE, max.type="abs")
acf_max(x, max.type="neg")
acf_max(x, max.type="neg", most.signif=TRUE)

pacf_max(x, plot=TRUE)
pacf_max(x, max.type="abs")

ccf_max(x, y, plot=TRUE)
ccf_max(x, y, max.type="neg")

# Same plot
plot(acf(x, plot=FALSE), ci.type="ma")
acf_max(x, plot=TRUE)


acf_max(x, ci=0.99, plot=TRUE)
ccf_max(x, y, ci=0, max.type="pos", plot=TRUE)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.