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. GOAL #2: Do an ARIMA analysis that takes into account seasonal variation> a.1 <- arima(w4.ts,order=c(1,0,0),seasonal=list(order=c > (0,1,0),period=12))First, I'm not quite sure if I should set period=12 (months in a year) or period=365*24 (number of my observations in a year). The documentation was unclear to me. Second, I've noticed that the fracdiff command is useful to find appropriate (p,d,q) values for ARIMA models. But I have not found a command that suggests reasonable values for the seasonal (p,d,q) values. GOAL #3 Use the ARIMA analysis to fill in for NA values. (I'm not sure how to do this yet. For example, I do not know if I will need to use windowing to smooth my backcasted data. I would appreciate any pointers, references, or code examples. Also, the terminology of "backcasting" and "interpolation" is not perfectly clear to me. I'm certainly looking to do more than linear interpolation between data points ... that's why I'm hoping that ARIMA will help. I need seasonal ARIMA, I believe, because there are seasonal swings in temperature Thanks, David [[alternative HTML version deleted]]
On 8/26/05, David James <djames at 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.