[R-SIG-Finance] ?returns not applicable to zoo objects anymore???

Jeff Ryan jeff.a.ryan at gmail.com
Mon Oct 27 16:23:11 CET 2008


You can also use:

?periodReturn in quantmod.  This allows you to calculate returns over
any period, on any type of time-series class.  Both log and arithmetic
(discrete).

     periodReturn(x,
                  period='monthly',
                  subset=NULL,
                  type='arithmetic',
                  leading=TRUE,
                  ...)

     dailyReturn(x, subset=NULL, type='arithmetic',
                leading=TRUE, ...)
     weeklyReturn(x, subset=NULL, type='arithmetic',
                leading=TRUE, ...)
     monthlyReturn(x, subset=NULL, type='arithmetic',
                leading=TRUE, ...)
     quarterlyReturn(x, subset=NULL, type='arithmetic',
                leading=TRUE, ...)
     annualReturn(x, subset=NULL, type='arithmetic',
                leading=TRUE, ...)
     yearlyReturn(x, subset=NULL, type='arithmetic',
                leading=TRUE, ...)
     allReturns(x, subset=NULL, type='arithmetic',
                leading=TRUE)


Jeff

On Mon, Oct 27, 2008 at 12:15 AM, Bastian Offermann
<bastian2507hk at yahoo.co.uk> wrote:
> hello,
>
> does anybody know by any chance why the function ?returns in package
> timeSeries (formerly fSeries) cannot be applied to zoo objects? And
> converting zoo objects into class timeSeries does not seem to work as well.
>
> E.g.
>
> ticker <- c("^GSPC", "MSFT", "MMM", "DAI", "GS")
> from <- "1970-10-19"              # of type "YYYY-MM-DD"
> till <- "2007-12-31"
> freque <- c("d", "w", "m", "y")
> fq <- 3                           # input 1 for "d", 2 for "w" etc.
>
> sp500 <- get.hist.quote(ticker[1], start = from, end = till,
> compression=freque[fq], quote="Close")
> rsp500 <- returns(get.hist.quote(ticker[1], start = from, end = till,
> compression=freque[fq], quote="Close"))
>
>
> above code returns error msg.:
>
> Error in .classEnv(thisClass) :
>  unable to find an environment containing class "zoo"
>
> I upgraded my version from 2.7.1 to 2.8.0 and found that the package fSeries
> has been changed to timeSeries. ?returns always worked fine as coded above
> and suddenly caused errors as the one above after I had installed 2.8.0. I
> am now using 2.7.1 again, but the error remains. operating system is windows
> vista.
>
> thanks in advance.
>
> regards
>
> bo
>
> _______________________________________________
> 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list