[R-SIG-Finance] Solicitation of opinions on which Timeseriesobject(s) to utilize.

jeff.a.ryan at gmail.com jeff.a.ryan at gmail.com
Mon Jan 21 23:12:16 CET 2008


I thought I'd clarify some items that Gabor brought up.

xts uses zoo as opposed to rewriting zoo functionality because zoo is essentially perfect.  Its generality is at the core of that.  It is all I ever use and technically what I continue to use - xts just wraps it along the lines of what I need - namely with time-based indicies.

In fact the extension of zoo to xts is because of the reasons that Gabor mentioned - most notably by enforcing the time-based index we can make conversions among classes more robust, and use fancy looking subsetting that is mostly a shortcut to what has always been possible with other commands or series of commands. By making assumptions about the index it can save a lot of as.Date/etc typing...and make things that otherwise would be difficult (error-prone) relatively easy.

The other aspect is the addition of attributes to allow for more detail to be added to an object.  For instance it would be trivial to add the timezone/financial center data to the object.

By relying on zoo it also keeps everything designed for zoo working without modification.

Its version number at 0.0-6 (on r-forge, as it hasn't been pushed to CRAN since 0.0-3) is for a good reason.  Most things work 90+% of the time, but there are bugs that are yet to be worked out.  It is also currently being decided as to what it _should_ do and how to accomplish those tasks. It is probably worthy of a higher number, but I would like it to have some more time... I suspect Gabor had an earlier version which didn't include much of what is there now.

Additionally some of the time-based functionality of quantmod (first/last/breakpoints (now endpoints)/periodicity/to.period) is being transitioned to xts.  The biggest reason xts is on CRAN at all this early is to make this transition as clean as possible.

At present the immediate benefit to xts is in fast and relatively painless coversion to and from the myriad of time-series classes in R.  Basically as.xts takes everything in the object being coverted, saves it to its xtsAttributes list (really just attributes that are hidden during printing) and makes the object behave like a zoo/xts object.  So everything that xts can do, and more importantly, everything that zoo can do is available.  Calling 'reclass' turns it back to the original form - everything intact.  So function development can be from a zoo/xts perspective, yet the input/output user experience will be in whichever class they originally used.  The best example of this is the 'to.period' routine in xts - which takes any of the main class types (timeSeries, zoo, its, irts, ts, ...) and aggregates to some different frequency (to.monthly from daily say) and returns an object *of the ORIGINAL class*.  It works quite well, and to the end user it is seemless.  This function in particular (to.period) even modifies the index class of the returned object if possible to something more logical - such as yearmon for monthly series.  Basically makes writing methods for all possible cases unnecessary, which makes development faster and the user experience seemless.

All that said, xts is still very much a work in progress and any suggestions as to direction/addition/deletion would be greatly appreciated.

We do hope to have at least one vignette available in the coming weeks covering the purpose of xts, as well as its functions/methods.

Jeff
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: "Gabor Grothendieck" <ggrothendieck at gmail.com>

Date: Mon, 21 Jan 2008 15:13:43 
To:r-sig-finance at stat.math.ethz.ch, "Joe W. Byers" <ecjbosu at aol.com>
Subject: Re: [R-SIG-Finance] Solicitation of opinions on which Timeseries
	object(s) to utilize.


On Jan 21, 2008 1:35 PM, Andrew Piskorski <atp at piskorski.com> wrote:
> On Sun, Jan 20, 2008 at 09:55:40AM -0600, Joe W. Byers wrote:
> > I am soliciting your opinions on the different time series objects as to
> > which you prefer, or which you do not prefer.  I have been using
>
> I don't know anything about which R time series packages are better
> (or for what), but I do have a list of some of the ones that exist:
>
>    zoo: http://cran.r-project.org/src/contrib/Descriptions/zoo.html
>    dse: http://www.bank-banque-canada.ca/pgilbert/
>    its: http://cran.r-project.org/src/contrib/Descriptions/its.html
>   urca: http://cran.r-project.org/src/contrib/Descriptions/urca.html
>    ast: http://sirio.stat.unipd.it/index.php?id=libast
> tseries: http://cran.r-project.org/src/contrib/Descriptions/tseries.html
>   tsa2: http://www.stat.pitt.edu/stoffer/tsa2/index.html
>         http://www.amazon.com/Time-Analysis-Its-Applications-Statistics/dp/0387293175/
> RTisean, tsdyn, and tserieschaos:
>  http://antonio.fabio.googlepages.com/rprojects
> And even more via 'label:timeseries' on Google Code:
>  http://code.google.com/hosting/search?q=label:timeseries&filter=0

I think many of these are focused on time series functions rather than
time series representations which seems to be more the topic of
discussion.

The CRAN Task Views on empirical finance and econometrics have some
discussion and lists of the time series packages in R.

>
> And here's my super-short summary of what others have said elsewhere
> in this thread:
>
> - zoo and/or xts are good.

Maybe that is going a bit far in cursory treatment.

xts
- what xts is is a subclass of zoo with its own is, as, coredata, print
and [ methods.
- it requires use of Date or POSIXct as the index class.  This has
the advantage that it can make certain assumptions which its
superclass zoo cannot make due to zoo's greater generality.
For example, the :: notation (which is roughly a counterpart of the
window() function in ts and zoo) is made possible by the fact that
it knows that the index is Date or POSIXct whereas zoo's
index could be practically anything.  On the other hand, with
xts you cannot directly model a quarterly series, say, other
than to embed it into a daily series, say.  However, as xts
is a zoo subclass you can directly access all zoo functionality
whenever you want so it would not be a problem to use xts
to model a daily Date class series and then convert it to yearmon
and keep going using just zoo at that point.
- xts has an as.xts.timeSeries method which can convert
timeSeries objects to xts/zoo.
- xts is at version 0.0.x and is not ready for wide use (all
the examples posted here would not work when I tried them)
but over time xts may gain maturity.  Given the interest shown
I would expect it might proceed rapidly.

zoo is a mature package with two vignettes (three in the next
version) that has been around quite a while now and provides
a general framework for modelling irregularly spaces series.
A description of zoo can be found in
library(zoo)
vignette("zoo")
vignette("zoo-quickref")
There are many other packages that use it or add
infrastructure to it such as xts, quantmod, dyn,
strucchange, etc.

> - zoo and/or xts basically make ts and tseries obsolete.

I don't think they make ts obsolete.  zoo (and therefore xts)
models irregularly spaced series and zoo also has a model for
irregularly spaced series which having an underlying regularity
whereas ts is based on strictly regular series.  Of course both
of zoo's irregular ones include regular ones as a subset but there
may be some situations where you prefer to model the regularity
directly.  Also ts is in the core of R and zoo and xts are not.
I use ts sometimes although I use zoo more.

tseries contains a time series model, irts.  The rest of tseries
consists of various time series functions and do not depend on irts
thus tseries as a package is not obsolete.

> - Rmetrics' timeSeries is useful but has certain problems.

Its main advantages are that many or at least some Rmetrics
functions use or can use that representation and it supports
financial centers.

Financial centers is really a property of the index class and not
necessarily of the time series so one could support this in zoo as
well by defining an appropriate index class.  e.g. as.xts.timeSeries

_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. 
-- If you want to post, subscribe first.


More information about the R-SIG-Finance mailing list