# TASK: test lag of dependent variables
# First, one series may have a delayed response to the other series, or
# perhaps a delayed response to a common stimulus that affects both
# series.
# create 2 series with lagged correlation
x <- arima.sim(model = list(ar = 0.6), n = 100, mean = 10, sd = 5)
y <- 0.8 * lag(x, 10) + rnorm(100)
plot(cbind(x, y))
# focus on the positive axes on ccf, since y is the second parameter, and
# positive lag means y leads x, or y's change results in x's. max value
# on the positive side indicates max correlation
ccf(x, y)
# the max value on lag 10 indicates y will have greatest effect on x at 10
# values later.