[Returnanalytics-commits] r2031 - pkg/PortfolioAnalytics/sandbox/attribution/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 18 18:53:59 CEST 2012


Author: ababii
Date: 2012-06-18 18:53:58 +0200 (Mon, 18 Jun 2012)
New Revision: 2031

Modified:
   pkg/PortfolioAnalytics/sandbox/attribution/R/Frongello.R
Log:
- fixed bug with xts multiplication and addition

Modified: pkg/PortfolioAnalytics/sandbox/attribution/R/Frongello.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/attribution/R/Frongello.R	2012-06-18 08:26:16 UTC (rev 2030)
+++ pkg/PortfolioAnalytics/sandbox/attribution/R/Frongello.R	2012-06-18 16:53:58 UTC (rev 2031)
@@ -59,11 +59,11 @@
     # FUNCTION:
     attr = attributions
     if (nrow(rp) > 1){
-        attr[2, ] = attr[2, ] * (1 + rp[1, 1]) + rb[2, 1] * attr[1, ]
+        attr[2, ] = coredata(attr[2, ]) * drop((1 + rp[1, 1])) + drop(rb[2, 1]) * coredata(attr[1, ])
     }
     if (nrow(rp) > 2){
         for(i in 3:nrow(rp)){
-            attr[i, ] = attr[i, ] * prod(1 + rp[1:(i-1), 1]) + rb[i, ] * colSums(attr[1:(i-1), ])
+            attr[i, ] = coredata(attr[i, ]) * drop(prod(1 + rp[1:(i-1), 1])) + drop(rb[i, ]) * coredata(colSums(attr[1:(i-1), ]))
         }
     }
     total = colSums(attr)



More information about the Returnanalytics-commits mailing list