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.
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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?
It would either
1) remove missing values only from the beginning or end of a time
series, or
2) return the longest contiguous subseries with no missing values,
e.g. presidents[32:110], or the first such subseries if there
were multiple matches.
A lot of S-plus time series functions use option 1). Option 2) seems
more useful to me. There is no "na.omit.ts" in Splus 3.3 but it
seems like a good way to implement this functionality.
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.
Error: NA/NaN/Inf in foreign function call (arg 1)
[The NA handling needs to be sorted out.]
See above.
A little later:
var0 <- diag(acf[1, , ], nrow = nser)
is wrong: it gives a matrix and multivariate acfs fail. I used
This works for me!
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.)
The main reason my confidence intervals are different is that I don't
have the correct expression for the degrees of freedom in the presence
of tapering (or padding, but that is trivial). Apart from that,
I deliberately chose different limits because I allow the user to
specify the coverage of the confidence interval in plot.spec, and if
one is allowed to do that, one needs to make sure that the confidence
interval contains the estimate, which would not always be the case with
the Splus behaviour.
I believe that padding
needs to be optional.
There seems to be two sorts of padding going on in Splus. One under
the control of the user, via the "pad" argument and the other
which is automatic, to aid the Fast Fourier Transform. I have
tried to reproduce this, but can't exactly match the Splus behaviour.
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._