[Returnanalytics-commits] r1990 - in pkg/PerformanceAnalytics: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 6 22:18:48 CEST 2012
Author: braverock
Date: 2012-06-06 22:18:48 +0200 (Wed, 06 Jun 2012)
New Revision: 1990
Modified:
pkg/PerformanceAnalytics/DESCRIPTION
pkg/PerformanceAnalytics/R/chart.QQPlot.R
pkg/PerformanceAnalytics/man/DownsideDeviation.Rd
pkg/PerformanceAnalytics/man/chart.ECDF.Rd
pkg/PerformanceAnalytics/man/chart.QQPlot.Rd
Log:
- update roxygen docs. bump version
Modified: pkg/PerformanceAnalytics/DESCRIPTION
===================================================================
--- pkg/PerformanceAnalytics/DESCRIPTION 2012-06-06 18:18:50 UTC (rev 1989)
+++ pkg/PerformanceAnalytics/DESCRIPTION 2012-06-06 20:18:48 UTC (rev 1990)
@@ -31,8 +31,8 @@
License: GPL
URL: http://r-forge.r-project.org/projects/returnanalytics/
Copyright: (c) 2004-2012
-Contributors: Kris Boudt, Diethelm Wuertz, Eric Zivot
-Thanks: A special thanks for contributions from
+Contributors: Kris Boudt, Diethelm Wuertz, Eric Zivot, Matthieu Lestel
+Thanks: A special thanks for additional contributions from
Stefan Albrecht, Khahn Nygyen, Jeff Ryan,
Josh Ulrich, Sankalp Upadhyay, Tobias Verbeke,
H. Felix Wittmann, Ram Ahluwalia
Modified: pkg/PerformanceAnalytics/R/chart.QQPlot.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.QQPlot.R 2012-06-06 18:18:50 UTC (rev 1989)
+++ pkg/PerformanceAnalytics/R/chart.QQPlot.R 2012-06-06 20:18:48 UTC (rev 1990)
@@ -62,22 +62,34 @@
#'
#' library(MASS)
#' data(managers)
+#'
#' x = checkData(managers[,2, drop = FALSE], na.rm = TRUE, method = "vector")
+#'
#' #layout(rbind(c(1,2),c(3,4)))
+#'
#' # Panel 1, Normal distribution
#' chart.QQPlot(x, main = "Normal Distribution", distribution = 'norm', envelope=0.95)
#' # Panel 2, Log-Normal distribution
#' fit = fitdistr(1+x, 'lognormal')
-#' chart.QQPlot(1+x, main = "Log-Normal Distribution", envelope=0.95, distribution='lnorm')#, meanlog = fit$estimate[[1]], sdlog = fit$estimate[[2]])
+#' chart.QQPlot(1+x, main = "Log-Normal Distribution", envelope=0.95, distribution='lnorm')
+#' #other options could include
+#' #, meanlog = fit$estimate[[1]], sdlog = fit$estimate[[2]])
+#'
#' \dontrun{
#' # Panel 3, Skew-T distribution
#' library(sn)
#' fit = st.mle(y=x)
-#' chart.QQPlot(x, main = "Skew T Distribution", envelope=0.95, distribution = 'st', location = fit$dp[[1]], scale = fit$dp[[2]], shape = fit$dp[[3]], df=fit$dp[[4]])
+#' chart.QQPlot(x, main = "Skew T Distribution", envelope=0.95,
+#' distribution = 'st', location = fit$dp[[1]],
+#' scale = fit$dp[[2]], shape = fit$dp[[3]], df=fit$dp[[4]])
+#'
#' #Panel 4: Stable Parietian
#' library(fBasics)
#' fit.stable = stableFit(x,doplot=FALSE)
-#' chart.QQPlot(x, main = "Stable Paretian Distribution", envelope=0.95, distribution = 'stable', alpha = fit.stable at fit$estimate[[1]], beta = fit.stable at fit$estimate[[2]], gamma = fit.stable at fit$estimate[[3]], delta = fit.stable at fit$estimate[[4]], pm = 0)
+#' chart.QQPlot(x, main = "Stable Paretian Distribution", envelope=0.95,
+#' distribution = 'stable', alpha = fit(stable.fit)$estimate[[1]],
+#' beta = fit(stable.fit)$estimate[[2]], gamma = fit(stable.fit)$estimate[[3]],
+#' delta = fit(stable.fit)$estimate[[4]], pm = 0)
#' }
#' #end examples
#'
Modified: pkg/PerformanceAnalytics/man/DownsideDeviation.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/DownsideDeviation.Rd 2012-06-06 18:18:50 UTC (rev 1989)
+++ pkg/PerformanceAnalytics/man/DownsideDeviation.Rd 2012-06-06 20:18:48 UTC (rev 1990)
@@ -6,7 +6,7 @@
\title{downside risk (deviation, variance) of the return distribution}
\usage{
DownsideDeviation(R, MAR = 0,
- method = c("subset", "full"), ..., potential = FALSE)
+ method = c("full", "subset"), ..., potential = FALSE)
}
\arguments{
\item{R}{an xts, vector, matrix, data frame, timeSeries
@@ -34,7 +34,10 @@
positive returns when calculating risk. Instead of using
the mean return or zero, it uses the Minimum Acceptable
Return as proposed by Sharpe (which may be the mean
- historical return or zero).
+ historical return or zero). It measures the the
+ variability of underperformance below a minimum targer
+ rate. The downside variance is the square of the downside
+ potential.
To calculate it, we take the subset of returns that are
less than the target (or Minimum Acceptable Returns
@@ -42,9 +45,15 @@
target. We sum the squares and divide by the total
number of returns to get a below-target semi-variance.
- \deqn{ DownsideDeviation(R , MAR)= \delta_{MAR} = \sqrt{
- \frac{\sum^{n}_{t=1}(R_{t} - MAR)^{2}}{n} } }
+ \deqn{ DownsideDeviation(R , MAR)= \delta_{MAR} =
+ \sqrt{\sum^{n}_{t=1}\frac{ min[(R_{t} - MAR), 0]^2}{n}}}
+ \deqn{ DownsideVariance(R, MAR) =
+ \sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]^2} {n}}
+
+ \deqn{DownsidePotential(R, MAR) =
+ \sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]} {n}}
+
where \eqn{n} is either the number of observations of the
entire series or the number of observations in the subset
of the series falling below the MAR.
@@ -84,6 +93,15 @@
contribution of this nature.
}
\examples{
+#with data used in Bacon 2008
+
+portfolio_return <- c(0.3,2.6,1.1,-1.0,1.5,2.5,1.6,6.7,-1.4,4.0,-0.5,8.1,4.0,-3.7,-6.1,1.7,-4.9,-2.2,7.0,5.8,-6.5,2.4,-0.5,-0.9)
+MAR = 0.5
+DownsideDeviation(portfolio_return, MAR) #expected 2.55
+DownsidePotential(portfolio_return, MAR) #expected 1.37
+
+#with data of managers
+
data(managers)
apply(managers[,1:6], 2, sd, na.rm=TRUE)
DownsideDeviation(managers[,1:6]) # MAR 0\%
@@ -94,12 +112,14 @@
SemiVariance (managers[,1:6]) #calculated using method="subset"
}
\author{
- Peter Carl, Brian G. Peterson
+ Peter Carl, Brian G. Peterson, Matthieu Lestel
}
\references{
Sortino, F. and Price, L. Performance Measurement in a
Downside Risk Framework. \emph{Journal of Investing}.
- Fall 1994, 59-65. \cr
+ Fall 1994, 59-65. \cr Carl Bacon, \emph{Practical
+ portfolio performance measurement and attribution},
+ second edition 2008
Plantinga, A., van der Meer, R. and Sortino, F. The
Impact of Downside Risk on Risk-Adjusted Performance of
Modified: pkg/PerformanceAnalytics/man/chart.ECDF.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/chart.ECDF.Rd 2012-06-06 18:18:50 UTC (rev 1989)
+++ pkg/PerformanceAnalytics/man/chart.ECDF.Rd 2012-06-06 20:18:48 UTC (rev 1990)
@@ -4,8 +4,8 @@
\usage{
chart.ECDF(R, main = "Empirical CDF", xlab = "x",
ylab = "F(x)", colorset = c("black", "#005AFF"),
- lwd = 1, xlim = NULL, ylim = NULL, lty = c(1, 1),
- element.color = "darkgray", ...)
+ lwd = 1, lty = c(1, 1), element.color = "darkgray",
+ xaxis = TRUE, yaxis = TRUE, ...)
}
\arguments{
\item{R}{an xts, vector, matrix, data frame, timeSeries
@@ -20,6 +20,10 @@
\item{ylab}{set the y-axis label, same as in
\code{\link{plot}}}
+ \item{xaxis}{if true, draws the x axis}
+
+ \item{yaxis}{if true, draws the y axis}
+
\item{colorset}{color palette to use, defaults to
c("black", "\#005AFF"), where first value is used to
color the step function and the second color is used for
@@ -28,12 +32,6 @@
\item{lwd}{set the line width, same as in
\code{\link{plot}}}
- \item{xlim}{set the x-axis limit, same as in
- \code{\link{plot}}}
-
- \item{ylim}{set the y-axis limit, same as in
- \code{\link{plot}}}
-
\item{element.color}{specify the color of chart elements.
Default is "darkgray"}
Modified: pkg/PerformanceAnalytics/man/chart.QQPlot.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/chart.QQPlot.Rd 2012-06-06 18:18:50 UTC (rev 1989)
+++ pkg/PerformanceAnalytics/man/chart.QQPlot.Rd 2012-06-06 20:18:48 UTC (rev 1990)
@@ -98,23 +98,36 @@
\examples{
library(MASS)
data(managers)
+
x = checkData(managers[,2, drop = FALSE], na.rm = TRUE, method = "vector")
+
#layout(rbind(c(1,2),c(3,4)))
+
# Panel 1, Normal distribution
chart.QQPlot(x, main = "Normal Distribution", distribution = 'norm', envelope=0.95)
# Panel 2, Log-Normal distribution
fit = fitdistr(1+x, 'lognormal')
-chart.QQPlot(1+x, main = "Log-Normal Distribution", envelope=0.95, distribution='lnorm')#, meanlog = fit$estimate[[1]], sdlog = fit$estimate[[2]])
+chart.QQPlot(1+x, main = "Log-Normal Distribution", envelope=0.95, distribution='lnorm')
+#other options could include
+#, meanlog = fit$estimate[[1]], sdlog = fit$estimate[[2]])
+
\dontrun{
# Panel 3, Skew-T distribution
library(sn)
fit = st.mle(y=x)
-chart.QQPlot(x, main = "Skew T Distribution", envelope=0.95, distribution = 'st', location = fit$dp[[1]], scale = fit$dp[[2]], shape = fit$dp[[3]], df=fit$dp[[4]])
+chart.QQPlot(x, main = "Skew T Distribution", envelope=0.95,
+ distribution = 'st', location = fit$dp[[1]],
+ scale = fit$dp[[2]], shape = fit$dp[[3]], df=fit$dp[[4]])
+
#Panel 4: Stable Parietian
library(fBasics)
fit.stable = stableFit(x,doplot=FALSE)
-chart.QQPlot(x, main = "Stable Paretian Distribution", envelope=0.95, distribution = 'stable', alpha = fit.stable
+chart.QQPlot(x, main = "Stable Paretian Distribution", envelope=0.95,
+ distribution = 'stable', alpha = fit(stable.fit)$estimate[[1]],
+ beta = fit(stable.fit)$estimate[[2]], gamma = fit(stable.fit)$estimate[[3]],
+ delta = fit(stable.fit)$estimate[[4]], pm = 0)
}
+#end examples
}
\author{
John Fox, ported by Peter Carl
More information about the Returnanalytics-commits
mailing list