[R-SIG-Finance] Return.calculate strange results?

Robert Iquiapaza rbali at ufmg.br
Fri Jun 12 21:18:27 CEST 2009


Mark

Using library(timeSeries)
returns(A, method = "discrete")
returns(A, method = "continuous")

or PerformanceAnalytics version 0.9.7.1

require(PerformanceAnalytics)
Return.calculate(z, method="simple")
               Column
2007-01-04 0.02219570
Return.calculate(z, method="compound")
               Column
2007-01-04 0.02195296

I got the same results.

The continuous or compound is computed with ln(85.66/83.8)

The error could be in the way you call the data. Also it appears that some 
packages have extrange behavior when you only have two observations.

This is the result with timeSeries
> returns(A, method = "discrete")
                    x
2007-01-04         NA        #lock the data
2007-01-04 0.02219570
>returns(A, method = "continuous")
                    x
2007-01-03         NA
           0.02195296     #no data

with tree observations gets better
> returns(A, method = "continuous")
                     x
2007-01-03          NA
2007-01-04  0.02195296
2007-01-05 -0.01363444


--------------------------------------------------
From: "Mark Breman" <breman.mark at gmail.com>
Sent: Friday, June 12, 2009 2:27 PM
To: <r-sig-finance at stat.math.ethz.ch>
Subject: [R-SIG-Finance] Return.calculate strange results?

> I'm getting strange results from the Return.calculate() function in the
> PerformanceAnalytics package:
> I have a timeseries A with price data:
>
>> A
>                      AAPL.Close
> 2007-01-03      83.80
> 2007-01-04      85.66
>
> The simple method of Return.calculate() gives me the following returns:
>
>> Return.calculate(A, method="simple")
>                   AAPL.Close
> 2007-01-03   -0.02171375
> 2007-01-04          NA
>
> Isn' t that weird? I would expect a simple return on the 2007-01-04 row 
> of:
> (85.66 / 83.80) -1 = 0.02219570 and a NA value for the 2007-01-03 row.
>
> The compound method of the function also gives a strange result:
>
>> Return.calculate(A, method="compound")
>                   AAPL.Close
> 2007-01-03         NA
> 2007-01-04   0.02195296
>
> On the 2007-01-04 row I would expect the same return as the simple method
> (because there is only one period): (85.66 / 83.80) -1 = 0.02219570
> Instead it gives me 0.02195296.
>
> Am I doing something wrong here or is the function broken?
>
> Regards,
>
> -Mark-
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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.
>



More information about the R-SIG-Finance mailing list