1
$\begingroup$

I have a huge data frame with over 1000 column, which are companies(column headers) and in each column I have their estimated return(monthly). The sample period of the data frame in 11 years. I want to calculate cumulative returns over the past 12 months with with one month lag. Meaning cumulative returns of January 2005 are estimated on the basis of Jan-04 to Dec.04 and February 2005 are estimated on the basis of Feb-04 to Jan-05. I present my data as follows:

df
Month    A       B      C     D      E
Jan-00  0.01    0.00    NA  -0.01   NA
Feb-00  0.01    0.00    NA  0.00    NA
Mar-00  -0.02   0.00    NA  0.01    NA
Apr-00  -0.01   0.00    NA  -0.01   NA
May-00  -0.01   0.00    NA  0.01    NA
Jun-00  0.00    0.01    NA  -0.01   NA
Jul-00  0.00    -0.01   NA  0.00    NA
Aug-00  0.00    0.01    NA  0.00    NA
Sep-00  0.00    0.00    NA  0.00    NA
Oct-00  -0.01   0.00    NA  0.00    NA
Nov-00  -0.01   -0.01   NA  0.01    NA
Dec-00  -0.01   0.00    NA  0.01    NA
Jan-01  -0.01   0.00    NA  0.00    NA

There also NAs within the data which cannot be removed due to the nature of data. I appreciate your help in this regard.

$\endgroup$
  • $\begingroup$ @vonjd there is funciton in performance analytics return.cumulative but I'm hesistant to use it as I have already estimated the returns and I need guidance for 1 lag i.e. what does it imply? $\endgroup$ – Aquarius Feb 26 '16 at 12:43
  • $\begingroup$ did you try lag function of dplyr? $\endgroup$ – berkorbay Feb 26 '16 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.