Skip to content

ARIMA (seasonal) backcasting & interpolation

2 messages · David James, Gabor Grothendieck

#
On 8/26/05, David James <djames at frontierassoc.com> wrote:
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.