[Returnanalytics-commits] r2999 - in pkg/PortfolioAnalytics: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 5 18:29:00 CEST 2013


Author: rossbennett34
Date: 2013-09-05 18:29:00 +0200 (Thu, 05 Sep 2013)
New Revision: 2999

Removed:
   pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd
Modified:
   pkg/PortfolioAnalytics/R/charts.efficient.frontier.R
   pkg/PortfolioAnalytics/man/chart.Weights.EF.Rd
Log:
Updating documentation for chart.Weights.EF and chart.EfficientFrontier generic methods.

Modified: pkg/PortfolioAnalytics/R/charts.efficient.frontier.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.efficient.frontier.R	2013-09-05 11:25:44 UTC (rev 2998)
+++ pkg/PortfolioAnalytics/R/charts.efficient.frontier.R	2013-09-05 16:29:00 UTC (rev 2999)
@@ -2,7 +2,7 @@
 #' Chart the efficient frontier and risk-return scatter
 #' 
 #' Chart the efficient frontier and risk-return scatter of the assets for 
-#' optimize.portfolio and efficient.frontier objects
+#' optimize.portfolio. or efficient.frontier objects
 #' 
 #' @details
 #' For objects created by optimize.portfolio with 'DEoptim', 'random', or 'pso'
@@ -33,13 +33,13 @@
 #' will be plotted using a risk free rate of 0. Set \code{rf=NULL} to omit 
 #' this from the plot. 
 #' 
-#' @param object object to chart
+#' @param object object of class optimize.portfolio.ROI to chart
+#' @param \dots passthru parameters to \code{\link{plot}}
 #' @param match.col string name of column to use for risk (horizontal axis).
 #' \code{match.col} must match the name of an objective measure in the 
 #' \code{objective_measures} or \code{opt_values} slot in the object created 
 #' by \code{\link{optimize.portfolio}}.
 #' @param n.portfolios number of portfolios to use to plot the efficient frontier
-#' @param \dots passthru parameters to \code{\link{plot}}
 #' @param xlim set the x-axis limit, same as in \code{\link{plot}}
 #' @param ylim set the y-axis limit, same as in \code{\link{plot}}
 #' @param cex.axis A numerical value giving the amount by which the axis should be magnified relative to the default.
@@ -55,17 +55,16 @@
 #' @param pch.assets plotting character of the assets, same as in \code{\link{plot}}
 #' @param cex.assets A numerical value giving the amount by which the asset points and labels should be magnified relative to the default.
 #' @author Ross Bennett
-#' @aliases chart.EfficientFrontier.optimize.portfolio.ROI chart.EfficientFrontier.optimize.portfolio chart.EfficientFrontier.efficient.frontier
+#' @rdname chart.EfficientFrontier
 #' @export
