Ok thanks. I got now a temporal series of 2557 elements thanks to the
below code:
> seriezoo=zooreg(serie, start=as.Date("2002-01-01"))
> seriezooTS=as.ts(seriezoo)
The structure of seriezooTS is then the following one (str command):
> str(seriezooTS)
Time-Series [1:2557] from 11688 to 14244: 0.03424657
0.03881249 0.03078472 0.03536114 ...
When applying the "decompose" command to get a seasonal decomposition, I
got the following message:
> decompose(seriezooTS, "mult")
Error in decompose(seriezooTS, "mult") :
time series has no or less than 2 periods
So, I think I have to transform the first and last days of the temporal
series in terms of Date or some kind of POSIXct number. Am I wrong? And
how can I do that?
Thanks in advance,
Peter
On 02/16/2011 04:21 PM, Gabor Grothendieck wrote:
On Wed, Feb 16, 2011 at 6:51 AM, Peter Zorglub<peter.zorg...@gmail.com> wrote:
Hi R community!
I'd like to create a temporal series with ts command for the interval 1st
January 2002 - 31 December 2008. I have daily values, so this is a 2557 days
temporal series. I'm using this command :
ts(observations, start=2002, end=2009, freq=365)
However, I don't get the correct temporal series since both frequency (365
OR 366 for leap years) and deltat (1/365 OR 1/366) are varying with the year
considered.
So, is there a specific way to deal with leap years in the ts command or
have I to use another package?
You could do this with an implied frequency of 1
tt<- ts(1:10, start=as.Date("2000-01-01"))
which would represent the times as days since the Epoch. You can
recover the Date class dates with:
as.Date(tt, origin = "1970-01-01")
You might be better off using zoo or xts. e.g.
library(zoo)
z<- zooreg(1:10, start = as.Date("2000-01-01"))
Its also possible to move back and forth:
as.ts(z)
as.zoo(tt)
aggregate(as.zoo(tt), identity, as.Date)
______________________________________________
R-help@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.