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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 8 14:54:16 CEST 2012


Author: matthieu_lestel
Date: 2012-07-08 14:54:16 +0200 (Sun, 08 Jul 2012)
New Revision: 2125

Added:
   pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
   pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd
Log:
adjusted sharpe ratio with examples and documentation

Added: pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R	2012-07-08 12:54:16 UTC (rev 2125)
@@ -0,0 +1,58 @@
+#' Adjusted Sharpe ratio of the return distribution
+#'
+#' Adjusted Sharpe ratio was introduced by Pezier and White (2006) to adjusts
+#' for skewness and kurtosis by incorporating a penalty factor for negative skewness
+#' and excess kurtosis.
+#'
+#' \deqn{Adjusted Sharpe Ratio = SR * [1 + (\frac{S}{6}) * SR - (\frac{K - 3}{24}) * SR^2]}
+#' {Adjusted Sharpe ratio = SR x [1 + (S/6) x SR - ((K-3) / 24) x SR^2]}
+#'
+#' where \eqn{SR} is the sharpe ratio with data annualized, \eqn{S} is the skewness and \eqn{K} is the kurtosis
+#' 
+#' @aliases Adusted Sharpe ratio
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param Rf the risk free rate
+#' @param period the number of returns in a year (ie 12 for monthly returns, 4 for quaterly returns)
+#' @param \dots any other passthru parameters
+#' @author Matthieu Lestel
+#' @references Carl Bacon, \emph{Practical portfolio performance measurement 
+#' and attribution}, second edition 2008 p.99
+#' 
+#' @keywords ts multivariate distribution models
+#' @examples
+#' data(portfolio_bacon)
+#' print(AdustedSharpeRatio(portfolio_bacon[,1])) #expected 0.813
+#'
+#' data(managers)
+#' print(AdustedSharpeRatio(managers['1996']))
+#' print(AdustedSharpeRatio(managers['1996',1])) 
+#'
+#' @export 
+
+AdjustedSharpeRatio <- function (R, Rf = 0, period = 12, ...)
+{
+    R0 <- R
+    R = checkData(R, method="matrix")
+
+    if (ncol(R)==1 || is.null(R) || is.vector(R)) {
+       R = na.omit(R)
+       n = length(R)
+       Rp = period/n*sum(R)
+       Sigp = sqrt(sum((R-mean(R))^2)/n)*sqrt(period)
+       SR = (Rp - Rf) / Sigp
+       K = kurtosis(R, method = "moment")
+       S = skewness(R)
+       result = SR*(1+(S/6)*SR-((K-3)/24)*SR^2)
+       reclass(result, R0)
+       return(result)
+    }  
+    else {
+        R = checkData(R)
+        result = apply(R, MARGIN = 2, AdjustedSharpeRatio, Rf = Rf, period = period, ...)
+        result<-t(result)
+        colnames(result) = colnames(R)
+        rownames(result) = paste("Adjusted Sharpe ratio (Risk free = ",Rf,")", sep="")
+        return(result)
+    }
+}
\ No newline at end of file

Added: pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd	                        (rev 0)
+++ pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd	2012-07-08 12:54:16 UTC (rev 2125)
@@ -0,0 +1,54 @@
+\name{AdjustedSharpeRatio}
+\alias{AdjustedSharpeRatio}
+\alias{Adusted}
+\alias{ratio}
+\alias{Sharpe}
+\title{Adjusted Sharpe ratio of the return distribution}
+\usage{
+  AdjustedSharpeRatio(R, Rf = 0, period = 12, ...)
+}
+\arguments{
+  \item{R}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of asset returns}
+
+  \item{Rf}{the risk free rate}
+
+  \item{period}{the number of returns in a year (ie 12 for
+  monthly returns, 4 for quaterly returns)}
+
+  \item{\dots}{any other passthru parameters}
+}
+\description{
+  Adjusted Sharpe ratio was introduced by Pezier and White
+  (2006) to adjusts for skewness and kurtosis by
+  incorporating a penalty factor for negative skewness and
+  excess kurtosis.
+}
+\details{
+  \deqn{Adjusted Sharpe Ratio = SR * [1 + (\frac{S}{6}) *
+  SR - (\frac{K - 3}{24}) * SR^2]} {Adjusted Sharpe ratio =
+  SR x [1 + (S/6) x SR - ((K-3) / 24) x SR^2]}
+
+  where \eqn{SR} is the sharpe ratio with data annualized,
+  \eqn{S} is the skewness and \eqn{K} is the kurtosis
+}
+\examples{
+data(portfolio_bacon)
+print(AdustedSharpeRatio(portfolio_bacon[,1])) #expected 0.813
+
+data(managers)
+print(AdustedSharpeRatio(managers['1996']))
+print(AdustedSharpeRatio(managers['1996',1]))
+}
+\author{
+  Matthieu Lestel
+}
+\references{
+  Carl Bacon, \emph{Practical portfolio performance
+  measurement and attribution}, second edition 2008 p.99
+}
+\keyword{distribution}
+\keyword{models}
+\keyword{multivariate}
+\keyword{ts}
+



More information about the Returnanalytics-commits mailing list