time series in R

Prof Brian D Ripley ripley@stats.ox.ac.uk
Mon, 19 Jul 1999 18:49:27 +0100 (BST)


Time Series functions in R
==========================

I think a good basic S-like functionality for library(ts) in base R
would include

ts class, tsp, is.ts, as.ts
plot methods
start end window frequency cycle deltat
lag diff aggregate
filter

spectrum, spec.pgram, spec.taper, cumulative periodogram, spec.ar?

ar -- at least univariate by Yule-Walker
arima -- sim, filter, mle, diag, forecast

stl


Of the first group we lack lag, deltat, cycle, filter. These are simple.
We have plot.ts, but might want lines.ts, for example.

Base R has nothing else, so I've taken a look at bats, tseries, dse
and timeslab.

bats
====

This is close to S(-PLUS) but lacks examples.
Its methods are often simple ones: it might benefit a lot from some
re-coding in C / Fortran.

It would give us 

ar.yw

acf and spectrum (spec.pgram, plot.spec).


tseries
=======

This has S-like function names, but does not, for example, accept
multiple time series in acf.  It has nice plots and nice examples.
(It would be better if the LIBNAME were tseries, when no Makefile
would be needed: as it is $(LD) should be $(SHLIBLD) and CFLAGS +=
-Wall is not a good idea being make and CC-specific.)

It would give us

acf/ccf/pacf (for acf in S)
spectrum/cross spectra/cumulative.periodogram


dse
===

As far as I can see (it is very complex) this handles state-space models,
and can handle ARMA models by converting them (approximately)
to state-space form.

dse is rather un-R-like, and did not compile for me without fixing 20
or so Fortran errors, and did not load for me even after an hour's
work fixing many more in the R code. I think the version in devel is
currently unusable, and has far, far too many conflicts. Given Paul's
claims of stability, I have spent a deeply frustrating afternoon.


timeslab
========

Rather self-contained, copyright position unclear (to me).



Suggestions:
===========

If Martyn and Adrian are agreeable, I will start a library(ts) in the
0.65 version. I will put in this:

the ts class and methods (maybe in due course these should be removed
from the base package?)

datasets from MASS, tseries

lag, deltat, cycle
filter

acf from bats, augmented by ideas from tseries.

spectrum, spec.pgram from bats  (after looking at tseries hard)
spec.taper
cpgram from MASS

ar.yw from bats  (although that probably needs to be moved to
C/Fortran, and I may special-case the univariate case to use code I
have for that).


That leaves

stl -- I believe the code for this is on netlib.

arima modelling.  I do have Fortran code for this, and will work on
  a simple R interface for it.  An elegant interface can come later.


One thing we do need to be very careful about is the odd constants
and signs that occur in time-series work. No two books I consulted
agree exactly on the definitions of the periodogram and spectrum!
I think we should follow S-PLUS unless there are compelling reasons
not to. I am bit worried that some of the fft usage actually
only computes approximations, and we need to assess how serious that is.


As the feature-freeze for 0.65 is probably about 2-3 weeks away, we
ought to concentrate on getting the basic stuff (bats-like) in first.

How does that sound as a plan?

Brian


-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._