search for: ccf

Displaying 20 results from an estimated 151 matches for "ccf".

2006 Nov 27
2
NaN with ccf() for vector with all same element
hello, i have been using ccf() to look at the correlation between lightning and electrogamnetic data. for the most part it has worked exactly as expected. however, i have come across something that puzzles me a bit: > x <- c(1, 0, 1, 0, 1, 0) > y <- c(0, 0, 0, 0, 0, 0) > ccf(x, x, plot = FALSE) Autocorrelation...
2010 Jun 01
3
lapply with functions with changing parameters
Dear all, I am trying to avoid a for loop here and wonder if the following is possible: I have a data.frame with 6 columns and i want to get a cross-correlogram (by using ccf) . Obivously ccf only accepts two columns at once and then returms a list. In fact, with a for loop i?d do the following for (i in 1:6) { x[[i]]=ccf(mydf[,i],mydf[,6]) } Is there any chance to the same with lapply? e.g. lapply(mydf,"ccf", .... ) with ... respresenting the changing...
2008 Apr 23
1
ccf and covariance
Hi. It's my understanding that a cross-correlation function of vectors x and y at lag zero is equivalent to their correlation (or covariance, depending on how the ccf is defined). If this is true, could somebody please explain why I get an inconsistent result between cov() and ccf(type = "covariance"), but a consistent result between cor() and ccf(type = "correlation")? Or have I misunderstood what is a cross-correlation? (unfortunately, I ca...
2006 Mar 02
1
CCF and Lag questions
...l columns in my dataset. 2) Since I'm trying to build a multivariate time series model, I want to find the correlations of var1 with my other variables (var1, var2, ...etc.) and their lagged values. But since I'm trying to produce a forecast for 3 years into the future, I want to find the ccf between var1 and my other variables lagged 3 years. I tried doing: ccf(var1, lag(var2, 3)) but I get the following error: Error in na.fail.default(ts.union(as.ts(x), as.ts(y))) : missing values in object Does anyone know how to use the lag funciton and ccf together? 3) Suppose var1 a...
2012 May 11
1
Possible artifacts in cross-correlation function ("ccf")?
Dear R-users, I have been using R and its core-packages with great satisfaction now for many years, and have recently started using the "ccf" function (part of the "stats" package version 2.16.0), about which I have a question. The "ccf"-algorithm for calculating the cross-correlation between two time series always calculates the mean and standard deviation per time series beforehand, thereby using a constant v...
2010 Apr 26
1
Why am I getting different results from cor VS ccf ?
Hi all, I am getting different results from ccf and cor, Here is a simple example: set.seed(100) N <- 100 x1 <- sample(N) x2 <- x1 + rnorm(N,0,5) ccf(x1,x2)$acf[ccf(x1,x2)$lag == -1] cor(x1[-N], x2[-1]) Results: > ccf(x1,x2)$acf[ccf(x1,x2)$lag == -1] [1] -0.128027 > cor(x1[-N], x2[-1]) [1] -0.1301427 Thanks, Tal --------...
2014 Nov 04
1
[R] Calculation of cross-correlation in ccf
Dear All, I am studying some process measurement time series in R and trying to identify time delays using cross-correlation function ccf. The results have however been bit confusing. I found a couple of years old message about this issue but unfortunately wasn't able to find it again for a reference. For example, an obvious time shift is observed between the measurements y1 and y2 when the following test data is plotted: x &lt...
2011 Jan 19
2
CCF and missing values.
Hi, I have missing values in my time series. "na.action = na.pass" works for acf and pacf. Why do I get the following error for the ccf? > ts(matrix(c(dev$u[1:10],dev$q[1:10]),ncol=2),start=1,freq=1) Time Series: Start = 1 End = 10 Frequency = 1 Series 1 Series 2 1 68.00000 138.4615 2 70.00000 355.5556 3 68.76000 304.3200 4 68.00000 231.4286 5 69.74194 357.4963 6 NA NA 7 67.45455 174.8697 8 66.00000...
2006 Sep 15
1
"ccf versus acf"
I am trying to run a cross-correlation using the "ccf()" function. When I select plot = TRUE in the ccf() I get a graph which has ACF on the y-axis, which would suggest that these y-values are the auto-correlation values. How should I adjust the code to produce a plot that provides the cross-correlation values? Here is my code: w002dat <-...
2009 Jan 20
2
Confidence intervals in ccf()
Hi, I have been running the ccf() function to find cross-correlations of time series across various lags. When I give the option of plot=TRUE, I get a plot that gives me 95% confidence interval cut-offs (based on sample covariances) for my cross-correlations at each lag. This gives me a sense of whether my cross-correlations are...
2007 May 22
2
R-help with apply and ccf
Dear R gurus, I would like to use the ccf function on two matrices that are each 196000 x 12. Ideally, I want to be able to go row by row for the two matrices using apply for the ccf function and get one 196000 X 1 array output. The apply function though wants only one array, no? Basically, is there a way to use apply when there are two...
2008 May 08
1
significance threshold in CCF
Hi everyone, When the CCF between two series of observations is plotted in R, a line indicating (presumably) the significance threshold appears across the plot. Does anyone know how this threshold is determined (it is different for each set of series) and how its value can be extracted from R? I've tried saving the CCF...
2006 Nov 28
1
ccf documentation bug or suggeston (PR#9394)
On 11/28/2006 11:50 AM, A.I. McLeod wrote: > Hi Duncan, Hi Ian. > > ccf(x,y) does not explain whether c(k)=cov(x(t),x(t+k)) or d(k)=cov(x(t),x(t-k)) is calculated. The following example demonstrates > that the c(k) definition is used: > ccf(c(-1,1,rep(0,8)),c(1,rep(0,9))) > However S-Plus acf uses the d(k) definition in their acf function. I don't think...
2009 Jul 24
1
Lag representation in ccf() while zoo object is used?
...2007-01-01 03:00:00 0.0 0.175833 2007-01-01 04:00:00 0.3 0.176000 2007-01-01 05:00:00 1.8 0.176250 2007-01-01 06:00:00 2.0 0.177583 2007-01-01 07:00:00 0.2 0.178333 2007-01-01 08:00:00 0.3 0.178167 2007-01-01 09:00:00 3.2 0.178417 When I applied the ccf method, ccf(data$V1, data$V2), I noticed the lag is every 3600 which is a little surprising to me. I was thinking the lag should be 1, but it seems the lag unit becomes 3600. I guess the number 3600 representing 3600 "seconds" because of the zoo object. I am not sure if I'm right and...
2007 Mar 29
1
ccf time units
Hi, I am using ccf but I could not figure out how to calculate the actual lag in number of periods from the returned results. The documentation for ccf says:"The lag is returned and plotted in units of time". What does "units of time" mean? For example: > x=ldeaths > x1=lag(ldeaths,1) >...
2010 Apr 13
0
ccf problem (cross-correlation)
Hi all, I have a problem concerning my understanding of the cross-correlation (ccf) function in R. assume a time serie as: > t<-seq(0,6.28,by=0.01); > my_serie<-ts(sin(t),start=0,end=6.28,deltat=0.01) then I generate an other one shifted by 12 time points: > my_shifted_serie<-ts(sin(t),start=0+0.12,end=6.28+0.12,deltat=0.01) if I do the cross-correlation I...
2012 Oct 11
2
ccf(x,y) vs. cor() of x and lagged values of y
Hi I'm computing the correlation between two time-series x_t and y_t-1 (time-series lagged using the lag(y,-1) function) using the cor() function and the returned value is different from the value of ccf() function at the same lag. Any ideas why this is so? Thanks in advance for any hints. Mihnea [[alternative HTML version deleted]]
2006 Oct 02
1
CCF and ACF
Dear all, given two numeric vectors x and y, the ACF(x) at lag k is cor(x(t),x(t+k)) while the CCF(x,y) at lag k is cor(x(t),y(t-k)). See below for a simple example. > set.seed(1) > x <- rnorm(10) > y <- rnorm(10) > x [1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 -0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884 > y [1] 1.51178117 0.38984324 -0.6212...
2009 Aug 12
1
CCF for hourly time series?
Hello, I have a dataframe containing various time series (not time series objects though!)with hourly time steps. I?d like to perform ccf for I need to know the correlation factors for different lags. Here is an example: x<-as.POSIXct(c("2008-12-25 16:00:00", "2008-12-25 17:00:00", "2008-12-25 18:00:00", "2008-12-25 19:00:00", "2008-12-25 20:00:00","2008-12-25 21:00:00"...
2002 Jun 11
1
extra 0 in ccf
im using R 1.5.0 on redhat. when i use ccf in the ts library i get, what i think is, an incorrect entry in the lag and acf components. as an example, look at the second entry in the lag and acf components below: > library(ts) > tmp <- ccf(ts(rnorm(3)),ts(rnorm(3)),plot=F) > tmp$lag , , 1 [,1] [1,] -1 [2,] 0 [3,]...