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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 23 03:42:11 CEST 2013


Author: rossbennett34
Date: 2013-08-23 03:42:10 +0200 (Fri, 23 Aug 2013)
New Revision: 2860

Added:
   pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd
Removed:
   pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.ROI.Rd
   pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.Rd
Modified:
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/charts.efficient.frontier.R
Log:
Adding chart.EfficientFrontier as a generic function. Changed the name of the subfunctions to be consistent with naming conventions.

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2013-08-22 22:46:06 UTC (rev 2859)
+++ pkg/PortfolioAnalytics/NAMESPACE	2013-08-23 01:42:10 UTC (rev 2860)
@@ -3,6 +3,9 @@
 export(applyFUN)
 export(box_constraint)
 export(CCCgarch.MM)
+export(chart.EfficientFrontier.optimize.portfolio.ROI)
+export(chart.EfficientFrontier.optimize.portfolio)
+export(chart.EfficientFrontier)
 export(chart.RiskReward.optimize.portfolio.DEoptim)
 export(chart.RiskReward.optimize.portfolio.GenSA)
 export(chart.RiskReward.optimize.portfolio.pso)

Modified: pkg/PortfolioAnalytics/R/charts.efficient.frontier.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.efficient.frontier.R	2013-08-22 22:46:06 UTC (rev 2859)
+++ pkg/PortfolioAnalytics/R/charts.efficient.frontier.R	2013-08-23 01:42:10 UTC (rev 2860)
@@ -1,28 +1,58 @@
 
-#' chart the efficient frontier and risk-reward scatter plot of the assets
+#' chart the efficient frontier and risk-return scatter plot of the assets
 #' 
-#' This function charts the efficient frontier and risk-reward scatter plot of the assets.
-#' The mean-var or mean-etl efficient frontier can be plotted for optimal
-#' portfolio objects created by \code{optimize.portfolio}.
+#' This function charts the efficient frontier and risk-return scatter plot of 
+#' the assets given an object created by \code{optimize.portfolio}.
 #' 
-#' If \code{match.col="var"}, the mean-variance efficient frontier is plotted.
+#' 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}.
+#' }
 #' 
-#' If \code{match.col="ETL"} (also "ES" or "CVaR"), the mean-etl efficient frontier is plotted.
+#' For objects created by optimize.portfolio with 'ROI' specified as the 
+#' optimize_method:
+#' \itemize{
+#'   \item The mean-var or mean-etl efficient frontier can be plotted for optimal
+#'   portfolio objects created by \code{optimize.portfolio}.
 #' 
+#'   \item If \code{match.col="var"}, the mean-variance 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.
+#' 
 #' @param object optimal portfolio created by \code{\link{optimize.portfolio}}
 #' @param match.col string name of column to use for risk (horizontal axis). 
 #' \code{match.col} must match the name of an objective in the \code{portfolio}
 #' object.
-#' 
+#' @param n.portfolios number of portfolios to use to plot the efficient frontier
 #' @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
+#' @param element.color 
 #' @param main a main title for the plot
 #' @param ... passthrough parameters to \code{\link{plot}}
-chart.Efficient.Frontier.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", ...){
+#' @author Ross Bennett
+#' @export
+chart.EfficientFrontier <- function(object, match.col="ES", n.portfolios=25, xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", ...){
+  UseMethod("chart.EfficientFrontier")
+}
+
+#' @rdname chart.EfficientFrontier
+#' @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", ...){
   if(!inherits(object, "optimize.portfolio.ROI")) stop("object must be of class optimize.portfolio.ROI")
   
   portf <- object$portfolio
   R <- object$R
+  if(is.null(R)) stop(paste("Not able to get asset returns from", object))
   wts <- object$weights
   objectclass <- class(object)[1]
   
@@ -78,28 +108,14 @@
   box(col = element.color)
 }
 
