Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I have two time series S, and T. they have the same frequency and the same length.

I would like to calculate (using R), the correlation between this pair (i.e. S and T), and also be able to calculate the significance of the correlation), so I can determine whether the correlation is due to chance or not.

I would like to do this in R, and am looking for pointers/skeletal framework to get me started.

share|improve this question
2  
Are the time series both stationnary ? www.econ.ohio-state.edu/dejong/note1.pdf – user603 Oct 10 '10 at 11:54
@kwak: No, the series are both NOT stationary. – morpheous Oct 12 '10 at 17:49
Here: stats.stackexchange.com/questions/1881/… I was proposing a Monte Carlo approach to determine confidence limits. The idea was to do this for two point processes, but I guess it could be easily adapted for your situation. – nico Oct 13 '10 at 10:53

2 Answers

How do you define correlation for non stationary time series? Do you plan to take the correlation of the diff or these time series? If not, I suggest you look for cointegration rather than correlation (cf Granger etc...)

share|improve this answer

You can use the ccf function to get the cross-correlation, but this will only give you a plot. If the estimated cross correlations fall outside the dash red line, then you can conclude that there is a statistically significant cross-correlation. But I do not know of a package with a formally encapsulated test. Example from ccf doc:

require(graphics)

## Example from Venables & Ripley (Provided in  CCF help file)
ccf(mdeaths, fdeaths, ylab = "cross-correlation")

Note, that the question of significance test is also discussed here.

share|improve this answer
Other posters have noted that stationarity is important here. If both series have a linear upwards trend (one kind of nonstationarity), they will be correlated - but all the correlation may be due to the common trend, which may or may not be what we are interested in. – Stephan Kolassa Oct 21 '10 at 13:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.