-chart.EfficientFrontier <- function(object, match.col, n.portfolios, ...){
+chart.EfficientFrontier <- function(object, ...){
   UseMethod("chart.EfficientFrontier")
 }
 
-
+#' @rdname chart.EfficientFrontier
 #' @method chart.EfficientFrontier optimize.portfolio.ROI
 #' @S3method chart.EfficientFrontier optimize.portfolio.ROI
-#' @export
-chart.EfficientFrontier.optimize.portfolio.ROI <- function(object, match.col="ES", n.portfolios=25, ..., xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", rf=0, tangent.line=TRUE, cex.legend=0.8, chart.assets=TRUE, labels.assets=TRUE, pch.assets=21, cex.assets=0.8){
+chart.EfficientFrontier.optimize.portfolio.ROI <- function(object, ..., match.col="ES", n.portfolios=25, xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", RAR.text="SR", rf=0, tangent.line=TRUE, cex.legend=0.8, chart.assets=TRUE, labels.assets=TRUE, pch.assets=21, cex.assets=0.8){
   if(!inherits(object, "optimize.portfolio.ROI")) stop("object must be of class optimize.portfolio.ROI")
   
   portf <- object$portfolio
@@ -160,7 +159,7 @@
     points(x.f[idx.maxsr], y.f[idx.maxsr], pch=16)
     # text(x=x.f[idx.maxsr], y=y.f[idx.maxsr], labels="T", pos=4, cex=0.8)
     # Add lengend with max Sharpe Ratio and risk-free rate
-    legend("topleft", paste(rar, " = ", signif(srmax,3), sep = ""), bty = "n", cex=cex.legend)
+    legend("topleft", paste(RAR.text, " = ", signif(srmax,3), sep = ""), bty = "n", cex=cex.legend)
     legend("topleft", inset = c(0,0.05), paste("rf = ", signif(rf,3), sep = ""), bty = "n", cex=cex.legend)
   }
   axis(1, cex.axis = cex.axis, col = element.color)
@@ -168,11 +167,10 @@
   box(col = element.color)
 }
 
-
+#' @rdname chart.EfficientFrontier
 #' @method chart.EfficientFrontier optimize.portfolio
 #' @S3method chart.EfficientFrontier optimize.portfolio
-#' @export
-chart.EfficientFrontier.optimize.portfolio <- function(object, match.col="ES", n.portfolios=25, ..., xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", RAR.text="SR", rf=0, tangent.line=TRUE, cex.legend=0.8, chart.assets=TRUE, labels.assets=TRUE, pch.assets=21, cex.assets=0.8){
+chart.EfficientFrontier.optimize.portfolio <- function(object, ..., match.col="ES", n.portfolios=25, xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", RAR.text="SR", rf=0, tangent.line=TRUE, cex.legend=0.8, chart.assets=TRUE, labels.assets=TRUE, pch.assets=21, cex.assets=0.8){
   # This function will work with objects of class optimize.portfolio.DEoptim,
   # optimize.portfolio.random, and optimize.portfolio.pso
   
@@ -269,43 +267,12 @@
   box(col = element.color)
 }
 
-# ' chart weights along an efficient frontier
-# ' 
-# ' This creates a stacked column chart of the weights of portfolios along an efficient frontier.
-# ' 
-# ' @param object object to chart.
-# ' @param \dots passthru parameters to \code{barplot}.
-# ' @param colorset color palette to use.
-# ' @param n.portfolios number of portfolios to extract along the efficient frontier.
-# ' This is only used for objects of class \code{optimize.portfolio}
-# ' @param by.groups TRUE/FALSE. If TRUE, the weights by group are charted.
-# ' @param match.col match.col string name of column to use for risk (horizontal axis).
-# ' Must match the name of an objective.
-# ' @param main main title used in the plot.
-# ' @param cex.lab The magnification to be used for x-axis and y-axis labels relative to the current setting of 'cex'.
-# ' @param cex.axis The magnification to be used for sizing the axis text relative to the current setting of 'cex', similar to \code{\link{plot}}.
-# ' @param cex.legend The magnification to be used for sizing the legend relative to the current setting of 'cex', similar to \code{\link{plot}}.
-# ' @param legend.labels character vector to use for the legend labels
-# ' @param element.color provides the color for drawing less-important chart elements, such as the box lines, axis lines, etc.
-# ' @param legend.loc NULL, "topright", "right", or "bottomright". If legend.loc is NULL, the legend will not be plotted.
-# ' @author Ross Bennett
-# ' @aliases chart.Weights.EF.efficient.frontier chart.Weights.EF.optimize.portfolio
-# ' @export
 
 #' Chart weights along an efficient frontier
 #' 
-#' This function is a generic method to chart weights along an efficient frontier
+#' This function produces a stacked barplot of weights along the efficient frontier.
 #' 
-#' @param object object to chart
-#' @param \dots any other passthru parameters
-#' @export
-chart.Weights.EF <- function(object, ...){
-  UseMethod("chart.Weights.EF")
-}
-
-#' Chart weights along an efficient frontier for an efficient.frontier object
-#' 
-#' @param object object of class \code{efficient.frontier}
+#' @param object object of class \code{efficient.frontier} or \code{optimize.portfolio}
 #' @param \dots passthru parameters to \code{barplot}.
 #' @param colorset color palette to use
 #' @param n.portfolios number of portfolios to extract along the efficient frontier
@@ -319,6 +286,14 @@
 #' @param element.color provides the color for drawing less-important chart elements, such as the box lines, axis lines, etc.
 #' @param legend.loc NULL, "topright", "right", or "bottomright". If legend.loc is NULL, the legend will not be plotted
 #' @author Ross Bennett
+#' @rdname chart.Weights.EF
+#' @export
+chart.Weights.EF <- function(object, ...){
+  UseMethod("chart.Weights.EF")
+}
+
+
+#' @rdname chart.Weights.EF
 #' @method chart.Weights.EF efficient.frontier
 #' @S3method chart.Weights.EF efficient.frontier
 chart.Weights.EF.efficient.frontier <- function(object, ..., colorset=NULL, n.portfolios=25, by.groups=FALSE, match.col="ES", main="", cex.lab=0.8, cex.axis=0.8, cex.legend=0.8, legend.labels=NULL, element.color="darkgray", legend.loc="topright"){
@@ -443,22 +418,7 @@
   box(col=element.color)
 }
 
-#' Chart weights along an efficient frontier for an efficient.frontier object
-#' 
-#' @param object object of class \code{efficient.frontier}
-#' @param \dots passthru parameters to \code{barplot}.
-#' @param colorset color palette to use
-#' @param n.portfolios number of portfolios to extract along the efficient frontier
-#' @param by.groups TRUE/FALSE. If TRUE, the group weights are charted
-#' @param match.col string name of column to use for risk (horizontal axis). Must match the name of an objective.
-#' @param main title used in the plot.
-#' @param cex.lab The magnification to be used for x-axis and y-axis labels relative to the current setting of 'cex'
-#' @param cex.axis The magnification to be used for sizing the axis text relative to the current setting of 'cex', similar to \code{\link{plot}}
-#' @param cex.legend The magnification to be used for sizing the legend relative to the current setting of 'cex', similar to \code{\link{plot}}
-#' @param legend.labels character vector to use for the legend labels
-#' @param element.color provides the color for drawing less-important chart elements, such as the box lines, axis lines, etc.
-#' @param legend.loc NULL, "topright", "right", or "bottomright". If legend.loc is NULL, the legend will not be plotted
-#' @author Ross Bennett
+#' @rdname chart.Weights.EF
 #' @method chart.Weights.EF optimize.portfolio
 #' @S3method chart.Weights.EF optimize.portfolio
 chart.Weights.EF.optimize.portfolio <- function(object, ..., colorset=NULL, n.portfolios=25, by.groups=FALSE, match.col="ES", main="", cex.lab=0.8, cex.axis=0.8, cex.legend=0.8, legend.labels=NULL, element.color="darkgray", legend.loc="topright"){
@@ -474,10 +434,10 @@
                                         legend.loc=legend.loc)
 }
 
+#' @rdname chart.EfficientFrontier
 #' @method chart.EfficientFrontier efficient.frontier
 #' @S3method chart.EfficientFrontier efficient.frontier
-#' @export
-chart.EfficientFrontier.efficient.frontier <- function(object, match.col="ES", n.portfolios=NULL, ..., xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", RAR.text="SR", rf=0, tangent.line=TRUE, cex.legend=0.8, chart.assets=TRUE, labels.assets=TRUE, pch.assets=21, cex.assets=0.8){
+chart.EfficientFrontier.efficient.frontier <- function(object, ..., match.col="ES", n.portfolios=NULL, xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", RAR.text="SR", rf=0, tangent.line=TRUE, cex.legend=0.8, chart.assets=TRUE, labels.assets=TRUE, pch.assets=21, cex.assets=0.8){
   if(!inherits(object, "efficient.frontier")) stop("object must be of class 'efficient.frontier'")
   
   # get the returns and efficient frontier object

Deleted: pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd	2013-09-05 11:25:44 UTC (rev 2998)
+++ pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd	2013-09-05 16:29:00 UTC (rev 2999)
@@ -1,107 +0,0 @@
-\name{chart.EfficientFrontier}
-\alias{chart.EfficientFrontier}
-\alias{chart.EfficientFrontier.efficient.frontier}
-\alias{chart.EfficientFrontier.optimize.portfolio}
-\alias{chart.EfficientFrontier.optimize.portfolio.ROI}
-\title{Chart the efficient frontier and risk-return scatter}
-\usage{
-  chart.EfficientFrontier(object, match.col, n.portfolios,
-    ...)
-}
-\arguments{
-  \item{object}{object to chart}
-
-  \item{match.col}{string name of column to use for risk
-  (horizontal axis). \code{match.col} must match the name
-  of an objective measure in the \code{objective_measures}
-  or \code{opt_values} slot in the object created by
-  \code{\link{optimize.portfolio}}.}
-
-  \item{n.portfolios}{number of portfolios to use to plot
-  the efficient frontier}
-
-  \item{\dots}{passthru parameters to \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{cex.axis}{A numerical value giving the amount by
-  which the axis should be magnified relative to the
-  default.}
-
-  \item{element.color}{provides the color for drawing
-  less-important chart elements, such as the box lines,
-  axis lines, etc.}
-
-  \item{main}{a main title for the plot}
-
-  \item{RAR.text}{Risk Adjusted Return ratio text to plot
-  in the legend}
-
-  \item{rf}{risk free rate. If \code{rf} is not null, the
-  maximum Sharpe Ratio or modified Sharpe Ratio tangency
-  portfolio will be plotted}
-
-  \item{tangent.line}{TRUE/FALSE to plot the tangent line}
-
-  \item{cex.legend}{A numerical value giving the amount by
-  which the legend should be magnified relative to the
-  default.}
-
-  \item{chart.assets}{TRUE/FALSE to include the assets}
-
-  \item{labels.assets}{TRUE/FALSE to include the asset
-  names in the plot. \code{chart.assets} must be
-  \code{TRUE} to plot asset names}
-
-  \item{pch.assets}{plotting character of the assets, same
-  as in \code{\link{plot}}}
-
-  \item{cex.assets}{A numerical value giving the amount by
-  which the asset points and labels should be magnified
-  relative to the default.}
-}
-\description{
-  Chart the efficient frontier and risk-return scatter of
-  the assets for optimize.portfolio and efficient.frontier
-  objects
-}
-\details{
-  For objects created by optimize.portfolio with 'DEoptim',
-  'random', or 'pso' specified as the optimize_method:
-  \itemize{ \item The efficient frontier plotted is based
-  on the the trace information (sets of portfolios tested
-  by the solver at each iteration) in objects created by
-  \code{optimize.portfolio}. }
-
-  For objects created by optimize.portfolio with 'ROI'
-  specified as the optimize_method: \itemize{ \item The
-  mean-StdDev or mean-etl efficient frontier can be plotted
-  for optimal portfolio objects created by
-  \code{optimize.portfolio}.
-
-  \item If \code{match.col="StdDev"}, the mean-StdDev
-  efficient frontier is plotted.
-
-  \item If \code{match.col="ETL"} (also "ES" or "CVaR"),
-  the mean-etl efficient frontier is plotted. }
-
-  Note that \code{trace=TRUE} must be specified in
-  \code{\link{optimize.portfolio}}
-
-  GenSA does not return any useable trace information for
-  portfolios tested at each iteration, therfore we cannot
-  extract and chart an efficient frontier.
-
-  By default, the tangency portfolio (maximum Sharpe Ratio
-  or modified Sharpe Ratio) will be plotted using a risk
-  free rate of 0. Set \code{rf=NULL} to omit this from the
-  plot.
-}
-\author{
-  Ross Bennett
-}
-

Modified: pkg/PortfolioAnalytics/man/chart.Weights.EF.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.Weights.EF.Rd	2013-09-05 11:25:44 UTC (rev 2998)
+++ pkg/PortfolioAnalytics/man/chart.Weights.EF.Rd	2013-09-05 16:29:00 UTC (rev 2999)
@@ -1,16 +1,72 @@
 \name{chart.Weights.EF}
 \alias{chart.Weights.EF}
+\alias{chart.Weights.EF.efficient.frontier}
+\alias{chart.Weights.EF.optimize.portfolio}
 \title{Chart weights along an efficient frontier}
 \usage{
   chart.Weights.EF(object, ...)
+
+  \method{chart.Weights.EF}{efficient.frontier} (object,
+    ..., colorset = NULL, n.portfolios = 25,
+    by.groups = FALSE, match.col = "ES", main = "",
+    cex.lab = 0.8, cex.axis = 0.8, cex.legend = 0.8,
+    legend.labels = NULL, element.color = "darkgray",
+    legend.loc = "topright")
+
+  \method{chart.Weights.EF}{optimize.portfolio} (object,
+    ..., colorset = NULL, n.portfolios = 25,
+    by.groups = FALSE, match.col = "ES", main = "",
+    cex.lab = 0.8, cex.axis = 0.8, cex.legend = 0.8,
+    legend.labels = NULL, element.color = "darkgray",
+    legend.loc = "topright")
 }
 \arguments{
-  \item{object}{object to chart}
+  \item{object}{object of class \code{efficient.frontier}
+  or \code{optimize.portfolio}}
 
-  \item{\dots}{any other passthru parameters}
+  \item{\dots}{passthru parameters to \code{barplot}.}
+
+  \item{colorset}{color palette to use}
+
+  \item{n.portfolios}{number of portfolios to extract along
+  the efficient frontier}
+
+  \item{by.groups}{TRUE/FALSE. If TRUE, the group weights
+  are charted}
+
+  \item{match.col}{string name of column to use for risk
+  (horizontal axis). Must match the name of an objective.}
+
+  \item{main}{title used in the plot.}
+
+  \item{cex.lab}{The magnification to be used for x-axis
+  and y-axis labels relative to the current setting of
+  'cex'}
+
+  \item{cex.axis}{The magnification to be used for sizing
+  the axis text relative to the current setting of 'cex',
+  similar to \code{\link{plot}}}
+
+  \item{cex.legend}{The magnification to be used for sizing
+  the legend relative to the current setting of 'cex',
+  similar to \code{\link{plot}}}
+
+  \item{legend.labels}{character vector to use for the
+  legend labels}
+
+  \item{element.color}{provides the color for drawing
+  less-important chart elements, such as the box lines,
+  axis lines, etc.}
+
+  \item{legend.loc}{NULL, "topright", "right", or
+  "bottomright". If legend.loc is NULL, the legend will not
+  be plotted}
 }
 \description{
-  This function is a generic method to chart weights along
-  an efficient frontier
+  This function produces a stacked barplot of weights along
+  the efficient frontier.
 }
+\author{
+  Ross Bennett
+}
 



More information about the Returnanalytics-commits mailing list