[R] Cross-correlation between two time series data
Andrew Robinson
A.Robinson at ms.unimelb.edu.au
Tue Sep 5 05:04:57 CEST 2006
Hi Spencer,
you are quite right. I should have been careful to emphasize that the
strategy I suggested was intended only to produce the "test for no
correlation" clause of the "either a confidence interval or a test for
no correlation" sentence.
Cheers
Andrew
On Mon, Sep 04, 2006 at 04:00:44PM -0700, Spencer Graves wrote:
> Hi, Andrew:
>
> This will produce a "permutation distribution" for the correlation
> under the null hypothesis of zero correlation between the variables.
> This is a reasonable thing to do, and would probably produce limits more
> accurate than the dashed red lines on the 'ccf' plot. However, they
> would NOT be confidence interval(s).
>
> For a confidence interval on cross correlation, you'd have to
> hypothesize some cross correlation pattern between x and y, preferably
> parameterized parsimoniously, then somehow determine an appropriate
> range of values consistent with the data. By the time you've done all
> that, you've effectively fit some model and constructed confidence
> intervals on the parameter(s).
>
> Best Wishes,
> Spencer
>
> Andrew Robinson wrote:
> >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