[Returnanalytics-commits] r3070 - in pkg: PerformanceAnalytics/R PerformanceAnalytics/man PortfolioAttribution PortfolioAttribution/R PortfolioAttribution/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 12 20:07:30 CEST 2013


Author: braverock
Date: 2013-09-12 20:07:30 +0200 (Thu, 12 Sep 2013)
New Revision: 3070

Added:
   pkg/PerformanceAnalytics/R/Return.annualized.excess.R
   pkg/PerformanceAnalytics/man/Return.annualized.excess.Rd
Removed:
   pkg/PortfolioAttribution/R/Return.annualized.excess.R
   pkg/PortfolioAttribution/man/Return.annualized.excess.Rd
Modified:
   pkg/PortfolioAttribution/NAMESPACE
Log:
- move Return.annualized.excess to PerformanceAnalytics from PortfolioAttribution


Copied: pkg/PerformanceAnalytics/R/Return.annualized.excess.R (from rev 3067, pkg/PortfolioAttribution/R/Return.annualized.excess.R)
===================================================================
--- pkg/PerformanceAnalytics/R/Return.annualized.excess.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/R/Return.annualized.excess.R	2013-09-12 18:07:30 UTC (rev 3070)
@@ -0,0 +1,78 @@
+#' calculates an annualized excess return for comparing instruments with different
+#' length history
+#' 
+#' An average annualized excess return is convenient for comparing excess 
+#' returns.
+#' 
+#' Annualized returns are useful for comparing two assets. To do so, you must
+#' scale your observations to an annual scale by raising the compound return to
+#' the number of periods in a year, and taking the root to the number of total 
+#' observations:
+#' \deqn{prod(1+R_{a})^{\frac{scale}{n}}-1=\sqrt[n]{prod(1+R_{a})^{scale}}-
+#' 1}{prod(1 + Ra)^(scale/n) - 1}
+#' 
+#' where scale is the number of periods in a year, and n is the total number of
+#' periods for which you have observations.
+#' 
+#' Finally having annualized returns for portfolio and benchmark we can compute
+#' annualized excess return as difference in the annualized portfolio and 
+#' benchmark returns in the arithmetic case:
+#' \deqn{er = R_{pa} - R_{ba}}{er = Rpa - Rba}
+#' 
+#' and as a geometric difference in the geometric case:
+#' \deqn{er = \frac{(1 + R_{pa})}{(1 + R_{ba})} - 1}{er = (1 + Rpa) / (1 + Rba) - 1}
+#' 
+#' @param Rp an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' portfolio returns
+#' @param Rb an xts, vector, matrix, data frame, timeSeries or zoo object of 
+#' benchmark returns
+#' @param scale number of periods in a year (daily scale = 252, monthly scale =
+#' 12, quarterly scale = 4)
+#' @param geometric generate geometric (TRUE) or simple (FALSE) excess returns,
+#' default TRUE
+#' @author Andrii Babii
+#' @seealso \code{\link{Return.annualized}},
+#' @references Bacon, Carl. \emph{Practical Portfolio Performance Measurement
+#' and Attribution}. Wiley. 2004. p. 206-207
+#' @keywords ts multivariate distribution models
+#' @examples
+#' 
+#' data(attrib)
+#' Return.annualized.excess(Rp = attrib.returns[, 21], Rb = attrib.returns[, 22])
+#' 
+#' @export
+Return.annualized.excess <- 
+function (Rp, Rb, scale = NA, geometric = TRUE )
+{ # @author Andrii Babii
+    Rp = checkData(Rp)
+    Rb = checkData(Rb)
+    
+    Rp = na.omit(Rp)
+    Rb = na.omit(Rb)
+    n = nrow(Rp)
+    if(is.na(scale)) {
+      freq = periodicity(Rp)
+      switch(freq$scale,
+             minute = {stop("Data periodicity too high")},
+             hourly = {stop("Data periodicity too high")},
+             daily = {scale = 252},
+             eekly = {scale = 52},
+             monthly = {scale = 12},
+             quarterly = {scale = 4},
+             yearly = {scale = 1}
+             )
+    }
+    Rpa = apply(1 + Rp, 2, prod)^(scale/n) - 1
+    Rba = apply(1 + Rb, 2, prod)^(scale/n) - 1
+    if (geometric) {
+      # geometric excess returns
+      result = (1 + Rpa) / (1 + Rba) - 1
+    } else {
+      # arithmetic excess returns
+      result = Rpa - Rba
+    }
+    dim(result) = c(1,NCOL(Rp))
+    colnames(result) = colnames(Rp)
+    rownames(result) = "Annualized Return"
+    return(result)
+}
\ No newline at end of file

