[R] Cross correlation between two time series over nested time periods?
timlee126 at yahoo.com
Thu May 14 16:17:27 CEST 2015
Here the period of my time series B is a proper subinterval of the period of A.
Does ccf(A,B) requires A and B span the same period?
If A and B don't span the same period, what does ccf do?
When moving B along the period of A by a lag, does ccf(A,B) calculate the cross correlation between B and the part of A overlapping with B?
Or does ccf(A,B) calculate the cross correlation between A and the extension of B to the period of A by zero padding?
On Thu, 5/14/15, Franklin Bretschneider <bretschr at xs4all.nl> wrote:
Subject: Re: [R] Cross correlation between two time series over nested time periods?
Date: Thursday, May 14, 2015, 6:14 AM
2015-05-14 , at 02:11, Tim via R-help <r-help at r-project.org>
> I have two time series
> Calculate and plot cross correlation
between two time series over nested time periods. Each point
in either time series is for a week (not exactly a calendar
week, but the first week in a calendar year always starts
from Jan 1, and the other weeks in the same year follow
that, and the last week of the year may contain more than 7
days but no more than 13 days).
> The first time series A is stored in a
compressed (.gz) text file, which looks like (each week and
the corresponding time series value are separated by a comma
in a line):
> The second time series B is similarly
stored in a compressed (.gz) text file, but over a subset of
period of A, which looks like:
> I wonder how to calculate the cross
correlation between the two time series A and B (up to a
specified maximum lag), and plot A and B in a single plot?
The auto- and crosscorrelation
functions are in the stats package:
acf(x, lag.max = NULL,
type = c("correlation", "covariance",
plot = TRUE,
na.action = na.fail, demean = TRUE, ...)
ccf(x, y, lag.max = NULL, type =
plot = TRUE, na.action = na.fail, ...)
See further: ?ccf
bretschr at xs4all.nl
More information about the R-help