Re: [R] ARIMA (seasonal) backcasting & interpolation

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 27 Aug 2005 - 13:25:33 EST

On 8/26/05, David James <djames@frontierassoc.com> wrote:
> Thanks for everyone's help with zoo -- I think I've got my data set
> ready. (The data consists of surface weather temperatures, from 2002
> to 2005, one observation per hour. Some values are missing... i.e. NA)
>
> I have three goals:
>
> GOAL #1:Get the data in proper time series form, preserving frequency
> information:
> > w4.ts <- as.ts( w3.zoo, frequency=(1/3600) )
> I hope that 1/3600 (0.0002778) is correct. I chose it because my
> zooreg object reported that value. This goes back to my choice of
> the ISOdatetime format, which required deltat=3600.

I will just address the zoo portion of this question.

In the ts class, a period is a unit so lets assume we want the resulting series to have a day represented as a unit. Then we first create a zoo series such that the integer part of the index is a day and then converting that is easy:

regts.day <- zoo(coredata(regts.zoo), as.numeric(time(regts.zoo))/(24*3600)) regts.ts <- as.ts(regts.day)

or convert it to chron first in which case its easy too:

library(chron)
regts.chron <- zoo(coredata(regts.zoo), as.chron(time(regts.zoo))) regts.ts <- as.ts(regts.chron)

Of course had chron been used in the first place just the last line would be needed.

Note that there are some issues as to which time zone is being used during conversion which I won't address but you can avoid that by just using chron right from the beginning. If you do use chron right from the beginning you won't have the problem with daylight savings time, you won't have the problem that the POSIXct and ts representations are very different and you won't have the problem of worrying about time zones.



R-help@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 Received on Sat Aug 27 13:29:51 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 16:00:38 EST