Solved – How to investigate how long it takes one variable to affect another in a time series

time series

I am a total newbie when it comes to time series, so it is quite possible this question is duplicated somewhere else, only that I cannot find it because I don't know what this feature is called.

My data:

I have weekly measurements of a variable "change in rank". I also have weekly measurements of another variable loosely described as "change in goodness". I believe that "change in rank" is dependent on "change in goodness", but I also believe that whenever "goodness" improves, it takes some time before rank improves. A simplistic representation of the data would look like this:

change_in_rank = c(0,0,0,0,-10,0,0,0)
change_in_goodness = c(0,2,0,0,0,0,0,0)

where this constructed example shows that a improvement of 2 in goodness took 3 time steps to lead to an improvement in rank.

My question:

What analysis method do I use to detect whether such a relationship actually exists between "change in goodness" and "change in rank", and if such a relationship exists, how do I find out how long it takes for a change in "goodness" to flow on to a change in rank.

The motivation behind this question:

Some additional, non necessary background: it is claimed that search engine optimisation takes time to affect your site's ranking in Google. E.g.:

"Why does SEO take so long?"

I am trying to find a statistical way of calculating how long it takes for a change in a site to actually reflect in the site's Google ranking.

More motivation:

Slightly different type of data but similar question…

"How long does it take before a change in diet starts to take effect?"

Best Answer

Try looking at cross-correlations between the two series:
correlate series 1 with series 2;
correlate series 1 with series 2 lagged by 1 period;
correlate series 1 with series 2 lagged by 2 periods;
etc.
Explore as many lags as can reasonably be expected to be plausible in the context you are in. Also, depending on the context of the application, you may need to look at lagged series 1 against (non-lagged) series 2.
Note which lag gives the highest absolute correlation - this will be a rough estimate of the "true" lag.

It is comfortable to inspect the cross-correlations visually. In R, you may use function ccf(.) to obtain and plot the correlogram.