# How can I estimate the phase difference between two periodic time-series?

I have 2 daily time-series, each 6 years long. While noisy, they are both clearly periodic (with a frequency of ~1 year), but appear to be out of phase. I would like to estimate the phase difference between these time-series.

I've considered fitting curves of the form $a\sin(\frac{2\pi}{365}t - b)$ to each time-series and just comparing the two different values for b, but I suspect there are more elegant (and rigourous!) methods for doing this (perhaps using Fourier transforms?). I would also prefer to have some kind of idea of the uncertainty in my phase difference estimate, if possible.

Update: The shaded regions are 95% CIs.

Sample crosscorrelation between the two time-series: • A plot would be interesting and, potentially, helpful. How close to sinusoidal are the two series? – cardinal Jan 13 '12 at 0:20
• Hi Cardinal. I have a plot, but need 10 reputation points to upload it, unfortunately! I'll do so as soon as that happens. The time-series are related to temperature and vegetation growth, so follow pretty consistent seasonal behaviour, although it is noisy. Without having seen the plots, do you have any thoughts on how to approach this problem? – Paul Keating Jan 13 '12 at 1:21
• Yes. I have a couple ideas, but I'd like to see a plot first to have a better idea of what you're dealing with. if you upload your plot to imgur and edit the post to provide the link, then I can edit it yet again to put the image inline. The rep will come soon enough. Welcome to the site. – cardinal Jan 13 '12 at 1:26
• For some reason, maybe my currently-crippled machine, I can't click on a link or see a plot. – jbowman Jan 13 '12 at 1:54
• As a very first quick-and-dirty check, have you tried plotting the sample crosscorrelation between the two series and finding the peak? There are some curious discontinuities, e.g., in the first series sometime around Feb 2005 or so. – cardinal Jan 13 '12 at 2:00

This is the very problem cross-spectral analysis is good for. Next you have an example of code using consumer prices (in differences) and price of oil, and estimating the coherency (roughly, a squared correlation coefficient broken by frequency band) and phase (lag in radians, again by frequency band).

Crudo <- dget(file="Crudo.dge")
IPC <- dget(file="ipc2001.dge")[,1]
dIPC <- diff(IPC)
datos <- ts.union(dIPC,
Crudo)
datos <- window(datos,
start=c(1979,1),
end=c(2002,1))
sp <- spectrum(datos,
main="Petróleo e IPC",
spans=rep(3,5))
par(mfrow=c(2,1))
plot(sp,plot.type="coh")
plot(sp,plot.type="phase")


These are the graphs produced by the last instructions. You can probably adapt this to your setup. 