aggregate.ts (PR#376)

plummer@iarc.fr plummer@iarc.fr
Thu, 16 Dec 1999 14:15:51 +0100 (MET)


I'm having some problems with aggregate.ts, e.g.

R> x <- ts(1:20)
R> frequency(x)
[1] 1

R> aggregate(x, nfreq=1/3)
Error in aggregate.ts(x, nfreq = 1/3) : cannot change frequency from 1 to
0.333333333333333

In fact aggregate.ts only accepts a new frequency that is a negative
power of two in this example. 

The problem with the current test for compatible frequencies

    if ((ofrequency%%nfrequency) != 0)
        stop(paste("cannot change frequency from", ofrequency,
            "to", nfrequency))

is that numerical errors may cause it to fail.  I suggest

     if (abs(ofrequency%%nfrequency) < ts.eps)

instead.
Martyn

--please do not edit the information below--

Version:
 platform = i686-unknown-linux
 arch = i686
 os = linux
 system = i686, linux
 status =
 major = 0
 minor = 90.1
 year = 1999
 month = December
 day = 15
 language = R

Search Path:
 .GlobalEnv, Autoloads, package:base

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