Skip to content
Prev 79432 / 398502 Next

Cross-correlation function

I have reproduced your error using the following

goo1 <- rnorm(100,0,1)
goo2 <- rnorm(100,0,1)
goo <- cbind(goo1,goo2)
goo[2,1] <- NA

ccf(ts(goo[,1]),ts(goo[,2]),na.action='na.exclude',type='cor')
Error in "colnames<-"(`*tmp*`, value = c("ts(goo[, 1])", "ts(goo[, 2])" :
        attempt to set colnames on object with less than two dimensions


ccf(ts(goo[,1]),ts(goo[,2]),type='cor')
Error in na.fail.default(ts.union(as.ts(x), as.ts(y))) :
        missing values in object

as desired, but

ccf(ts(goo[,1]),ts(goo[,2]),na.action=na.exclude,type='cor')

works fine for me, so removing the quotation marks around the na.exclude 
should do the trick.
Cheers,

Andreas


----- Original Message ----- 
From: "Anne Hertel" <ahertel at atmos.uiuc.edu>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, October 20, 2005 6:03 PM
Subject: [R] Cross-correlation function