[R-SIG-Finance] Fwd: runMult instead of runSum

Martin Bauer Bauermartin at gmx.at
Sat Oct 29 22:42:46 CEST 2011


-------- Original-Nachricht --------
Datum: Fri, 28 Oct 2011 18:13:14 +0200
Von: "Martina Bauer" <Bauermartin at gmx.at>
An: r-sig-finance at r-project.or
Betreff: runMult instead of runSum

Hello,

Maybe my approach is wrong from the beginning but I would like to calculate from monthly data - one months and two months and lastly three months return
I know that I have to multiply the monthly performance instead to sum up - but I dont know how to do in R. Finally I should also rank the result according to n period performance (no clue how to archive this in R)


here my code

require(quantmod)
stock=c("DD","DIS","PFE")
DD.sp=Ad(DD)
dd.m=monthlyReturn(DD.sp)
dd1=runSum(dd.m,n=1)
dd2=runSum(dd.m,n=2)
dd3=runSum(dd.m,n=3)

DIS.sp=Ad(DIS)
dis.m=monthlyReturn(DIS.sp)
dis1=runSum(DIS.m,n=1)
dis2=runSum(DIS.m,n=2)
dis3=runSum(DIS.m,n=3)

PFE.sp=Ad(PFE)
pfe.m=monthlyReturn(PFE.sp)
pfe1=runSum(pfe.m,n=1)
pfe2=runSum(pfe.m,n=2)
pfe3=runSum(pfe.m,n=3)


I know that my R code is very poor any idea how to improve ?

THanks in advance
Best Regards

martin

-- 




--



More information about the R-SIG-Finance mailing list