ccf2: Cross Correlation

ccf2R Documentation

Cross Correlation

Description

Calculates and plots the sample CCF of two time series.

Usage

ccf2(x, y, max.lag = NULL, main = NULL, ylab = "CCF", plot = TRUE,
         na.action = na.pass, type = c("correlation", "covariance"), ...)

Arguments

x, y

univariate time series

max.lag

maximum lag for which to calculate the CCF

main

plot title - if NULL, uses x and y names

ylab

vertical axis label; default is 'CCF'

plot

if TRUE (default) a graphic is produced and the values are returned invisibly. Otherwise, the values are returned.

na.action

how to handle missing values; default is na.pass

type

default is cross-correlation; an option is cross-covariance

...

additional arguments passed to tsplot

Details

This will produce a graphic of the sample corr[x(t+lag), y(t)] from -max.lag to max.lag. Also, the (rounded) values of the CCF are returned invisibly unless plot=FALSE. Similar details apply to the cross-covariance.

Author(s)

D.S. Stoffer

References

You can find demonstrations of astsa capabilities at FUN WITH ASTSA.

The most recent version of the package can be found at https://github.com/nickpoison/astsa/.

In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.

The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.

Examples

ccf2(soi, rec, plot=FALSE)  # now you see it
ccf2(soi, rec)              # now you don't

# happy birthday mom
ccf2(soi, rec, col=rainbow(36, v=.8), lwd=4, gg=TRUE)

astsa documentation built on Jan. 10, 2023, 1:11 a.m.