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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jun 24 23:35:56 CEST 2012


Author: ababii
Date: 2012-06-24 23:35:56 +0200 (Sun, 24 Jun 2012)
New Revision: 2063

Modified:
   pkg/PortfolioAnalytics/sandbox/attribution/R/Attribution.geometric.R
Log:
- minor changes in the documentation and comments

Modified: pkg/PortfolioAnalytics/sandbox/attribution/R/Attribution.geometric.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/attribution/R/Attribution.geometric.R	2012-06-24 21:27:42 UTC (rev 2062)
+++ pkg/PortfolioAnalytics/sandbox/attribution/R/Attribution.geometric.R	2012-06-24 21:35:56 UTC (rev 2063)
@@ -1,7 +1,7 @@
 #' performs geometric attribution 
 #' 
 #' Performance attribution of geometric excess returns. Calculates total 
-#' geometric attribution effects over multiple periods. Used internally by the 
+#' geometric attribution effects over multiple periods. Used internally by the
 #' \code{\link{Attribution}} function. Geometric attribution effects in the
 #' conrast with arithmetic do naturally link over time multiplicatively:
 #' \deqn{\frac{(1+r)}{1+b}-1=\overset{n}{\underset{t=1}{\prod}}(1+A_{t}^{G})\times\overset{n}{\underset{t=1}{\prod}}(1+S{}_{t}^{G})-1}
@@ -25,11 +25,13 @@
 #' @param wp xts of portfolio weights
 #' @param Rb xts of benchmark returns
 #' @param wb xts of benchmark weights
+#' @return This function returns the list with attribution effects (allocation
+#' or selection effect) including total multi-period  attribution effects
 #' @author Andrii Babii
 #' @seealso  \code{\link{Attribution}}
 #' @references Christopherson, Jon A., Carino, David R., Ferson, Wayne E.  
-#' \emph{Portfolio Performance Measurement and Benchmarking}. McGraw-Hill. 2009. 
-#' Chapter 18-19
+#' \emph{Portfolio Performance Measurement and Benchmarking}. McGraw-Hill. 
+#' 2009. Chapter 18-19
 #' 
 #' Bacon, C. \emph{Practical Portfolio Performance Measurement and
 #' Attribution}. Wiley. 2004. Chapter 5, 8
@@ -54,16 +56,15 @@
     # wb       vector, xts, data frame or matrix of benchmark weights
   
     # Outputs: 
-    # This function returns the list with attribution effects (allocation,
-    # selection and total effects) including total multi-period 
-    # attribution effects
+    # This function returns the list with attribution effects (allocation or
+    # selection effect) including total multi-period  attribution effects
   
     # FUNCTION:
     rp = reclass(rowSums(Rp * wp), Rp)  
     rb = reclass(rowSums(Rb * wb), Rb)  
     names(rp) = "Total"                    
     names(rb) = "Total"                 
-    bs = reclass(rowSums((wp * Rb[, 1:ncol(wp)])), rp) # Seminotional funds returns
+    bs = reclass(rowSums((wp * Rb[, 1:ncol(wp)])), rp) # Allocation notional fund returns
     allocation = ((1 + Rb) / (1 + rep(rb, ncol(Rp))) - 1) * (wp - wb) # Geometric attribution effects for individual categories
     selection = wp * (Rp - Rb) / (1 + rep(bs, ncol(Rp)))
     allocation = cbind(allocation, rowSums(allocation)) # Total effects
@@ -74,17 +75,16 @@
     # Link single-period attribution effects
     a = (apply(1 + allocation[, ncol(allocation)], 2, prod) - 1)
     s = (apply(1 + selection[, ncol(selection)], 2, prod) - 1)
-    (apply(1 + selection[, ncol(selection)], 2, prod) - 1)
     allocation = rbind(as.data.frame(allocation), c(rep(NA, ncol(allocation) - 1), a))
     selection = rbind(as.data.frame(selection), c(rep(NA, ncol(selection) - 1), s))
     rownames(allocation)[nrow(allocation)] = "Total"
     rownames(selection)[nrow(selection)] = "Total"
     
-    # Get annualized geometric excess returns
+    # Get total geometric excess returns
     excess.returns = (1 + rp) / (1 + rb) - 1
     rp.a = prod(1 + rp) - 1              
     rb.a = prod(1 + rb) - 1
-    ger.a = as.matrix((1 + rp.a) / (1 + rb.a) - 1)  # Geometric (annualized) excess returns
+    ger.a = as.matrix((1 + rp.a) / (1 + rb.a) - 1)  
     rownames(ger.a) = "Total geometric"
     excess.returns = rbind(as.matrix(excess.returns), ger.a)
     



More information about the Returnanalytics-commits mailing list