-#' chart the efficient frontier and risk-reward scatter plot of the assets
-#' 
-#' This function charts the efficient frontier and risk-reward scatter plot of the assets.
-#' 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}. When running \code{optimize.portfolio},
-#' \code{trace=TRUE} must be specified.
-#' 
-#' @param object optimal portfolio created by \code{\link{optimize.portfolio}}
-#' @param match.col string name of column to use for risk (horizontal axis). 
-#' \code{match.col} must match the name of an objective in the \code{portfolio}
-#' object.
-#' @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 main a main title for the plot
-#' @param ... passthrough parameters to \code{\link{plot}}
-chart.Efficient.Frontier.optimize.portfolio <- function(object, match.col="ES", n.portfolios=25, xlim=NULL, ylim=NULL, cex.axis=0.8, element.color="darkgray", main="Efficient Frontier", ...){
+#' @rdname chart.EfficientFrontier
+#' @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", ...){
   # This function will work with objects of class optimize.portfolio.DEoptim,
   # optimize.portfolio.random, and optimize.portfolio.pso
   
   if(inherits(object, "optimize.portfolio.GenSA")){
-    stop("GenSA does not return any useable trace information for portfolios tested, thus we cannot extract an efficient portfolio")
+    stop("GenSA does not return any useable trace information for portfolios tested, thus we cannot extract an efficient frontier.")
   }
   
   if(!inherits(object, "optimize.portfolio")) stop("object must be of class optimize.portfolio")

Deleted: pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.ROI.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.ROI.Rd	2013-08-22 22:46:06 UTC (rev 2859)
+++ pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.ROI.Rd	2013-08-23 01:42:10 UTC (rev 2860)
@@ -1,42 +0,0 @@
-\name{chart.Efficient.Frontier.optimize.portfolio.ROI}
-\alias{chart.Efficient.Frontier.optimize.portfolio.ROI}
-\title{chart the efficient frontier and risk-reward scatter plot of the assets}
-\usage{
-  chart.Efficient.Frontier.optimize.portfolio.ROI(object,
-    match.col = "ES", n.portfolios = 25, xlim = NULL,
-    ylim = NULL, cex.axis = 0.8,
-    element.color = "darkgray",
-    main = "Efficient Frontier", ...)
-}
-\arguments{
-  \item{object}{optimal portfolio created by
-  \code{\link{optimize.portfolio}}}
-
-  \item{match.col}{string name of column to use for risk
-  (horizontal axis). \code{match.col} must match the name
-  of an objective in the \code{portfolio} object.}
-
-  \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{main}{a main title for the plot}
-
-  \item{...}{passthrough parameters to \code{\link{plot}}}
-}
-\description{
-  This function charts the efficient frontier and
-  risk-reward scatter plot of the assets. The mean-var or
-  mean-etl efficient frontier can be plotted for optimal
-  portfolio objects created by \code{optimize.portfolio}.
-}
-\details{
-  If \code{match.col="var"}, the mean-variance efficient
-  frontier is plotted.
-
-  If \code{match.col="ETL"} (also "ES" or "CVaR"), the
-  mean-etl efficient frontier is plotted.
-}
-

Deleted: pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.Rd	2013-08-22 22:46:06 UTC (rev 2859)
+++ pkg/PortfolioAnalytics/man/chart.Efficient.Frontier.optimize.portfolio.Rd	2013-08-23 01:42:10 UTC (rev 2860)
@@ -1,39 +0,0 @@
-\name{chart.Efficient.Frontier.optimize.portfolio}
-\alias{chart.Efficient.Frontier.optimize.portfolio}
-\title{chart the efficient frontier and risk-reward scatter plot of the assets}
-\usage{
-  chart.Efficient.Frontier.optimize.portfolio(object,
-    match.col = "ES", n.portfolios = 25, xlim = NULL,
-    ylim = NULL, cex.axis = 0.8,
-    element.color = "darkgray",
-    main = "Efficient Frontier", ...)
-}
-\arguments{
-  \item{object}{optimal portfolio created by
-  \code{\link{optimize.portfolio}}}
-
-  \item{match.col}{string name of column to use for risk
-  (horizontal axis). \code{match.col} must match the name
-  of an objective in the \code{portfolio} object.}
-
-  \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{main}{a main title for the plot}
-
-  \item{...}{passthrough parameters to \code{\link{plot}}}
-}
-\description{
-  This function charts the efficient frontier and
-  risk-reward scatter plot of the assets. 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}. When running
-  \code{optimize.portfolio}, \code{trace=TRUE} must be
-  specified.
-}
-

Added: pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd	                        (rev 0)
+++ pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd	2013-08-23 01:42:10 UTC (rev 2860)
@@ -0,0 +1,84 @@
+\name{chart.EfficientFrontier}
+\alias{chart.EfficientFrontier}
+\alias{chart.EfficientFrontier.optimize.portfolio}
+\alias{chart.EfficientFrontier.optimize.portfolio.ROI}
+\title{chart the efficient frontier and risk-return scatter plot of the assets}
+\usage{
+  chart.EfficientFrontier(object, match.col = "ES",
+    n.portfolios = 25, xlim = NULL, ylim = NULL,
+    cex.axis = 0.8, element.color = "darkgray",
+    main = "Efficient Frontier", ...)
+
+  chart.EfficientFrontier.optimize.portfolio.ROI(object,
+    match.col = "ES", n.portfolios = 25, xlim = NULL,
+    ylim = NULL, cex.axis = 0.8,
+    element.color = "darkgray",
+    main = "Efficient Frontier", ...)
+
+  chart.EfficientFrontier.optimize.portfolio(object,
+    match.col = "ES", n.portfolios = 25, xlim = NULL,
+    ylim = NULL, cex.axis = 0.8,
+    element.color = "darkgray",
+    main = "Efficient Frontier", ...)
+}
+\arguments{
+  \item{object}{optimal portfolio created by
+  \code{\link{optimize.portfolio}}}
+
+  \item{match.col}{string name of column to use for risk
+  (horizontal axis). \code{match.col} must match the name
+  of an objective in the \code{portfolio} object.}
+
+  \item{n.portfolios}{number of portfolios to use to plot
+  the efficient frontier}
+
+  \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}{}
+
+  \item{element.color}{}
+
+  \item{main}{a main title for the plot}
+
+  \item{...}{passthrough parameters to \code{\link{plot}}}
+}
+\description{
+  This function charts the efficient frontier and
+  risk-return scatter plot of the assets given an object
+  created by \code{optimize.portfolio}.
+}
+\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-var or mean-etl efficient frontier can be plotted
+  for optimal portfolio objects created by
+  \code{optimize.portfolio}.
+
+  \item If \code{match.col="var"}, the mean-variance
+  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.
+}
+\author{
+  Ross Bennett
+}
+



More information about the Returnanalytics-commits mailing list