[Returnanalytics-commits] r1955 - pkg/PerformanceAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 23 18:38:16 CEST 2012
Author: braverock
Date: 2012-05-23 18:38:16 +0200 (Wed, 23 May 2012)
New Revision: 1955
Modified:
pkg/PerformanceAnalytics/R/ActivePremium.R
pkg/PerformanceAnalytics/R/CAPM.alpha.R
pkg/PerformanceAnalytics/R/CAPM.beta.R
pkg/PerformanceAnalytics/R/CalmarRatio.R
pkg/PerformanceAnalytics/R/ES.R
pkg/PerformanceAnalytics/R/MultivariateMoments.R
pkg/PerformanceAnalytics/R/Return.read.R
pkg/PerformanceAnalytics/R/apply.fromstart.R
pkg/PerformanceAnalytics/R/apply.rolling.R
pkg/PerformanceAnalytics/R/chart.BarVaR.R
pkg/PerformanceAnalytics/R/chart.Drawdown.R
pkg/PerformanceAnalytics/R/chart.Events.R
pkg/PerformanceAnalytics/R/chart.Histogram.R
pkg/PerformanceAnalytics/R/chart.QQPlot.R
pkg/PerformanceAnalytics/R/chart.Regression.R
pkg/PerformanceAnalytics/R/chart.RelativePerformance.R
pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R
pkg/PerformanceAnalytics/R/chart.RollingPerformance.R
pkg/PerformanceAnalytics/R/chart.RollingQuantileRegression.R
pkg/PerformanceAnalytics/R/chart.RollingRegression.R
pkg/PerformanceAnalytics/R/chart.SnailTrail.R
pkg/PerformanceAnalytics/R/chart.StackedBar.R
pkg/PerformanceAnalytics/R/chart.TimeSeries.R
pkg/PerformanceAnalytics/R/chart.VaRSensitivity.R
pkg/PerformanceAnalytics/R/charts.Bar.R
pkg/PerformanceAnalytics/R/charts.BarVaR.R
pkg/PerformanceAnalytics/R/findDrawdowns.R
pkg/PerformanceAnalytics/R/mean.utils.R
pkg/PerformanceAnalytics/R/sortDrawdowns.R
pkg/PerformanceAnalytics/R/table.CalendarReturns.R
pkg/PerformanceAnalytics/R/table.DownsideRisk.R
pkg/PerformanceAnalytics/R/table.Drawdowns.R
pkg/PerformanceAnalytics/R/table.MonthlyReturns.R
Log:
- improvements to roxygen docs supporting svn r1954
Modified: pkg/PerformanceAnalytics/R/ActivePremium.R
===================================================================
--- pkg/PerformanceAnalytics/R/ActivePremium.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/ActivePremium.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -25,6 +25,10 @@
#' ActivePremium(managers[,1:6], managers[,8,drop=FALSE])
#' ActivePremium(managers[,1:6], managers[,8:7,drop=FALSE])
#'
+#' @export
+#'
+#'
+
ActivePremium <- function (Ra, Rb, scale = NA)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/CAPM.alpha.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.alpha.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/CAPM.alpha.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -22,14 +22,26 @@
#'
#' # First we load the data
#' data(managers)
-#' CAPM.alpha(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12)
-#' CAPM.alpha(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE])
-#' CAPM.alpha(managers[,1:6], managers[,8,drop=FALSE], Rf=.035/12)
-#' CAPM.alpha(managers[,1:6], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE])
-#' CAPM.alpha(managers[,1:6], managers[,8:7,drop=FALSE], Rf=.035/12)
-#' CAPM.alpha(managers[,1:6], managers[,8:7,drop=FALSE], Rf = managers[,10,drop=FALSE])
+#' CAPM.alpha(managers[,1,drop=FALSE],
+#' managers[,8,drop=FALSE],
+#' Rf=.035/12)
+#' CAPM.alpha(managers[,1,drop=FALSE],
+#' managers[,8,drop=FALSE],
+#' Rf = managers[,10,drop=FALSE])
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8,drop=FALSE],
+#' Rf=.035/12)
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8,drop=FALSE],
+#' Rf = managers[,10,drop=FALSE])
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8:7,drop=FALSE],
+#' Rf=.035/12)
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8:7,drop=FALSE],
+#' Rf = managers[,10,drop=FALSE])
#'
-#'
+#' @export
CAPM.alpha <- function (Ra, Rb, Rf = 0)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/CAPM.beta.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.beta.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/CAPM.beta.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -44,19 +44,43 @@
#' @examples
#'
#' data(managers)
-#' CAPM.alpha(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12)
-#' CAPM.alpha(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE])
-#' CAPM.alpha(managers[,1:6], managers[,8,drop=FALSE], Rf=.035/12)
-#' CAPM.alpha(managers[,1:6], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE])
-#' CAPM.alpha(managers[,1:6], managers[,8:7,drop=FALSE], Rf=.035/12)
-#' CAPM.alpha(managers[,1:6], managers[,8:7,drop=FALSE], Rf = managers[,10,drop=FALSE])
-#' CAPM.beta(managers[, "HAM2", drop=FALSE], managers[, "SP500 TR", drop=FALSE], Rf = managers[, "US 3m TR", drop=FALSE])
-#' CAPM.beta.bull(managers[, "HAM2", drop=FALSE], managers[, "SP500 TR", drop=FALSE], Rf = managers[, "US 3m TR", drop=FALSE])
-#' CAPM.beta.bear(managers[, "HAM2", drop=FALSE], managers[, "SP500 TR", drop=FALSE], Rf = managers[, "US 3m TR", drop=FALSE])
-#' TimingRatio(managers[, "HAM2", drop=FALSE], managers[, "SP500 TR", drop=FALSE], Rf = managers[, "US 3m TR", drop=FALSE])
-#' chart.Regression(managers[, "HAM2", drop=FALSE], managers[, "SP500 TR", drop=FALSE], Rf = managers[, "US 3m TR", drop=FALSE], fit="conditional", main="Conditional Beta")
+#' CAPM.alpha(managers[,1,drop=FALSE],
+#' managers[,8,drop=FALSE],
+#' Rf=.035/12)
+#' CAPM.alpha(managers[,1,drop=FALSE],
+#' managers[,8,drop=FALSE],
+#' Rf = managers[,10,drop=FALSE])
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8,drop=FALSE],
+#' Rf=.035/12)
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8,drop=FALSE],
+#' Rf = managers[,10,drop=FALSE])
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8:7,drop=FALSE],
+#' Rf=.035/12)
+#' CAPM.alpha(managers[,1:6],
+#' managers[,8:7,drop=FALSE],
+#' Rf = managers[,10,drop=FALSE])
+#' CAPM.beta(managers[, "HAM2", drop=FALSE],
+#' managers[, "SP500 TR", drop=FALSE],
+#' Rf = managers[, "US 3m TR", drop=FALSE])
+#' CAPM.beta.bull(managers[, "HAM2", drop=FALSE],
+#' managers[, "SP500 TR", drop=FALSE],
+#' Rf = managers[, "US 3m TR", drop=FALSE])
+#' CAPM.beta.bear(managers[, "HAM2", drop=FALSE],
+#' managers[, "SP500 TR", drop=FALSE],
+#' Rf = managers[, "US 3m TR", drop=FALSE])
+#' TimingRatio(managers[, "HAM2", drop=FALSE],
+#' managers[, "SP500 TR", drop=FALSE],
+#' Rf = managers[, "US 3m TR", drop=FALSE])
+#' chart.Regression(managers[, "HAM2", drop=FALSE],
+#' managers[, "SP500 TR", drop=FALSE],
+#' Rf = managers[, "US 3m TR", drop=FALSE],
+#' fit="conditional",
+#' main="Conditional Beta")
#'
-#'
+#' @export
CAPM.beta <-
function (Ra, Rb, Rf = 0)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/CalmarRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/CalmarRatio.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/CalmarRatio.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -1,7 +1,5 @@
#' calculate a Calmar or Sterling reward/risk ratio
-#'
-#' @aliases SterlingRatio
-#'
+#'
#' Calmar and Sterling Ratios are yet another method of creating a
#' risk-adjusted measure for ranking investments similar to the
#' \code{\link{SharpeRatio}}.
@@ -9,7 +7,7 @@
#' Both the Calmar and the Sterling ratio are the ratio of annualized return
#' over the absolute value of the maximum drawdown of an investment. The
#' Sterling ratio adds an excess risk measure to the maximum drawdown,
-#' traditionally and defaulting to 10%.
+#' traditionally and defaulting to 10\%.
#'
#' It is also traditional to use a three year return series for these
#' calculations, although the functions included here make no effort to
@@ -19,8 +17,8 @@
#'
#' Many other measures have been proposed to do similar reward to risk ranking.
#' It is the opinion of this author that newer measures such as Sortino's
-#' \code{\link{UpsidePotentialRatio}} or Favre's
-#' \code{\link{SharpeRatio.modified}} are both \dQuote{better} measures, and
+#' \code{\link{UpsidePotentialRatio}} or Favre's modified
+#' \code{\link{SharpeRatio}} are both \dQuote{better} measures, and
#' should be preferred to the Calmar or Sterling Ratio.
#'
#' @aliases CalmarRatio SterlingRatio
@@ -29,10 +27,13 @@
#' @param scale number of periods in a year (daily scale = 252, monthly scale =
#' 12, quarterly scale = 4)
#' @param excess for Sterling Ratio, excess amount to add to the max drawdown,
-#' traditionally and default .1 (10%)
+#' traditionally and default .1 (10\%)
#' @author Brian G. Peterson
-#' @seealso \code{\link{Return.annualized}}, \cr \code{\link{maxDrawdown}}, \cr
-#' \code{\link{SharpeRatio.modified}}, \cr \code{\link{UpsidePotentialRatio}}
+#' @seealso
+#' \code{\link{Return.annualized}}, \cr
+#' \code{\link{maxDrawdown}}, \cr
+#' \code{\link{SharpeRatio.modified}}, \cr
+#' \code{\link{UpsidePotentialRatio}}
#' @references Bacon, Carl. \emph{Practical Portfolio Performance Measurement
#' and Attribution}. Wiley. 2004.
#' @keywords ts multivariate distribution models
@@ -44,6 +45,8 @@
#' SterlingRatio(managers[,1,drop=FALSE])
#' SterlingRatio(managers[,1:6])
#'
+#' @export
+#' @rdname CalmarRatio
CalmarRatio <- function (R, scale = NA)
{ # @author Brian G. Peterson
Modified: pkg/PerformanceAnalytics/R/ES.R
===================================================================
--- pkg/PerformanceAnalytics/R/ES.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/ES.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -155,8 +155,8 @@
if (is.null(mu)) { mu = apply(R,2,'mean' ) }
if (is.null(sigma)) { sigma = cov(R) }
if(method=="modified"){
- if (is.null(m3)) {m3 = M3.MM(R,mu=mu,sigma=sigma)}
- if (is.null(m4)) {m4 = M4.MM(R,mu=mu,sigma=sigma)}
+ if (is.null(m3)) {m3 = M3.MM(R,mu=mu)}
+ if (is.null(m4)) {m4 = M4.MM(R,mu=mu)}
}
}
} else {
Modified: pkg/PerformanceAnalytics/R/MultivariateMoments.R
===================================================================
--- pkg/PerformanceAnalytics/R/MultivariateMoments.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/MultivariateMoments.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -1,5 +1,5 @@
###############################################################################
-# Functions to peRform multivariate matrix
+# Functions to perform multivariate matrix
# calculations on portfolios of assets.
#
# I've modified these to minimize the number of
@@ -23,7 +23,7 @@
for(t in c(1:T))
{
centret = as.numeric(matrix(R[t,]-mu,nrow=cAssets,ncol=1))
- M3 = M3 + ( centret%*%t(centret) )%x%t(centret)
+ M3 = M3 + ( centret%*%t(centret) )%x%t(centret)
}
return( 1/T*M3 );
}
Modified: pkg/PerformanceAnalytics/R/Return.read.R
===================================================================
--- pkg/PerformanceAnalytics/R/Return.read.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/Return.read.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -3,20 +3,21 @@
#' A simple wrapper of read.zoo with some defaults for different date formats
#' and xts conversion
#'
-#' The parameter 'format.in' takes several values, including: \describe{
-#' \item{excel}{default date format for MS Excel spreadsheet csv format, which
-#' is "%m/%d/%Y"} \item{oo}{default date format for OpenOffice spreadsheet csv
-#' format, "%m/%d/%y", although this may be operating system dependent}
-#' \item{gnumeric}{default date format for Gnumeric spreadsheet, which is
-#' "%d-%b-%Y"} \item{...}{alternatively, any specific format may be passed in,
-#' such as "%M/%y"} }
+#' The parameter 'format.in' takes several values, including:
+#' \describe{
+#' \item{excel}{default date format for MS Excel spreadsheet csv format, which is "\%m/\%d/\%Y"}
+#' \item{oo}{default date format for OpenOffice spreadsheet csv format, "\%m/\%d/\%y", although this may be operating system dependent}
+#' \item{gnumeric}{default date format for Gnumeric spreadsheet, which is "\%d-\%b-\%Y"}
+#' \item{...}{alternatively, any specific format may be passed in, such as "\%M/\%y"}
+#' }
#'
#' @param filename the name of the file to be read
-#' @param frequency \itemize{ \item "d" sets as a daily timeseries using
-#' \code{\link{as.Date}}, \item "m" sets as monthly timeseries using
-#' \code{\link[zoo]{as.yearmon}}, \item "q" sets as a quarterly timeseries
-#' using \code{\link[zoo]{as.yearqtr}}, and \item "i" sets as irregular
-#' timeseries using \code{\link{as.POSIXct}} }
+#' @param frequency \itemize{
+#' \item "d" sets as a daily timeseries using \code{\link{as.Date}},
+#' \item "m" sets as monthly timeseries using \code{\link[zoo]{as.yearmon}},
+#' \item "q" sets as a quarterly timeseries using \code{\link[zoo]{as.yearqtr}}, and
+#' \item "i" sets as irregular timeseries using \code{\link{as.POSIXct}}
+#' }
#' @param format.in says how the data being read is formatted. Although the
#' default is set to the ISO 8601 standard (which can also be set as "%F"),
#' most spreadsheets have less sensible date formats as defaults. See below.
Modified: pkg/PerformanceAnalytics/R/apply.fromstart.R
===================================================================
--- pkg/PerformanceAnalytics/R/apply.fromstart.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/apply.fromstart.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -21,6 +21,7 @@
#' data(managers)
#' apply.fromstart(managers[,1,drop=FALSE], FUN="mean", width=36)
#'
+#' @export
#'
apply.fromstart <- function (R, FUN = "mean" , gap = 1, ...)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/apply.rolling.R
===================================================================
--- pkg/PerformanceAnalytics/R/apply.rolling.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/apply.rolling.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -25,6 +25,7 @@
#' data(managers)
#' apply.rolling(managers[,1,drop=FALSE], FUN="mean", width=36)
#'
+#' @export
#'
apply.rolling <- function (R, width, trim = TRUE, gap = 12, by = 1, FUN = "mean", ...)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/chart.BarVaR.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.BarVaR.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.BarVaR.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -1,6 +1,6 @@
#' Periodic returns in a bar chart with risk metric overlay
#'
-#' Plots the periodic returns in a bar chart overlayed with a risk metric
+#' Plots the periodic returns as a bar chart overlayed with a risk metric
#' calculation.
#'
#' Note that \code{StdDev} and \code{VaR} are symmetric calculations, so a high
@@ -11,6 +11,10 @@
#' indicate value on the y-axis. Overlays a line to indicate the value of a
#' risk metric calculated at that time period.
#'
+#' \code{charts.BarVaR} places multile bar charts in a single
+#' graphic, with associated risk measures
+#'
+#' @name chart.BarVaR
#' @aliases chart.BarVaR charts.BarVaR
#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
#' asset returns
@@ -74,25 +78,48 @@
#' chart.BarVaR(managers[,1,drop=FALSE], main="Monthly Returns")
#'
#' # with risk line
-#' chart.BarVaR(managers[,1,drop=FALSE], methods="HistoricalVaR", main="... with Empirical VaR from Inception")
+#' chart.BarVaR(managers[,1,drop=FALSE],
+#' methods="HistoricalVaR",
+#' main="... with Empirical VaR from Inception")
#'
#' # with lines for all managers in the sample
-#' chart.BarVaR(managers[,1:6], methods="GaussianVaR", all=TRUE, lty=1, lwd=2, colorset= c("red", rep("gray", 5)), main="... with Gaussian VaR and Estimates for Peers")
+#' chart.BarVaR(managers[,1:6],
+#' methods="GaussianVaR",
+#' all=TRUE, lty=1, lwd=2,
+#' colorset= c("red", rep("gray", 5)),
+#' main="... with Gaussian VaR and Estimates for Peers")
#'
#' # with multiple methods
-#' chart.BarVaR(managers[,1,drop=FALSE],methods=c("HistoricalVaR", "ModifiedVaR", "GaussianVaR"), main="... with Multiple Methods")
+#' chart.BarVaR(managers[,1,drop=FALSE],
+#' methods=c("HistoricalVaR", "ModifiedVaR", "GaussianVaR"),
+#' main="... with Multiple Methods")
#'
#' # cleaned up a bit
-#' chart.BarVaR(managers[,1,drop=FALSE],methods=c("HistoricalVaR", "ModifiedVaR", "GaussianVaR"), lwd=2, ypad=.01, main="... with Padding for Bottom Legend")
+#' chart.BarVaR(managers[,1,drop=FALSE],
+#' methods=c("HistoricalVaR", "ModifiedVaR", "GaussianVaR"),
+#' lwd=2, ypad=.01,
+#' main="... with Padding for Bottom Legend")
#'
#' # with 'cleaned' data for VaR estimates
-#' chart.BarVaR(managers[,1,drop=FALSE],methods=c("HistoricalVaR", "ModifiedVaR"), lwd=2, ypad=.01, clean="boudt", main="... with Robust ModVaR Estimate")
+#' chart.BarVaR(managers[,1,drop=FALSE],
+#' methods=c("HistoricalVaR", "ModifiedVaR"),
+#' lwd=2, ypad=.01, clean="boudt",
+#' main="... with Robust ModVaR Estimate")
#'
-#' # Cornish Fisher VaR estimated with cleaned data, with horizontal line to show exceptions
-#' chart.BarVaR(managers[,1,drop=FALSE],methods="ModifiedVaR", lwd=2, ypad=.01, clean="boudt", show.horizontal=TRUE, lty=2, main="... with Robust ModVaR and Line for Identifying Exceptions")
+#' # Cornish Fisher VaR estimated with cleaned data,
+#' # with horizontal line to show exceptions
+#' chart.BarVaR(managers[,1,drop=FALSE],
+#' methods="ModifiedVaR",
+#' lwd=2, ypad=.01, clean="boudt",
+#' show.horizontal=TRUE, lty=2,
+#' main="... with Robust ModVaR and Line for Identifying Exceptions")
#'
+#' @rdname chart.BarVaR
+#' @export
chart.BarVaR <- function (R, width = 0, gap = 12,
- methods = c("none", "ModifiedVaR", "GaussianVaR", "HistoricalVaR", "StdDev", "ModifiedES", "GaussianES", "HistoricalES"),
+ methods = c("none", "ModifiedVaR", "GaussianVaR",
+ "HistoricalVaR", "StdDev", "ModifiedES",
+ "GaussianES", "HistoricalES"),
p=0.95,
clean = c("none", "boudt","geltner"),
all = FALSE,
Modified: pkg/PerformanceAnalytics/R/chart.Drawdown.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.Drawdown.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.Drawdown.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -18,16 +18,20 @@
#' @param \dots any other passthru parameters
#' @author Peter Carl
#' @seealso
-#'
-#' \code{\link{plot}} \cr \code{\link{chart.TimeSeries}} \cr
-#' \code{\link{findDrawdowns}} \cr \code{\link{sortDrawdowns}} \cr
-#' \code{\link{maxDrawdown}} \cr \code{\link{table.Drawdowns}} \cr
+#' \code{\link{plot}} \cr
+#' \code{\link{chart.TimeSeries}} \cr
+#' \code{\link{findDrawdowns}} \cr
+#' \code{\link{sortDrawdowns}} \cr
+#' \code{\link{maxDrawdown}} \cr
+#' \code{\link{table.Drawdowns}} \cr
#' \code{\link{table.DownsideRisk}}
#' @keywords ts
#' @examples
#'
#' data(edhec)
-#' chart.Drawdown(edhec[,c(1,2)], main="Drawdown from Peak Equity Attained", legend.loc="bottomleft")
+#' chart.Drawdown(edhec[,c(1,2)],
+#' main="Drawdown from Peak Equity Attained",
+#' legend.loc="bottomleft")
#'
chart.Drawdown <-
function (R, geometric = TRUE, legend.loc = NULL, colorset = (1:12), ...)
Modified: pkg/PerformanceAnalytics/R/chart.Events.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.Events.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.Events.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -37,8 +37,14 @@
#' data(managers)
#' R = Drawdowns(managers[,2,drop=FALSE])
#' n = table.Drawdowns(managers[,2,drop=FALSE])
-#' chart.Events(Drawdowns(managers[,2,drop=FALSE]), dates = n$Trough, prior=max(na.omit(n$"To Trough")), post=max(na.omit(n$Recovery)), lwd=2, colorset=redfocus, legend.loc=NULL, main = "Worst Drawdowns")
+#' chart.Events(Drawdowns(managers[,2,drop=FALSE]),
+#' dates = n$Trough,
+#' prior=max(na.omit(n$"To Trough")),
+#' post=max(na.omit(n$Recovery)),
+#' lwd=2, colorset=redfocus, legend.loc=NULL,
+#' main = "Worst Drawdowns")
#'
+#' @export
chart.Events <-
function (R, dates, prior=12, post=12, main = NULL, xlab=NULL, ...)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/chart.Histogram.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.Histogram.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.Histogram.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -14,18 +14,24 @@
#'
#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
#' asset returns
-#' @param breaks one of: \itemize{ \item a vector giving the breakpoints
-#' between histogram cells, \item a single number giving the number of cells
-#' for the histogram, \item a character string naming an algorithm to compute
-#' the number of cells (see \sQuote{Details}), \item a function to compute the
-#' number of cells. } In the last three cases the number is a suggestion only.
+#' @param breaks one of:
+#' \itemize{
+#' \item a vector giving the breakpoints between histogram cells,
+#' \item a single number giving the number of cells for the histogram,
+#' \item a character string naming an algorithm to compute the number of cells (see \sQuote{Details}),
+#' \item a function to compute the number of cells.
+#' }
+#' For the last three the number is a suggestion only.
#' see \code{\link[graphics]{hist}} for details, default "FD"
-#' @param methods what to graph, one or more of: \itemize{ \itemadd.density to
-#' display the density plot \itemadd.normal to display a fitted normal
-#' distibution line over the mean \itemadd.centered to display a fitted normal
-#' line over zero \itemadd.rug to display a rug of the observations
-#' \itemadd.risk to display common risk metrics \itemadd.qqplot to display a
-#' small qqplot in the upper corner of the histogram plot }
+#' @param methods what to graph, one or more of:
+#' \itemize{
+#' \item add.density to display the density plot
+#' \item add.normal to display a fitted normal distibution line over the mean
+#' \item add.centered to display a fitted normal line over zero
+#' \item add.rug to display a rug of the observations
+#' \item add.risk to display common risk metrics
+#' \item add.qqplot to display a small qqplot in the upper corner of the histogram plot
+#' }
#' @param p confidence level for calculation, default p=.99
#' @param probability logical; if TRUE, the histogram graphic is a
#' representation of frequencies, the counts component of the result; if FALSE,
@@ -73,25 +79,66 @@
#' data(edhec)
#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE])
#'
-#' # version with more breaks and the standard close fit density distribution
-#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE], breaks=40, methods = c("add.density", "add.rug") )
+#' # version with more breaks and the
+#' # standard close fit density distribution
+#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE],
+#' breaks=40, methods = c("add.density", "add.rug") )
#'
-#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE], methods = c( "add.density", "add.normal") )
+#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE],
+#' methods = c( "add.density", "add.normal") )
#'
-#' # version with just the histogram and normal distribution centered on 0
-#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE], methods = c( "add.density", "add.centered") )
+#' # version with just the histogram and
+#' # normal distribution centered on 0
+#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE],
+#' methods = c( "add.density", "add.centered") )
#'
-#' # add a rug to the previous plot for more granularity on precisely where the distribution fell
-#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE], methods = c( "add.centered", "add.density", "add.rug") )
+#' # add a rug to the previous plot
+#' # for more granularity on precisely where the distribution fell
+#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE],
+#' methods = c( "add.centered", "add.density", "add.rug") )
#'
-#' # now show a qqplot to give us another view on how normal the data are
-#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE], methods = c( "add.centered", "add.density", "add.rug", "add.qqplot") )
+#' # now show a qqplot to give us another view
+#' # on how normal the data are
+#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE],
+#' methods = c("add.centered","add.density","add.rug","add.qqplot"))
#'
-#' # add risk measure(s) to show where those are in relation to observed returns
-#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE], methods = c("add.density", "add.centered", "add.rug", "add.risk") )
+#' # add risk measure(s) to show where those are
+#' # in relation to observed returns
+#' chart.Histogram(edhec[,'Equity Market Neutral',drop=FALSE],
+#' methods = c("add.density","add.centered","add.rug","add.risk"))
#'
+#' @export
chart.Histogram <-
-function(R, breaks="FD", main = NULL, xlab = "Returns", ylab = "Frequency", methods = c("none","add.density", "add.normal", "add.centered", "add.cauchy", "add.sst", "add.rug", "add.risk", "add.qqplot"), show.outliers = TRUE, colorset = c("lightgray", "#00008F", "#005AFF", "#23FFDC", "#ECFF13", "#FF4A00", "#800000"), border.col = "white", lwd = 2, xlim = NULL, ylim = NULL, element.color="darkgray", note.lines = NULL, note.labels = NULL, note.cex = 0.7, note.color = "darkgray", probability = FALSE, p = 0.95, cex.axis = 0.8, cex.legend = 0.8, cex.lab = 1, cex.main = 1, xaxis=TRUE, yaxis=TRUE, ...)
+function(R,
+ breaks="FD",
+ main = NULL,
+ xlab = "Returns",
+ ylab = "Frequency",
+ methods = c("none","add.density","add.normal",
+ "add.centered","add.cauchy","add.sst",
+ "add.rug","add.risk","add.qqplot"),
+ show.outliers = TRUE,
+ colorset = c("lightgray","#00008F","#005AFF",
+ "#23FFDC","#ECFF13","#FF4A00","#800000"),
+ border.col = "white",
+ lwd = 2,
+ xlim = NULL,
+ ylim = NULL,
+ element.color="darkgray",
+ note.lines = NULL,
+ note.labels = NULL,
+ note.cex = 0.7,
+ note.color = "darkgray",
+ probability = FALSE,
+ p = 0.95,
+ cex.axis = 0.8,
+ cex.legend = 0.8,
+ cex.lab = 1,
+ cex.main = 1,
+ xaxis=TRUE,
+ yaxis=TRUE,
+ ...
+)
{ # @author Peter Carl
# DESCRIPTION:
Modified: pkg/PerformanceAnalytics/R/chart.QQPlot.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.QQPlot.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.QQPlot.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -48,7 +48,9 @@
#' the current setting of 'cex'.
#' @param \dots any other passthru parameters to the distribution function
#' @author John Fox, ported by Peter Carl
-#' @seealso \code{\link[stats]{qqplot}} \cr \code{\link[car]{qq.plot}} \cr
+#' @seealso
+#' \code{\link[stats]{qqplot}} \cr
+#' \code{\link[car]{qq.plot}} \cr
#' \code{\link{plot}}
#' @references main code forked/borrowed/ported from the excellent: \cr Fox,
#' John (2007) \emph{car: Companion to Applied Regression} \cr
Modified: pkg/PerformanceAnalytics/R/chart.Regression.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.Regression.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.Regression.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -45,7 +45,11 @@
#' @examples
#'
#' data(managers)
-#' chart.Regression(managers[, 1:2, drop = FALSE], managers[, 8, drop = FALSE], Rf = managers[, 10, drop = FALSE], excess.returns = TRUE, fit = c("loess", "linear"), legend.loc = "topleft")
+#' chart.Regression(managers[, 1:2, drop = FALSE],
+#' managers[, 8, drop = FALSE],
+#' Rf = managers[, 10, drop = FALSE],
+#' excess.returns = TRUE, fit = c("loess", "linear"),
+#' legend.loc = "topleft")
#'
chart.Regression <-
function (Ra, Rb, Rf = 0, excess.returns = FALSE, reference.grid = TRUE, main = "Title", ylab=NULL, xlab=NULL, xlim = NA, colorset = 1:12, symbolset = 1:12, element.color = "darkgray", legend.loc = NULL, ylog = FALSE, fit = c("loess", "linear", "conditional", "quadratic"), span = 2/3, degree = 1, family = c("symmetric", "gaussian"), ylim = NA, evaluation = 50, legend.cex= 0.8, cex = 0.8, lwd = 2, ...)
Modified: pkg/PerformanceAnalytics/R/chart.RelativePerformance.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RelativePerformance.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.RelativePerformance.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -35,7 +35,10 @@
#' @examples
#'
#' data(managers)
-#' chart.RelativePerformance(managers[, 1:6, drop=FALSE], managers[, 8, drop=FALSE], colorset=rich8equal, legend.loc="bottomright", main="Relative Performance to S&P")
+#' chart.RelativePerformance(managers[, 1:6, drop=FALSE],
+#' managers[, 8, drop=FALSE],
+#' colorset=rich8equal, legend.loc="bottomright",
+#' main="Relative Performance to S&P")
#'
chart.RelativePerformance <-
function (Ra, Rb, main = "Relative Performance", xaxis = TRUE, colorset = (1:12), legend.loc = NULL, ylog = FALSE, elementcolor = "darkgray", lty = 1, cex.legend=.7, ...)
Modified: pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -22,7 +22,10 @@
#'
#' # First we get the data
#' data(managers)
-#' chart.RollingCorrelation(managers[, 1:6, drop=FALSE], managers[, 8, drop=FALSE], colorset=rich8equal, legend.loc="bottomright", width=24, main = "Rolling 12-Month Correlation")
+#' chart.RollingCorrelation(managers[, 1:6, drop=FALSE],
+#' managers[, 8, drop=FALSE],
+#' colorset=rich8equal, legend.loc="bottomright",
+#' width=24, main = "Rolling 12-Month Correlation")
#'
chart.RollingCorrelation <-
function (Ra, Rb, width = 12, xaxis = TRUE, legend.loc = NULL, colorset = (1:12), na.pad = FALSE, ...)
Modified: pkg/PerformanceAnalytics/R/chart.RollingPerformance.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingPerformance.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.RollingPerformance.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -24,8 +24,14 @@
#'
#' data(edhec)
#' chart.RollingPerformance(edhec[, 1:3], width = 24)
-#' chart.RollingPerformance(edhec[, 1:3], FUN = 'mean', width = 24, colorset = rich8equal, lwd = 2, legend.loc = "topleft", main = "Rolling 24-Month Mean Return")
-#' chart.RollingPerformance(edhec[, 1:3], FUN = 'SharpeRatio.annualized', width = 24, colorset = rich8equal, lwd = 2, legend.loc = "topleft", main = "Rolling 24-Month Sharpe Ratio")
+#' chart.RollingPerformance(edhec[, 1:3],
+#' FUN = 'mean', width = 24, colorset = rich8equal,
+#' lwd = 2, legend.loc = "topleft",
+#' main = "Rolling 24-Month Mean Return")
+#' chart.RollingPerformance(edhec[, 1:3],
+#' FUN = 'SharpeRatio.annualized', width = 24,
+#' colorset = rich8equal, lwd = 2, legend.loc = "topleft",
+#' main = "Rolling 24-Month Sharpe Ratio")
#'
chart.RollingPerformance <- function (R, width = 12, FUN = "Return.annualized", ..., na.pad = TRUE, ylim=NULL, main=NULL)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/chart.RollingQuantileRegression.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingQuantileRegression.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.RollingQuantileRegression.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -1,3 +1,4 @@
+#' @rdname chart.RollingRegression
chart.RollingQuantileRegression <-
function (Ra, Rb, width = 12, Rf = 0, attribute = c("Beta", "Alpha", "R-Squared"), main=NULL, na.pad = TRUE, ...)
{ # @author Peter Carl, Brian Peterson
Modified: pkg/PerformanceAnalytics/R/chart.RollingRegression.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingRegression.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.RollingRegression.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -43,13 +43,20 @@
#'
#' # First we load the data
#' data(managers)
-#' chart.RollingRegression(managers[, 1, drop=FALSE], managers[, 8, drop=FALSE], Rf = .04/12)
-#' charts.RollingRegression(managers[, 1:6], managers[, 8, drop=FALSE], Rf = .04/12, colorset = rich6equal, legend.loc="topleft")
+#' chart.RollingRegression(managers[, 1, drop=FALSE],
+#' managers[, 8, drop=FALSE], Rf = .04/12)
+#' charts.RollingRegression(managers[, 1:6],
+#' managers[, 8, drop=FALSE], Rf = .04/12,
+#' colorset = rich6equal, legend.loc="topleft")
#' dev.new()
-#' chart.RollingQuantileRegression(managers[, 1, drop=FALSE], managers[, 8, drop=FALSE], Rf = .04/12)
+#' chart.RollingQuantileRegression(managers[, 1, drop=FALSE],
+#' managers[, 8, drop=FALSE], Rf = .04/12)
#' # not implemented yet
-#' #charts.RollingQuantileRegression(managers[, 1:6], managers[, 8, drop=FALSE], Rf = .04/12, colorset = rich6equal, legend.loc="topleft")
+#' #charts.RollingQuantileRegression(managers[, 1:6],
+#' managers[, 8, drop=FALSE], Rf = .04/12,
+#' colorset = rich6equal, legend.loc="topleft")
#'
+#' @export
chart.RollingRegression <-
function (Ra, Rb, width = 12, Rf = 0, attribute = c("Beta", "Alpha", "R-Squared"), main=NULL, na.pad = TRUE, ...)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/chart.SnailTrail.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.SnailTrail.R 2012-05-23 15:47:57 UTC (rev 1954)
+++ pkg/PerformanceAnalytics/R/chart.SnailTrail.R 2012-05-23 16:38:16 UTC (rev 1955)
@@ -50,7 +50,12 @@
#' @examples
#'
#' data(managers)
-#' chart.SnailTrail(managers[,c("HAM2","SP500 TR"),drop=FALSE], width=36, stepsize=12, colorset=c('red','orange'),add.names="firstandlast", rf=.04/12, main="Trailing 36-month Performance Calc'd Every 12 Months")
+#' chart.SnailTrail(managers[,c("HAM2","SP500 TR"),drop=FALSE],
+#' width=36, stepsize=12,
+#' colorset=c('red','orange'),
+#' add.names="firstandlast",
+#' rf=.04/12,
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/returnanalytics -r 1955
More information about the Returnanalytics-commits
mailing list