Copied: pkg/PerformanceAnalytics/man/Return.annualized.excess.Rd (from rev 3067, pkg/PortfolioAttribution/man/Return.annualized.excess.Rd)
===================================================================
--- pkg/PerformanceAnalytics/man/Return.annualized.excess.Rd	                        (rev 0)
+++ pkg/PerformanceAnalytics/man/Return.annualized.excess.Rd	2013-09-12 18:07:30 UTC (rev 3070)
@@ -0,0 +1,67 @@
+\name{Return.annualized.excess}
+\alias{Return.annualized.excess}
+\title{calculates an annualized excess return for comparing instruments with different
+length history}
+\usage{
+  Return.annualized.excess(Rp, Rb, scale = NA,
+    geometric = TRUE)
+}
+\arguments{
+  \item{Rp}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of portfolio returns}
+
+  \item{Rb}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of benchmark returns}
+
+  \item{scale}{number of periods in a year (daily scale =
+  252, monthly scale = 12, quarterly scale = 4)}
+
+  \item{geometric}{generate geometric (TRUE) or simple
+  (FALSE) excess returns, default TRUE}
+}
+\description{
+  An average annualized excess return is convenient for
+  comparing excess returns.
+}
+\details{
+  Annualized returns are useful for comparing two assets.
+  To do so, you must scale your observations to an annual
+  scale by raising the compound return to the number of
+  periods in a year, and taking the root to the number of
+  total observations:
+  \deqn{prod(1+R_{a})^{\frac{scale}{n}}-1=\sqrt[n]{prod(1+R_{a})^{scale}}-
+  1}{prod(1 + Ra)^(scale/n) - 1}
+
+  where scale is the number of periods in a year, and n is
+  the total number of periods for which you have
+  observations.
+
+  Finally having annualized returns for portfolio and
+  benchmark we can compute annualized excess return as
+  difference in the annualized portfolio and benchmark
+  returns in the arithmetic case: \deqn{er = R_{pa} -
+  R_{ba}}{er = Rpa - Rba}
+
+  and as a geometric difference in the geometric case:
+  \deqn{er = \frac{(1 + R_{pa})}{(1 + R_{ba})} - 1}{er = (1
+  + Rpa) / (1 + Rba) - 1}
+}
+\examples{
+data(attrib)
+Return.annualized.excess(Rp = attrib.returns[, 21], Rb = attrib.returns[, 22])
+}
+\author{
+  Andrii Babii
+}
+\references{
+  Bacon, Carl. \emph{Practical Portfolio Performance
+  Measurement and Attribution}. Wiley. 2004. p. 206-207
+}
+\seealso{
+  \code{\link{Return.annualized}},
+}
+\keyword{distribution}
+\keyword{models}
+\keyword{multivariate}
+\keyword{ts}
+

Modified: pkg/PortfolioAttribution/NAMESPACE
===================================================================
--- pkg/PortfolioAttribution/NAMESPACE	2013-09-12 17:46:41 UTC (rev 3069)
+++ pkg/PortfolioAttribution/NAMESPACE	2013-09-12 18:07:30 UTC (rev 3070)
@@ -9,7 +9,6 @@
 export(Grap)
 export(HierarchyQuintiles)
 export(Menchero)
-export(Return.annualized.excess)
 export(Return.level)
 export(Weight.level)
 export(Weight.transform)

