rollccf {hydromad}  R Documentation 
Rolling crosscorrelation at given lags. Can be useful to show how the relationship between two time series changes over time, including outbyone timing errors.
rollccf(DATA = data.frame(Q = , P = ), width = list(365, 90), by = 28, lags = base.lag + c(0, 1, 1), base.lag = estimateDelay(DATA, rises = rises, plot = FALSE), rises = FALSE, na.action = na.contiguous, na.max.fraction = 1/3) ## S3 method for class 'rollccf' xyplot(x, data = NULL, ..., with.data = TRUE, type = list(c("h", "b")), type.data = "l", par.settings = simpleTheme(pch = ".", cex = 2), layout = c(1, length(x$rolls) + with.data * 2), strip = strip.default, ylim = c(0, 1), xlab = NULL, as.table = TRUE)
DATA 
a named list, data frame, time series or zoo object containing the two data series. 
width 
a list or number specifying the width of window(s), in time steps, in which to calculate cross correlations. 
by 
temporal resolution: cross correlation is calculated in windows
spaced every 
lags, base.lag 

rises 
if 
na.action 
function to handle missing data in each window (not the whole
series). This is only applied when the number of missing values is
less than Could be 
na.max.fraction 
if the proportion of missing values in the moving window exceeds
this value, the corresponding result will be 
x, data 

with.data 
if 
type, type.data 
drawing styles for the cross correlation series and input data
series. See 
par.settings, layout, strip, ylim, xlab, as.table, ... 
passed to 
This is a fairly straightforward application of
rollapply
with the ccf
function. It
may be better to do a timevarying regression between the two series.
rollccf
returns a list of class "rollccf"
, with
components:
rolls 
a list of time series of cross correlations.
One element for each value of 
data 
time series input data. 
lags, width, call 
values of arguments used. 
Felix Andrews felix@nfrac.org
ccf
,
rollapply
data(Canning) foo < rollccf(Canning) xyplot(foo)