[R-SIG-Finance] apply.fromstart() warnings
ggrothendieck at gmail.com
Mon Jun 2 15:40:53 CEST 2008
The problem goes beyond some warnings -- the answers from
apply.fromstart are wrong. You could report the problem to the
author and just use a suitably modified version of the loop I posted
as a workaround.
On Mon, Jun 2, 2008 at 9:26 AM, Murali Menon <feanor0 at hotmail.com> wrote:
> Hi Gabor,
> Thanks for the suggestion. Actually, I just simplified the problem to a small bit of code that replicates the issue; in actuality, it's not the mean I am interested in calculating (but all sorts of other metrics), and the data are not randomly generated, but are financial time-series.
> The warning's probably coming from the apply.fromstart() function, but am not quite able to determine why. The initial 20 NAs are expected as there are no 'mean' computed for these (viz. the argument gap = 20).
> Murali> Date: Mon, 2 Jun 2008 08:27:56 -0400> From: ggrothendieck at gmail.com> To: feanor0 at hotmail.com> Subject: Re: [R-SIG-Finance] apply.fromstart() warnings> CC: r-sig-finance at stat.math.ethz.ch> > To do it in zoo alone try this:> > library(zoo)> d <- zoo(matrix(1:50, 25), as.Date(1:25))> > dd <- NA * d> for(i in 21:nrow(dd)) dd[i, ] <- colMeans(d[1:i, ])> > You also might try updating the to latest version of all packages and R> although that does not appear to be the source of the problem here.> > On Mon, Jun 2, 2008 at 7:57 AM, Murali Menon <feanor0 at hotmail.com> wrote:> >> >> > Folks,> >> > When I attempt to find the growing window columnwise mean of a two-dimensional array, I get a bunch of warnings. Any idea why? Here's my code:> >> >> library(PerformanceAnalytics)> >> >> d <- zoo(matrix(rnorm(50), ncol=2), order.by=as.Date(1:25))> >> >> apply.fromstart(d, gap=20, FUN="mean")> > 1970-01-02 NA NA> > 1970-01-03 NA NA> > 1970-01-04 NA NA> > 1970-01-05 NA NA> > 1970-01-06 NA NA> > 1970-01-07 NA NA> > 1970-01-08 NA NA> > 1970-01-09 NA NA> > 1970-01-10 NA NA> > 1970-01-11 NA NA> > 1970-01-12 NA NA> > 1970-01-13 NA NA> > 1970-01-14 NA NA> > 1970-01-15 NA NA> > 1970-01-16 NA NA> > 1970-01-17 NA NA> > 1970-01-18 NA NA> > 1970-01-19 NA NA> > 1970-01-20 NA NA> > 1970-01-21 -0.05899970 -0.05899970> > 1970-01-22 -0.05882669 -0.05882669> > 1970-01-23 -0.08635806 -0.08635806> > 1970-01-24 -0.15848480 -0.15848480> > 1970-01-25 -0.13168358 -0.13168358> > 1970-01-26 -0.17101046 -0.17101046> > There were 12 warnings (use warnings() to see them)> >> >> > When I check the warnings(), here's the first string I get:> >> > 1: In column.Return.calc[i] = apply(as.matrix(data.zoo[, ... :> > number of items to replace is not a multiple of replacement length> >> > I'm not sure why this should be the case?> >> >> > I'm using:> >> >> packageDescription("zoo")$Version> >  "1.4-2"> >> packageDescription("PerformanceAnalytics")$Version> >  "0.9.6"> >> >> > And R 2.6.1 on Windows XP.> >> >> > Thanks,> >> >> > Murali> >> > _________________________________________________________________> > Give to a good cause with every e-mail. Join the i'm Initiative from Microsoft.> >> > _______________________________________________> > R-SIG-Finance at stat.math.ethz.ch mailing list> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance> > -- Subscriber-posting only.> > -- If you want to post, subscribe first.> >
> Give to a good cause with every e-mail. Join the i'm Initiative from Microsoft.
> [[alternative HTML version deleted]]
> R-SIG-Finance at stat.math.ethz.ch mailing list
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
More information about the R-SIG-Finance