Deleted: pkg/PortfolioAttribution/R/Return.annualized.excess.R
===================================================================
--- pkg/PortfolioAttribution/R/Return.annualized.excess.R	2013-09-12 17:46:41 UTC (rev 3069)
+++ pkg/PortfolioAttribution/R/Return.annualized.excess.R	2013-09-12 18:07:30 UTC (rev 3070)
@@ -1,78 +0,0 @@
-#' calculates an annualized excess return for comparing instruments with different
-#' length history
-#' 
-#' An average annualized excess return is convenient for comparing excess 
-#' returns.
-#' 
-#' Annualized returns are useful for comparing two assets. To do so, you must
-#' scale your observations to an annual scale by raising the compound return to
-#' the number of periods in a year, and taking the root to the number of total 
-#' observations:
-#' \deqn{prod(1+R_{a})^{\frac{scale}{n}}-1=\sqrt[n]{prod(1+R_{a})^{scale}}-
-#' 1}{prod(1 + Ra)^(scale/n) - 1}
-#' 
-#' where scale is the number of periods in a year, and n is the total number of
-#' periods for which you have observations.
-#' 
-#' Finally having annualized returns for portfolio and benchmark we can compute
-#' annualized excess return as difference in the annualized portfolio and 
-#' benchmark returns in the arithmetic case:
-#' \deqn{er = R_{pa} - R_{ba}}{er = Rpa - Rba}
-#' 
-#' and as a geometric difference in the geometric case:
-#' \deqn{er = \frac{(1 + R_{pa})}{(1 + R_{ba})} - 1}{er = (1 + Rpa) / (1 + Rba) - 1}
-#' 
-#' @param Rp an xts, vector, matrix, data frame, timeSeries or zoo object of
-#' portfolio returns
-#' @param Rb an xts, vector, matrix, data frame, timeSeries or zoo object of 
-#' benchmark returns
-#' @param scale number of periods in a year (daily scale = 252, monthly scale =
-#' 12, quarterly scale = 4)
-#' @param geometric generate geometric (TRUE) or simple (FALSE) excess returns,
-#' default TRUE
-#' @author Andrii Babii
-#' @seealso \code{\link{Return.annualized}},
-#' @references Bacon, Carl. \emph{Practical Portfolio Performance Measurement
-#' and Attribution}. Wiley. 2004. p. 206-207
-#' @keywords ts multivariate distribution models
-#' @examples
-#' 
-#' data(attrib)
-#' Return.annualized.excess(Rp = attrib.returns[, 21], Rb = attrib.returns[, 22])
-#' 
-#' @export
-Return.annualized.excess <- 
-function (Rp, Rb, scale = NA, geometric = TRUE )
-{ # @author Andrii Babii
-    Rp = checkData(Rp)
-    Rb = checkData(Rb)
-    
-    Rp = na.omit(Rp)
-    Rb = na.omit(Rb)
-    n = nrow(Rp)
-    if(is.na(scale)) {
-      freq = periodicity(Rp)
-      switch(freq$scale,
-             minute = {stop("Data periodicity too high")},
-             hourly = {stop("Data periodicity too high")},
-             daily = {scale = 252},
-             eekly = {scale = 52},
-             monthly = {scale = 12},
-             quarterly = {scale = 4},
-             yearly = {scale = 1}
-             )
-    }
-    Rpa = apply(1 + Rp, 2, prod)^(scale/n) - 1
-    Rba = apply(1 + Rb, 2, prod)^(scale/n) - 1
-    if (geometric) {
-      # geometric excess returns
-      result = (1 + Rpa) / (1 + Rba) - 1
-    } else {
-      # arithmetic excess returns
-      result = Rpa - Rba
-    }
-    dim(result) = c(1,NCOL(Rp))
-    colnames(result) = colnames(Rp)
-    rownames(result) = "Annualized Return"
-    return(result)
-}
\ No newline at end of file

Deleted: pkg/PortfolioAttribution/man/Return.annualized.excess.Rd
===================================================================
--- pkg/PortfolioAttribution/man/Return.annualized.excess.Rd	2013-09-12 17:46:41 UTC (rev 3069)
+++ pkg/PortfolioAttribution/man/Return.annualized.excess.Rd	2013-09-12 18:07:30 UTC (rev 3070)
@@ -1,67 +0,0 @@
-\name{Return.annualized.excess}
-\alias{Return.annualized.excess}
-\title{calculates an annualized excess return for comparing instruments with different
-length history}
-\usage{
-  Return.annualized.excess(Rp, Rb, scale = NA,
-    geometric = TRUE)
-}
-\arguments{
-  \item{Rp}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of portfolio returns}
-
-  \item{Rb}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of benchmark returns}
-
-  \item{scale}{number of periods in a year (daily scale =
-  252, monthly scale = 12, quarterly scale = 4)}
-
-  \item{geometric}{generate geometric (TRUE) or simple
-  (FALSE) excess returns, default TRUE}
-}
-\description{
-  An average annualized excess return is convenient for
-  comparing excess returns.
-}
-\details{
-  Annualized returns are useful for comparing two assets.
-  To do so, you must scale your observations to an annual
-  scale by raising the compound return to the number of
-  periods in a year, and taking the root to the number of
-  total observations:
-  \deqn{prod(1+R_{a})^{\frac{scale}{n}}-1=\sqrt[n]{prod(1+R_{a})^{scale}}-
-  1}{prod(1 + Ra)^(scale/n) - 1}
-
-  where scale is the number of periods in a year, and n is
-  the total number of periods for which you have
-  observations.
-
-  Finally having annualized returns for portfolio and
-  benchmark we can compute annualized excess return as
-  difference in the annualized portfolio and benchmark
-  returns in the arithmetic case: \deqn{er = R_{pa} -
-  R_{ba}}{er = Rpa - Rba}
-
-  and as a geometric difference in the geometric case:
-  \deqn{er = \frac{(1 + R_{pa})}{(1 + R_{ba})} - 1}{er = (1
-  + Rpa) / (1 + Rba) - 1}
-}
-\examples{
-data(attrib)
-Return.annualized.excess(Rp = attrib.returns[, 21], Rb = attrib.returns[, 22])
-}
-\author{
-  Andrii Babii
-}
-\references{
-  Bacon, Carl. \emph{Practical Portfolio Performance
-  Measurement and Attribution}. Wiley. 2004. p. 206-207
-}
-\seealso{
-  \code{\link{Return.annualized}},
-}
-\keyword{distribution}
-\keyword{models}
-\keyword{multivariate}
-\keyword{ts}
-



More information about the Returnanalytics-commits mailing list