[Returnanalytics-commits] r2012 - pkg/PortfolioAnalytics/sandbox/attribution

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 14 12:29:28 CEST 2012


Author: ababii
Date: 2012-06-14 12:29:28 +0200 (Thu, 14 Jun 2012)
New Revision: 2012

Modified:
   pkg/PortfolioAnalytics/sandbox/attribution/Carino.R
   pkg/PortfolioAnalytics/sandbox/attribution/Frongello.R
   pkg/PortfolioAnalytics/sandbox/attribution/Grap.R
   pkg/PortfolioAnalytics/sandbox/attribution/Menchero.R
Log:
- documentation update

Modified: pkg/PortfolioAnalytics/sandbox/attribution/Carino.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/attribution/Carino.R	2012-06-13 18:42:29 UTC (rev 2011)
+++ pkg/PortfolioAnalytics/sandbox/attribution/Carino.R	2012-06-14 10:29:28 UTC (rev 2012)
@@ -1,7 +1,65 @@
-# Carino linking
+#' calculates total attribution effects using logarithmic linking 
+#' 
+#' Calculates total attribution effects over multiple periods using 
+#' logarithmic linking method. Used internally by the \code{\link{Attribution}} 
+#' function. Arithmetic attribution effects do not naturally link over time. 
+#' This function uses logarithmic smoothing to adjust attribution effects 
+#' so that they can be summed up over multiple periods. Attribution effect 
+#' are multiplied by the adjustment factor: 
+#' \deqn{A_{t}' = A_{t} \times \frac{k_{t}}{k}},
+#' where \deqn{k_{t} = \frac{log(1 + r_{t}) - log(1 + b_{t})}{r_{t} - b_{t}}}, 
+#' \deqn{k = \frac{log(1 + r) - log(1 + b)}{r - b}}. In case if portfolio and 
+#' benchmark returns are equal \deqn{k_{t} = \frac{1}{1 + r_{t}}. 
+#' \deqn{A_{t}}' - adjusted attribution effects at period \deqn{t}
+#' \deqn{A_{t}} - unadjusted attribution effects at period \deqn{t}
+#' \deqn{r_{t}} - portfolio returns at period \deqn{t}
+#' \deqn{b_{t}} - benchmark returns at period \deqn{t}
+#' \deqn{r} - total portfolio returns
+#' \deqn{b} - total benchmark returns
+#' \deqn{n} - number of periods
+#' The total arithmetic excess returns can be explained in terms of the sum 
+#' of adjusted attribution effects: 
+#' \deqn{r - b = \overset{n}{\underset{t=1}{\sum}}\left(Allocation_{t}+Selection_{t}+Interaction_{t}\right)}
+#' 
+#' @aliases Carino
+#' @param rp xts of portfolio returns
+#' @param rb xts of benchmark returns
+#' @param attributions  xts with attribution effects
+#' @author Andrii Babii
+#' @seealso  \code{\link{Attribution}} \cr \code{\link{Menchero}} \cr 
+#' \code{\link{Grap}} \cr \code{\link{Frongello}} \cr
+#' \code{\link{Attribution.geometric}}
+#' @references Christopherson, Jon A., Carino, David R., Ferson, Wayne E.  
+#' \emph{Portfolio Performance Measurement and Benchmarking}. McGraw-Hill. 2009. 
+#' Chapter 19
+#' 
+#' Bacon, C. \emph{Practical Portfolio Performance Measurement and
+#' Attribution}. Wiley. 2004. p. 191-193
+#' @keywords arithmetic attribution, Carino linking, logarithmic linking
+#' @examples
+#' 
+#' data(attrib)
+#' Carino(rp, rb, allocation)
+#' 
+#' @export
 Carino <- 
 function(rp, rb, attributions)
 {   # @author Andrii Babii
+  
+    # DESCRIPTION:
+    # Function to provide multi-period summary of attribution effects using
+    # logarithmic linking. Used internally by the Attribution function
+  
+    # Inputs:
+    # rp            xts of portfolio returns
+    # rb            xts of benchmark returns
+    # attributions  attribution effects (e.g. allocation, selection, interaction)
+  
+    # Outputs: 
+    # This function returns the data.frame with original attribution effects
+    # and total attribution effects over multiple periods
+  
+    # FUNCTION:
     rp.a = prod(1 + rp) - 1              
     rb.a = prod(1 + rb) - 1
     k = (log(1 + rp.a) - log(1 + rb.a)) / (rp.a - rb.a)

Modified: pkg/PortfolioAnalytics/sandbox/attribution/Frongello.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/attribution/Frongello.R	2012-06-13 18:42:29 UTC (rev 2011)
+++ pkg/PortfolioAnalytics/sandbox/attribution/Frongello.R	2012-06-14 10:29:28 UTC (rev 2012)
@@ -1,7 +1,63 @@
-# Frongello linking
+#' calculates total attribution effects using Frongello linking 
+#' 
+#' Calculates total attribution effects over multiple periods using 
+#' logarithmic linking method. Used internally by the \code{\link{Attribution}} 
+#' function. Arithmetic attribution effects do not naturally link over time. 
+#' This function uses logarithmic smoothing algorithms to adjust
+#' attribution effects so that they can be summed up over multiple periods
+#' Adjusted attribution effect at period t are:
+#' \deqn{A_{t}' = A_{t}\times\overset{t-1}{\underset{i=1}{\prod}}(1+r_{i})+b_{t}\times\overset{t-1}{\underset{i=1}{\sum}}A_{i}'}
+#' \deqn{A_{t}}' - adjusted attribution effects at period \deqn{t}
+#' \deqn{A_{t}} - unadjusted attribution effects at period \deqn{t}
+#' \deqn{r_{i}} - portfolio returns at period \deqn{i}
+#' \deqn{b_{i}} - benchmark returns at period \deqn{i}
+#' \deqn{r} - total portfolio returns
+#' \deqn{b} - total benchmark returns
+#' \deqn{n} - number of periods
+#' 
+#' @aliases Frongello
+#' @param Rp xts of portfolio returns
+#' @param wp xts of portfolio weights
+#' @param Rb xts of benchmark returns
+#' @param wb xts of benchmark weights
+#' @param attributions  xts with attribution effects
+#' @author Andrii Babii
+#' @seealso  \code{\link{Attribution}} \cr \code{\link{Menchero}} \cr 
+#' \code{\link{Grap}} \cr \code{\link{Carino}} \cr
+#' \code{\link{Attribution.geometric}}
+#' @references Christopherson, Jon A., Carino, David R., Ferson, Wayne E.  
+#' \emph{Portfolio Performance Measurement and Benchmarking}. McGraw-Hill. 2009. 
+#' Chapter 19
+#' 
+#' Bacon, C. \emph{Practical Portfolio Performance Measurement and
+#' Attribution}. Wiley. 2004. p. 199-201
+#' @keywords attribution, Frongello linking
+#' @examples
+#' 
+#' data(attrib)
+#' Frongello(Rp, wp, Rb, wb, allocation)
+#' 
+#' @export
 Frongello <-
 function(Rp, wp, Rb, wb, attributions)
 {   # @author Andrii Babii
+  
+    # DESCRIPTION:
+    # Function to provide multi-period summary of attribution effects using
+    # Frongello linking. Used internally by the Attribution function
+  
+    # Inputs:
+    # Rp xts of portfolio returns
+    # wp xts of portfolio weights
+    # Rb xts of benchmark returns
+    # wb xts of benchmark weights
+    # attributions  attribution effects (e.g. allocation, selection, interaction)
+  
+    # Outputs: 
+    # This function returns the data.frame with original attribution effects
+    # and total attribution effects over multiple periods
+    
+    # FUNCTION:
     rp = reclass(rowSums(Rp * wp), Rp)  
     rb = reclass(rowSums(Rb * wb), Rb)
     Rp = cbind(Rp, rp)

Modified: pkg/PortfolioAnalytics/sandbox/attribution/Grap.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/attribution/Grap.R	2012-06-13 18:42:29 UTC (rev 2011)
+++ pkg/PortfolioAnalytics/sandbox/attribution/Grap.R	2012-06-14 10:29:28 UTC (rev 2012)
@@ -1,7 +1,61 @@
-# GRAP linking
+#' calculates total attribution effects using GRAP linking 
+#' 
+#' Calculates total attribution effects over multiple periods using 
+#' logarithmic linking method. Used internally by the \code{\link{Attribution}} 
+#' function. Arithmetic attribution effects do not naturally link over time. 
+#' This function uses GRAP smoothing algorithms to adjust
+#' attribution effects so that they can be summed up over multiple periods
+#' Attribution effect are multiplied by the adjustment factor 
+#' \deqn{A_{t}' = A_{t} \times G_{t}}, where 
+#' \deqn{G_{t}=\overset{t-1}{\underset{i=1}{\prod}}(1+r_{i})\times\overset{n}{\underset{i=t+1}{\prod}}(1+b_{i})}
+#' \deqn{A_{t}}' - adjusted attribution effects at period \deqn{t}
+#' \deqn{A_{t}} - unadjusted attribution effects at period \deqn{t}
+#' \deqn{r_{i}} - portfolio returns at period \deqn{i}
+#' \deqn{b_{i}} - benchmark returns at period \deqn{i}
+#' \deqn{r} - total portfolio returns
+#' \deqn{b} - total benchmark returns
+#' \deqn{n} - number of periods
+#' The total arithmetic excess returns can be explained in terms of the sum 
+#' of adjusted attribution effects: 
+#' \deqn{r - b = \overset{n}{\underset{t=1}{\sum}}\left(Allocation_{t}+Selection_{t}+Interaction_{t}\right)}
+#'
+#'
+#' @aliases Grap
+#' @param rp xts of portfolio returns
+#' @param rb xts of benchmark returns
+#' @param attributions  xts with attribution effects
+#' @author Andrii Babii
+#' @seealso  \code{\link{Attribution}} \cr \code{\link{Menchero}} \cr 
+#' \code{\link{Carino}} \cr \code{\link{Frongello}} \cr
+#' \code{\link{Attribution.geometric}}
+#' @references Bacon, C. \emph{Practical Portfolio Performance Measurement and
+#' Attribution}. Wiley. 2004. p. 196-199
+#' @keywords attribution, GRAP linking
+#' @examples
+#' 
+#' data(attrib)
+#' Grap(rp, rb, allocation)
+#' 
+#' @export
 Grap <-
 function(rp, rb, attributions)
 {   # @author Andrii Babii
+  
+  
+    # DESCRIPTION:
+    # Function to provide multi-period summary of attribution effects using
+    # GRAP linking. Used internally by the Attribution function
+  
+    # Inputs:
+    # rp            xts of portfolio returns
+    # rb            xts of benchmark returns
+    # attributions  attribution effects (e.g. allocation, selection, interaction)
+  
+    # Outputs: 
+    # This function returns the data.frame with original attribution effects
+    # and total attribution effects over multiple periods
+  
+    # FUNCTION:
     G = rp
     T = nrow(rp)
     G[1] = prod(1 + rb[2:T])           #GRAP factor for the first period

Modified: pkg/PortfolioAnalytics/sandbox/attribution/Menchero.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/attribution/Menchero.R	2012-06-13 18:42:29 UTC (rev 2011)
+++ pkg/PortfolioAnalytics/sandbox/attribution/Menchero.R	2012-06-14 10:29:28 UTC (rev 2012)
@@ -1,7 +1,62 @@
-# Menchero linking
+#' calculates total attribution effects using Menchero linking 
+#' 
+#' Calculates total attribution effects over multiple periods using 
+#' Menchero linking method. Used internally by the \code{\link{Attribution}} 
+#' function. Arithmetic attribution effects do not naturally link over time. 
+#' This function uses Menchero smoothing algorithms to adjust
+#' attribution effects so that they can be summed up over multiple periods
+#' Attribution effect are multiplied by the adjustment factor 
+#' \deqn{A_{t}' = A_{t} \times (M +a_{t})},
+#' where \deqn{M=\frac{\frac{1}{n}(r-b)}{(1+r)^{\frac{1}{n}}-(1+b)^{\frac{1}{n}}}}
+#' \deqn{a_{t} = \left(\frac{r-b-M\times\overset{n}{\underset{t=1}{\sum}}(r_{t}-b_{t})}{\overset{n}{\underset{t=1}{\sum}}(r_{t}-b_{t})^{2}}\right)\times(r_{t}-b_{t})}
+#' In case if portfolio and benchmark returns are equal 
+#' \deqn{M = (1 + r)^\frac{n-1}{n}}
+#' \deqn{A_{t}}' - adjusted attribution effects at period \deqn{t}
+#' \deqn{A_{t}} - unadjusted attribution effects at period \deqn{t}
+#' \deqn{r_{t}} - portfolio returns at period \deqn{t}
+#' \deqn{b_{t}} - benchmark returns at period \deqn{t}
+#' \deqn{r} - total portfolio returns
+#' \deqn{b} - total benchmark returns
+#' \deqn{n} - number of periods
+#' The total arithmetic excess returns can be explained in terms of the sum 
+#' of adjusted attribution effects: 
+#' \deqn{r - b = \overset{n}{\underset{t=1}{\sum}}\left(Allocation_{t}+Selection_{t}+Interaction_{t}\right)}
+#'
+#' @aliases Menchero
+#' @param rp xts of portfolio returns
+#' @param rb xts of benchmark returns
+#' @param attributions  xts with attribution effects
+#' @author Andrii Babii
+#' @seealso  \code{\link{Attribution}} \cr \code{\link{Carino}} \cr 
+#' \code{\link{Grap}} \cr \code{\link{Frongello}} \cr
+#' \code{\link{Attribution.geometric}}
+#' @references Bacon, C. \emph{Practical Portfolio Performance Measurement and
+#' Attribution}. Wiley. 2004. p. 194-196
+#' @keywords arithmetic attribution, Menchero linking
+#' @examples
+#' 
+#' data(attrib)
+#' Menchero(rp, rb, allocation)
+#' 
+#' @export
 Menchero <-
 function(rp, rb, attributions)
 {   # @author Andrii Babii
+    
+    # DESCRIPTION:
+    # Function to provide multi-period summary of attribution effects using
+    # Menchero linking. Used internally by the Attribution function
+  
+    # Inputs:
+    # rp            xts of portfolio returns
+    # rb            xts of benchmark returns
+    # attributions  attribution effects (e.g. allocation, selection, interaction)
+  
+    # Outputs: 
+    # This function returns the data.frame with original attribution effects
+    # and total attribution effects over multiple periods
+  
+    # FUNCTION:
     rp.a = prod(1 + rp) - 1              
     rb.a = prod(1 + rb) - 1
     T = nrow(rp)



More information about the Returnanalytics-commits mailing list