Hi Andreas, thank you for replying so soon. You are right, your code works
perfectly for my example. Unfortunately, the real data contains inner NAs, which
I forgot to include. Sorry about that. Any other suggestions?
Thanks,
Katharina
-------- Original-Nachricht --------> Datum: Wed, 12 Aug 2009 16:29:26 +0200
> Von: Andreas Hary <andreashary at googlemail.com>
> An: Katharina Appel <KAJOAP at gmx.de>
> Betreff: Re: [R] CCF for hourly time series?
> I have replaced na.pass by na.omit (along with some other, relatively
> minor
> changes) and it works for me:
>
> 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"))
> y<-c(NA, 1.5,3,7, 1, 0.1)
> z<-c(0.3,0.35,0.7,0.72,0.72,0.8)
> x<-as.data.frame(x)
> prec<-cbind(x,y)
> theta<-cbind(x,z)
> ccf(ts(y),ts(z),lag.max=24,type='correlation',na.action=na.omit)
>
> Hope it'll work for you too. Cheers,
>
> Andreas
>
>
>
>
>
>
>
> On Wed, Aug 12, 2009 at 4:15 PM, Katharina Appel <KAJOAP at gmx.de>
wrote:
>
> > 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"))
> > y<-c(NA, 1.5,3,7, 1, 0.1)
> > z<-c(0.3,0.35,0.7,0.72,0.72,0.8)
> > x<-as.data.frame(x)
> > prec<-cbind(x,y)
> > theta<-cbind(x,z)
> >
> >
>
ccf(ts(mat1[,4]),ts(mat1[,j]),lag.max=24,type='correlation',na.action=na.pass)
> >
> >
> > that gives me "error in na.fail.default(as.ts(x)):missing values
in
> object"
> > In order to create the data frame I already intersected different time
> > series so I know that the timeindex is the same for all rows and
missing
> > values were replaced by NA.
> > Does that already impede creating a ts-object?
> > Is there another possibility to perform the cross-correlation?
> >
> > Thanks in advance,
> > Katharina
> > --
> > ___________________
> > Katharina Appel
> > Gro?e Weinmeisterstra?e 30
> > 14469 Potsdam
> >
> > Tel.: 0331-2370828
> > e-mail: Kajoap at gmx.de
> >
> > Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox
3
> -
> > sicherer, schneller und einfacher!
http://portal.gmx.net/de/go/atbrowser
> >
> > ______________________________________________
> > R-help at r-project.org 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.
> >
--
___________________
Katharina Appel
Gro?e Weinmeisterstra?e 30
14469 Potsdam
Tel.: 0331-2370828
e-mail: Kajoap at gmx.de
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser