Series names not used by stats:::acf when fUtilities (as.matrix.ts seems to be the culprit) is loaded
Yohan Chalabi
chalabi at phys.ethz.ch
Wed Dec 10 19:08:06 CET 2008
>>>> "PBD" == "Pfaff, Bernhard Dr." <Bernhard_Pfaff at fra.invesco.com>
>>>> on Wed, 10 Dec 2008 11:35:01 -0000
PBD> Dear Rmetrics-core member (probably Diethelm and Yohan),
PBD>
PBD> I detected the following behaviour when the package "fUtilities" is
PBD> loaded:
PBD>
PBD>
PBD> > search()
PBD> [1] ".GlobalEnv" "package:MASS" "package:stats"
PBD> [4] "package:graphics" "package:datasets" "package:fortunes"
PBD> [7] "package:utils" "package:grDevices" "package:methods"
PBD> [10] "Autoloads" "package:base"
PBD> >
PBD> > data(EuStockMarkets)
PBD> > [1] "DAX" "SMI" "CAC" "FTSE"
PBD> > tmp.mts <- diff(log(EuStockMarkets)) * 100
PBD> > colnames(tmp.mts)
PBD> > acf(tmp.mts)
PBD> ## in acf the colnames are preserved in the plot
PBD> > search()
PBD> [1] ".GlobalEnv" "package:MASS" "package:stats"
PBD> [4] "package:graphics" "package:datasets" "package:fortunes"
PBD> [7] "package:utils" "package:grDevices" "package:methods"
PBD> [10] "Autoloads" "package:base"
PBD> > colnames(tmp.mts)
PBD> [1] "DAX" "SMI" "CAC" "FTSE"
PBD> > library(fUtilities)
PBD> Rmetrics Package fUtilities (270.75) loaded.
PBD> > search()
PBD> [1] ".GlobalEnv" "package:fUtilities" "package:MASS"
PBD> [4] "package:stats" "package:graphics" "package:datasets"
PBD> [7] "package:fortunes" "package:utils" "package:grDevices"
PBD> [10] "package:methods" "Autoloads" "package:base"
PBD> > acf(tmp.mts)
PBD> ## in acf the colnames are not any longer preserved!
PBD> ## due to as.matrix.ts() in fUtilities
PBD>
PBD>
PBD> as.matrix.ts <-
PBD> function (x, ...)
PBD> {
PBD> ans = as.matrix.default(unclass(x))
PBD> attr(ans, "tsp") <- NULL
PBD> rownames(ans) <- NULL
PBD> colnames(ans) <- NULL
PBD> ans
PBD> }
PBD>
PBD>
PBD> and in stats:::acf you will find the line:
PBD>
PBD> x <- as.matrix(x)
PBD>
PBD> which make use of as.matrix.ts (S3-method dispatch) in fUtilities and
PBD> there the colnames are set to NULL.
PBD> Hence, would it be possible to alter as.matrix.ts() to something like:
PBD>
PBD>
PBD> as.matrix.ts <- function (x, ...)
PBD> {
PBD> ans = as.matrix.default(unclass(x))
PBD> attr(ans, "tsp") <- NULL
PBD> rownames(ans) <- NULL
PBD> ifelse(is.null(colnames(ans)), colnames(ans) <- NULL, colnames(ans)
PBD> <- colnames(x))
PBD> ans
PBD> }
PBD>
PBD>
PBD> or rename as.matrix.ts() such that it is not dispatched as method in
PBD> acf()? However, I do not know if the former suggested function body
PBD> change would cause trouble elsewhere.
PBD>
PBD>
PBD> Best,
PBD> Bernhard
Hi Bernhard,
fUtilites was merged to fBasics and is now considered deprecated.
In the new fBasics package, the function as.matrix.ts has
been already removed to avoid the problem you mentioned.
hope this helps,
Yohan
--
PhD student
Swiss Federal Institute of Technology
Zurich
www.ethz.ch
More information about the Rmetrics-core
mailing list