[Returnanalytics-commits] r2098 - in pkg/PerformanceAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jul 2 17:07:26 CEST 2012
Author: matthieu_lestel
Date: 2012-07-02 17:07:25 +0200 (Mon, 02 Jul 2012)
New Revision: 2098
Added:
pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
Log:
SkewnessKurtosisRatio with examples and documentation
Added: pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R (rev 0)
+++ pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-02 15:07:25 UTC (rev 2098)
@@ -0,0 +1,53 @@
+#' Skewness-Kurtosis ratio of the return distribution
+#'
+#' Skewness-Kurtosis ratio is the division of Skewness by Kurtosis.
+#'
+#' It is used in conjunction with the Sharpe ratio to rank portfolios.
+#' The higher the rate the better.
+#'
+#' \deqn{ SkewnessKurtosisRatio(R , MAR) = \frac{S}{K}}
+#' {SkewnessKurtosisRatio(R, MAR) = S/K}
+#'
+#' where \eqn{S} is the skewness and \eqn{K} is the Kurtosis
+#'
+#' @aliases Skewness-Kurtosis ratio
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param \dots any other passthru parameters
+#' @author Matthieu Lestel
+#' @references Carl Bacon, \emph{Practical portfolio performance measurement
+#' and attribution}, second edition 2008 p.100
+#'
+#' @keywords ts multivariate distribution models
+#' @examples
+#'
+#' data(portfolio_bacon)
+#' print(SkewnessKurtosisRatio(portfolio_bacon)) #expected
+#'
+#' data(managers)
+#' print(SkewnessKurtosisRatio(managers['1996']))
+#' print(SkewnessKurtosisRatio(managers['1996',1])
+#'
+#' @export
+
+SkewnessKurtosisRatio <-
+function (R, ...)
+{
+ R0 <- R
+ R = checkData(R, method="matrix")
+
+ if (ncol(R)==1 || is.null(R) || is.vector(R)) {
+ R = na.omit(R)
+ result = skewness(R) / kurtosis(R, method = "moment")
+ reclass(result, R0)
+ return(result)
+ }
+ else {
+ R = checkData(R)
+ result = apply(R, MARGIN = 2, SkewnessKurtosisRatio, ...)
+ result<-t(result)
+ colnames(result) = colnames(R)
+ rownames(result) = paste("SkewnessKurtosisRatio", sep="")
+ return(result)
+ }
+}
\ No newline at end of file
Added: pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd (rev 0)
+++ pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd 2012-07-02 15:07:25 UTC (rev 2098)
@@ -0,0 +1,47 @@
+\name{SkewnessKurtosisRatio}
+\alias{ratio}
+\alias{Skewness-Kurtosis}
+\alias{SkewnessKurtosisRatio}
+\title{Skewness-Kurtosis ratio of the return distribution}
+\usage{
+ SkewnessKurtosisRatio(R, ...)
+}
+\arguments{
+ \item{R}{an xts, vector, matrix, data frame, timeSeries
+ or zoo object of asset returns}
+
+ \item{\dots}{any other passthru parameters}
+}
+\description{
+ Skewness-Kurtosis ratio is the division of Skewness by
+ Kurtosis.
+}
+\details{
+ It is used in conjunction with the Sharpe ratio to rank
+ portfolios. The higher the rate the better.
+
+ \deqn{ SkewnessKurtosisRatio(R , MAR) = \frac{S}{K}}
+ {SkewnessKurtosisRatio(R, MAR) = S/K}
+
+ where \eqn{S} is the skewness and \eqn{K} is the Kurtosis
+}
+\examples{
+data(portfolio_bacon)
+print(SkewnessKurtosisRatio(portfolio_bacon)) #expected
+
+data(managers)
+print(SkewnessKurtosisRatio(managers['1996']))
+print(SkewnessKurtosisRatio(managers['1996',1])
+}
+\author{
+ Matthieu Lestel
+}
+\references{
+ Carl Bacon, \emph{Practical portfolio performance
+ measurement and attribution}, second edition 2008 p.100
+}
+\keyword{distribution}
+\keyword{models}
+\keyword{multivariate}
+\keyword{ts}
+
More information about the Returnanalytics-commits
mailing list