From Prof Brian Ripley <ripley@stats.ox.ac.uk>  Tue Jul 20 12:10:06 1999
From: Prof Brian Ripley <ripley@stats.ox.ac.uk> (Prof Brian Ripley)
Date: Tue, 20 Jul 1999 12:10:06 +0100 (BST)
Subject: time series in R
Message-ID: <199907201110.MAA04887@toucan.stats.ox.ac.uk>

> Date: Tue, 20 Jul 1999 11:17:51 +0200 (CEST)
> From: Martyn Plummer <plummer@iarc.fr>
> To: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
> Subject: RE: time series in R
> 
> On 19-Jul-99 Prof Brian D Ripley wrote:

> > Time Series functions in R
> > ==========================
> > 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?)
> 
> Some of the ts class stuff is implemented in the C code of the base
> library. I'm not sure you can separate this.

Rather, in the C core of R (the base package has no C code).  I was not
intended to separate that. My aim was merely to allow some code to be
re-written without losing backwards compatibility, yet. For example,
print.ts does not do well with multiple series (and it breaks the 
cardinal rule of a print method returning its first argument unchanged).

> I also suggested an "na.omit" method for time series - which would be
> used by many of the time series functions. Martin has made na.omit()
> and na.fail() generic so this is possible now.

Good. What do you want na.omit.ts to do? 

> > filter
> 
> I think there is some functional overlap between filter() and convolve(),
> which now has a type="filter" option. I'm not sure convolve() needs this
> if there is a filter() function.

I'll take a look.

> 
> > acf from bats, augmented by ideas from tseries.
> 
> I updated acf() in bats_0.1-3.tar.gz (now on CRAN) to use FFT instead,
> after seeing its rather embarrassing performance.

I have that. However, I am having a number of problems with it,
for example that pacf does not work, and acf does not work correctly
for multiple series.

> library(bats)
> data(presidents)
> acf(presidents, type="partial")
Error: Object "xb" not found

OK, fix that:
> acf(presidents, type="partial")
Error: NA/NaN/Inf in foreign function call (arg 1)

[The NA handling needs to be sorted out.]

A little later:

            var0 <- diag(acf[1, , ], nrow = nser)

is wrong: it gives a matrix and multivariate acfs fail. I used

            var0 <- if(nser > 1) diag(acf[1, , ]) else acf[1,1,1]

I think I will special-case the univariate code here.


> > spectrum, spec.pgram from bats  (after looking at tseries hard)
> 
> Adrian's spectrum() function allows a wider range of kernel smoothers
> and it would be nice to keep this.  Since spectrum() is just a wrapper
> function anyway, it should be possible to do this, while keeping the
> S-PLUS compatible interface.

Yes, I intend to look at that. For now, though, your code is not
giving the same results as S-PLUS, and I need to fix up at least the
confidence interval calculations.  (I think I know exactly how it
is done in S-PLUS: it uses Bloomfield's code.)  I believe that padding
needs to be optional.

> > 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).
> 
> I haven't tried very hard to make my code efficient, as you can see,
> concentrating instead on getting something that works like the S-PLUS
> version. Much of the work involved trying to get the same answer as
> S-PLUS, and when that wasn't possible, trying to work out what S-PLUS
> was doing wrong (see the COMPAT file).
> 
> I think the multivariate version would be harder to implement in C.

I agree, but maybe it should be done.

> I will see if I can speed the R code up.
> 
> I have been looking at Burg's algorithm and I think I can implement
> this now, if you want.

Yes, please (even though I think it is in principle a bad idea).

> > 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.

Looking at where I am, that looks feasible

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


time series in R
Prof Brian Ripley