[R-SIG-Finance] Difficulty getting desired returns withreturns(fSeries) function

Robert Iquiapaza rbali at ufmg.br
Fri Sep 5 16:33:56 CEST 2008


Try 'method' instead of 'type'. This works

getReturns(MSFT, method = "discrete", na.rm = F, trim = F, percentage = T)

Robert

--------------------------------------------------
From: "Weiyang Lim" <Weiyang.Lim at henderson.com>
Sent: Friday, September 05, 2008 4:14 AM
To: <r-sig-finance at stat.math.ethz.ch>
Subject: [R-SIG-Finance] Difficulty getting desired returns 
withreturns(fSeries) function

> Dear users,
>
> I tried to use the getReturns/returns function available with the fSeries 
> package but it did not appear to give me the results generated by the same 
> function in S-Plus finmetrics. I am not sure what is happening or what 
> goes behind the calculations.
>
> I have the code
>
> my.ts <- timeSeries(data = DataSeries) which generates the time series
>
>                        37
> 1970-01-01        NA
> 1970-01-02        NA
> 1970-01-03        NA
> 1970-01-04        NA
> 1970-01-05        NA
> 1970-01-06        NA
> 1970-01-07        NA
> 1970-01-08        NA
> 1970-01-09        NA
> 1970-01-10        NA
> 1970-01-11        6500
> 1970-01-12        8100
> 1970-01-13        8010
> 1970-01-14        7930
> .                       .
> .                       .
> .                       .
> .                       .
> .                       .
>
> Then I used
>
> dummystock.rs <- getReturns(my.ts, type = "discrete", na.rm = F, trim = F, 
> percentage = T) which generates the returns
>
>                        37
> 1970-01-01        NA
> 1970-01-02        NA
> 1970-01-03        NA
> 1970-01-04        NA
> 1970-01-05        NA
> 1970-01-06        NA
> 1970-01-07        NA
> 1970-01-08        NA
> 1970-01-09        NA
> 1970-01-10        NA
> 1970-01-11        NA
> 1970-01-12        22.0061885
> 1970-01-13        -1.1173301
> 1970-01-14        -1.0037725
> .                       .
> .                       .
> .                       .
> .                       .
>
> However, what I really want is 24.61, -1.111, and -0.99 respectively 
> rather than the returns above. The calculation I wanted for returns was 
> (8100-6500)/6500 * 100 (for the first return) = 24.61 rather than 
> 22.0061885.
>
> I am using R version 2.7.0.
>
> I wonder if anyone can give me any kind advice as to how to achieve the 
> returns I hope to have.
>
> Many thanks.
>
> Best Regards,
> Wy
>



More information about the R-SIG-Finance mailing list