[R] Cross-correlation between two time series data
Andrew Robinson
A.Robinson at ms.unimelb.edu.au
Tue Sep 5 00:06:26 CEST 2006
Jun,
If your interest is to estimate the correlation and either a
confidence interval or a test for no correlation, then you might try
to proceed as follows. This is a Monte-Carlo significance test, and a
useful strategy.
1) use ccf() to compute the cross-correlation between x and y.
2) repeat the following steps, say, 1000 times.
2a) randomly reorder the values of one of the time series, say x.
Call the randomly reordered series x'.
2b) use ccf() to compute the cross-correlation between x' and y.
Store that cross-correlation.
3) the 1000 cross-correlation estimates computed in step 2 are all
estimating cross-correlation 0, conditional on the data. A
two-tailed test then is: if the cross-correlation computed in step
1 is outside the (0.025, 0.975) quantiles of the empirical
distribution of the cross-correlations computed in step 2, then,
reject the null hypothesis that x and y are uncorrelated, with size
0.05.
I hope that this helps.
Andrew
Juni Joshi wrote:
> Hi all,
>
> I have two time series data (say x and y). I am interested to
> calculate the correlation between them and its confidence interval (or
> to test no correlation). Function cor.test(x,y) does the test of no
> correlation. But this test probably is wrong because of autocorrelated
> data.
>
> ccf() calculates the correlation between two series data. But it does
> not provide the confidence intervals of cross correlation. Is there
> any function that calculates the confidence interval of correlation
> between two time series data or performs the test of no correlation
> between two time series data.
>
> Thanks.
>
> Jun
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Andrew Robinson
Department of Mathematics and Statistics Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
Email: a.robinson at ms.unimelb.edu.au http://www.ms.unimelb.edu.au
More information about the R-help
mailing list