Hi!
first I would like to say that I am an enthusiastic user of the Rmetrics
libraries and I am very greatful to all the developpers.
I would really appreciate a few comments on the following problem though. As
the example below shows the function "colMeans" (package base) treats Nas
differently from the function "colStats" (package timeSeires). In order to have
the same tretment of Nas I could not find a better solution as to write a new
function: "colSdsNAs" instead of "colSds". I need this because I want to use
the function im "applySeries" and my data is similar to the "x" in the example.
Is this the only way or I can use the functions "colStats", "colSds" in some
way that suits my problem?
Thank you for your help!
-------
require(timeSeries)
require(fAssets)
a = c(rep(NA, 5), 6:12)
b = c(rep(NA, 3), 4:12)
x = cbind(a, b)
x = as.timeSeries(x)
dt0 = as.timeDate("20000101")
dt1 = as.timeDate("20001201")
tStamps = timeSequence(from = dt0, to = dt1, by = "1 month")
time(x) = tStamps
colMeans(x)
colSds(x)
colStats(x, mean)
#
colMeans(x, na.rm = TRUE)
colSds(x, na.rm = TRUE)
by = periods(time(x), "3m", "1m")
applySeries(x, from = by$from, to = by$to, FUN = "colMeans")
applySeries(x, from = by$from, to = by$to, FUN = "colSds")
colSdsNAs <- function(x) apply(x, 2, "sd")
applySeries(x, from = by$from, to = by$to, FUN = "colSdsNAs")
------
Dr. Danilo Mercurio
ERSTE-SPARINVEST Kapitalanlagegesellschaft m.b.H
Quantitative Analyst, Global Strategies and Research
AT00951850 Global Strategies & Research
Sitz des Unternehmens: 1010 Wien, Habsburgergasse 1a
Tel.: +43 (0) 50100 - 19957
Fax.: +43 (0) 50100 9 - 19957
Mob.: +43 (0) 50100 6 - 19957
www.sparinvest.com
Handelsgericht Wien - FN 81876 g
ERSTE-SPARINVEST Kapitalanlagegesellschaft m.b.H. - Member of Erste Group
_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should
go.