[R] Semi-Regular Time Series with Missing Values

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jan 19 21:31:10 CET 2011


On Wed, Jan 19, 2011 at 3:07 PM, Adam Oliner <oliner at gmail.com> wrote:
> This still does not give me the desired behavior:
>
>> z = zoo(x, order.by=t, frequency=24)
>> t = as.ts(z)
> ... inserts 23 NA values between every actual value. This is not correct;
> the original data has a frequency of 24 and doesn't need one forced upon it
> during coercion.
>> z = zoo(x, order.by=t)
>> t = as.ts(z)
> ... obviously doesn't give me a ts with frequency 24.
>
> Keep in mind that I'm trying to get a ts with frequency 24 so I can feed it
> to stl. I haven't yet found a sequence of operations that lets me do this.
> Any ideas?

Its not clear what you are expecting but here is an example:

> library(zoo)
> z <- zooreg(1001:1012, frequency = 4); z
1(1) 1(2) 1(3) 1(4) 2(1) 2(2) 2(3) 2(4) 3(1) 3(2) 3(3) 3(4)
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
> frequency(z)
[1] 4
> tt <- as.ts(z); tt
  Qtr1 Qtr2 Qtr3 Qtr4
1 1001 1002 1003 1004
2 1005 1006 1007 1008
3 1009 1010 1011 1012
> frequency(tt)
[1] 4

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list