estimateDelay {hydromad}  R Documentation 
Use crosscorrelation to estimate the delay between an input time series and (rises in) the corresponding output time series.
estimateDelay(DATA = data.frame(U=, Q=), rises = TRUE, lag.max = hydromad.getOption("max.delay"), n.estimates = 1, negative.ok = FALSE, na.action = na.exclude, plot = FALSE, main = NULL, ...)
DATA 
a

rises 
use only rises in the output to estimate delay. 
lag.max 
largest delay (in time steps) to consider. 
n.estimates 
number of estimates of delay to produce. 
negative.ok 
to allow negative delay times to be considered. 
na.action 
handler for missing values.
The default removes leading and trailing NAs only.
Use 
plot 
plot the crosscorrelation function. 
main 
title for plot. 
... 
further arguments passed to 
The estimated delay is the one maximising the crosscorrelation function.
The estimated delay as an integer number of time steps.
If n.estimates > 1
, that number of integer delays, ordered by the CCF.
Felix Andrews felix@nfrac.org
set.seed(1) x < ts(pmax(0, rgamma(200, shape=0.1, scale=20)  5)) ## simulate error as multiplicative uniform random y < x * runif(200, min=0.5, max=1.5) ## and resample 10 percent of time steps ii < sample(seq_along(y), 20) y[ii] < rev(y[ii]) ## apply recursive filter and lag y < filter(y, 0.8, method="r") y < lag(y, 2) # true delay is 2 plot(ts.union(y,x)) ## based on cross correlation function: estimateDelay(ts.union(y,x), rises = FALSE, plot = TRUE) ## based on ccf with flow rises only: estimateDelay(ts.union(y,x), plot = TRUE)