CCF to show correlations between time series

2 time series, which looked like highly correlated. I want to prove it with CCF.

CCF stands for cross-correlation. In this case, I used R ccf (cross-correlation) function.

With direct CCF:

fe <- c(15,24,36,40,50,68,71,86,88,81,84,85,102,120,124,124,128,134)
ma <- c(317,331,347,353,368,382,395,411,417,418,454,460,469,480,493,503,516,522)

female <- ts(fe, frequency = 1, start=c(1950))
male <- ts(ma, frequency = 1, start=c(1950))

ccf(male, female)


Am I right here, they are highly correlated with zero lags?

With differencing:

ccf(diff(male), diff(female))


It shows no correlation.

What is the best way to find out the correlations between two time series?

p.s. This question is specifically related to CCF, from time series’ point of view and trying to understand if there's a lagging factor, not Pearson correlation.

Thannk you.

• Possible duplicate of How to use Pearson correlation correctly with time series Commented Sep 27, 2019 at 9:25
• What is CCF? It's not a common acronym, so please spell it out. Commented Sep 27, 2019 at 14:10
• @Peter Flom, CCF stands for cross-correlation. In this case, I used R ccf (cross-correlation) function. Commented Sep 27, 2019 at 14:48
• @Peter You're right: it doesn't hurt to spell out acronyms and abbreviations; and often that is necessary. But it's not always necessary to close a question that relies on one acronym whose meaning is readily inferred from the context. My test is this: if I don't know the subject but can easily guess the meaning of an acronym and confirm it with a quick Web search, it's probably safe to assume the question is understandable by those who know enough to answer it.
– whuber
Commented Sep 27, 2019 at 19:26
• steps for performing CCF explained here: stats.stackexchange.com/questions/418894/… Commented Jul 25, 2020 at 19:59

Found below in a book. Just post it here for reference in case it helps anyone.

According to Page 267, Time Series Analysis With Applications in R, Second Edition, by Jonathan D. Cryer • Kung-Sik Chan, Springer

"The specification of which lags of the covariate enter into the model is often done by inspecting the sample cross-correlation function based on the prewhitened data."

Prewhiten in R is different from Differencing. It seems Differencing shouldn't had been performed for this case.

• I think you’re misinterpreting the quote. You want to calculate the sample ccf on stationary data and you want to make sure at least one of the series is white. In this case, differencing gives you stationarity, and prewhitening may or may not be necessary. You’ll want to look at the acf of both differenced series. If neither is white then the sampling distribution of the ccf would have more error without prewhitenig. If one is white, then no prewhitening is necessary. Commented Jun 30, 2023 at 2:46
• @Taylor, thanks for looking into it. Commented Jun 30, 2023 at 2:55
• @Taylor: I'm not disagreeing with your approach, I'm just wondering where you got the information that, if one series is white, then no pre-whitening on the other series is necessary. In fact, if you know of a good general reference for this topic ( pre-whitening for ccf ), it's appreciated. I have a lot of time-series related books but I don't know of a good discussion on this topic. Thanks. Commented Nov 2, 2023 at 5:47
• Note that transfer-response (in time domain) and pre-whitening are related ( AFAIK) so a good discussion of either one is useful for me. Thanks. Commented Nov 2, 2023 at 8:57
• @Taylor : I missed this and am just seeing it now by accident so thanks for link. Commented Mar 21 at 4:45