# Generate dataset with known lag and recover this lag --------------#'
lag <- 3
n <- 156
start_year <- 2005
frequency <- 12
trend_function <- function(x) x^2
x <- seq(-3,3, length.out = n)
y1 <- ts(trend_function(x),start = start_year, freq = frequency)
y2 <- stats::lag(y1, k = lag)
# Recover lag
estimate_lag(y1,y2, possible_lags = -36:36,
method = "rank",leave_off = 0, spline = FALSE)
Run the code above in your browser using DataLab