[Returnanalytics-commits] r3228 - in pkg/PortfolioAnalytics: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 18 03:04:32 CEST 2013
Author: rossbennett34
Date: 2013-10-18 03:04:30 +0200 (Fri, 18 Oct 2013)
New Revision: 3228
Removed:
pkg/PortfolioAnalytics/man/chart.Weights.Rd
Modified:
pkg/PortfolioAnalytics/NAMESPACE
pkg/PortfolioAnalytics/R/chart.RiskReward.R
pkg/PortfolioAnalytics/R/chart.Weights.R
pkg/PortfolioAnalytics/R/charts.DE.R
pkg/PortfolioAnalytics/R/charts.GenSA.R
pkg/PortfolioAnalytics/R/charts.PSO.R
pkg/PortfolioAnalytics/R/charts.ROI.R
pkg/PortfolioAnalytics/R/charts.RP.R
Log:
Adding chart.Weights method for optimize.portfolio.rebalancing objects.
Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/NAMESPACE 2013-10-18 01:04:30 UTC (rev 3228)
@@ -91,6 +91,7 @@
S3method(chart.Weights,optimize.portfolio.GenSA)
S3method(chart.Weights,optimize.portfolio.pso)
S3method(chart.Weights,optimize.portfolio.random)
+S3method(chart.Weights,optimize.portfolio.rebalancing)
S3method(chart.Weights,optimize.portfolio.ROI)
S3method(chart.Weights.EF,efficient.frontier)
S3method(chart.Weights.EF,optimize.portfolio)
Modified: pkg/PortfolioAnalytics/R/chart.RiskReward.R
===================================================================
--- pkg/PortfolioAnalytics/R/chart.RiskReward.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/chart.RiskReward.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -32,8 +32,6 @@
#' @param cex.lab numerical value giving the amount by which the labels should be magnified relative to the default.
#' @param colorset color palette or vector of colors to use.
#' @seealso \code{\link{optimize.portfolio}}
-#' @rdname chart.RiskReward
-#' @name chart.RiskReward
#' @export
chart.RiskReward <- function(object, ...){
UseMethod("chart.RiskReward")
Modified: pkg/PortfolioAnalytics/R/chart.Weights.R
===================================================================
--- pkg/PortfolioAnalytics/R/chart.Weights.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/chart.Weights.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -1,7 +1,12 @@
#' boxplot of the weights of the optimal portfolios
#'
-#' Chart the optimal weights and upper and lower bounds on weights of a portfolio run via \code{\link{optimize.portfolio}}.
+#' This function charts the optimal weights of a portfolio run via
+#' \code{\link{optimize.portfolio}} or \code{\link{optimize.portfolio.rebalancing}}.
+#' The upper and lower bounds on weights can be plotted for single period optimizations.
+#' The optimal weights will be charted through time for \code{optimize.portfolio.rebalancing}
+#' objects. For \code{optimize.portfolio.rebalancing} objects, the weights are
+#' plotted with \code{\link[PerformanceAnalytics]{chart.StackedBar}}.
#'
#' @param object optimal portfolio object created by \code{\link{optimize.portfolio}}.
#' @param neighbors set of 'neighbor' portfolios to overplot. See Details.
@@ -22,12 +27,10 @@
#' @param legend.loc location of the legend. If NULL, the legend will not be plotted.
#' @param cex.legend The magnification to be used for legend annotation relative to the current setting of \code{cex}.
#' @param plot.type "line" or "barplot" to plot.
-#' @seealso \code{\link{optimize.portfolio}}
-#' @rdname chart.Weights
+#' @seealso \code{\link{optimize.portfolio}} \code{\link{optimize.portfolio.rebalancing}} \code{\link[PerformanceAnalytics]{chart.StackedBar}}
#' @name chart.Weights
-#' @aliases chart.Weights.optimize.portfolio.ROI chart.Weights.optimize.portfolio.DEoptim chart.Weights.optimize.portfolio.pso chart.Weights.optimize.portfolio.GenSA
#' @export
-chart.Weights <- function(object, neighbors = NULL, ..., main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8){
+chart.Weights <- function(object, ...){
UseMethod("chart.Weights")
}
@@ -91,3 +94,11 @@
}
box(col=element.color)
}
+
+#' @rdname chart.Weights
+#' @method chart.Weights optimize.portfolio.rebalancing
+#' @S3method chart.Weights optimize.portfolio.rebalancing
+chart.Weights.optimize.portfolio.rebalancing <- function(object, ..., main="Weights"){
+ rebal.weights <- extractWeights(object)
+ chart.StackedBar(w=rebal.weights, main=main, ...)
+}
Modified: pkg/PortfolioAnalytics/R/charts.DE.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.DE.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/charts.DE.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -11,7 +11,7 @@
###############################################################################
-chart.Weights.DE <- function(object, neighbors = NULL, ..., main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
+chart.Weights.DE <- function(object, ..., neighbors = NULL, main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
# Specific to the output of optimize.portfolio with optimize_method="DEoptim"
if(!inherits(object, "optimize.portfolio.DEoptim")) stop("object must be of class 'optimize.portfolio.DEoptim'")
Modified: pkg/PortfolioAnalytics/R/charts.GenSA.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.GenSA.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/charts.GenSA.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -1,5 +1,5 @@
-chart.Weights.GenSA <- function(object, neighbors = NULL, ..., main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
+chart.Weights.GenSA <- function(object, ..., neighbors = NULL, main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
if(!inherits(object, "optimize.portfolio.GenSA")) stop("object must be of class 'optimize.portfolio.GenSA'")
Modified: pkg/PortfolioAnalytics/R/charts.PSO.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.PSO.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/charts.PSO.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -1,5 +1,5 @@
-chart.Weights.pso <- function(object, neighbors = NULL, ..., main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
+chart.Weights.pso <- function(object, ..., neighbors = NULL, main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
if(!inherits(object, "optimize.portfolio.pso")) stop("object must be of class 'optimize.portfolio.pso'")
Modified: pkg/PortfolioAnalytics/R/charts.ROI.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.ROI.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/charts.ROI.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -1,5 +1,5 @@
-chart.Weights.ROI <- function(object, neighbors = NULL, ..., main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
+chart.Weights.ROI <- function(object, ..., neighbors = NULL, main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
if(!inherits(object, "optimize.portfolio.ROI")) stop("object must be of class 'optimize.portfolio.ROI'")
Modified: pkg/PortfolioAnalytics/R/charts.RP.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.RP.R 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/R/charts.RP.R 2013-10-18 01:04:30 UTC (rev 3228)
@@ -10,7 +10,7 @@
#
###############################################################################
-chart.Weights.RP <- function(object, neighbors = NULL, ..., main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
+chart.Weights.RP <- function(object, ..., neighbors = NULL, main="Weights", las = 3, xlab=NULL, cex.lab = 1, element.color = "darkgray", cex.axis=0.8, colorset=NULL, legend.loc="topright", cex.legend=0.8, plot.type="line"){
# Specific to the output of the random portfolio code with constraints
if(!inherits(object, "optimize.portfolio.random")){
stop("object must be of class 'optimize.portfolio.random'")
Deleted: pkg/PortfolioAnalytics/man/chart.Weights.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.Weights.Rd 2013-10-17 23:25:32 UTC (rev 3227)
+++ pkg/PortfolioAnalytics/man/chart.Weights.Rd 2013-10-18 01:04:30 UTC (rev 3228)
@@ -1,107 +0,0 @@
-\name{chart.Weights}
-\alias{chart.Weights}
-\alias{chart.Weights.opt.list}
-\alias{chart.Weights.optimize.portfolio.DEoptim}
-\alias{chart.Weights.optimize.portfolio.GenSA}
-\alias{chart.Weights.optimize.portfolio.pso}
-\alias{chart.Weights.optimize.portfolio.random}
-\alias{chart.Weights.optimize.portfolio.ROI}
-\title{boxplot of the weights of the optimal portfolios}
-\usage{
- \method{chart.Weights}{optimize.portfolio.DEoptim} (object, neighbors = NULL, ..., main = "Weights",
- las = 3, xlab = NULL, cex.lab = 1,
- element.color = "darkgray", cex.axis = 0.8,
- colorset = NULL, legend.loc = "topright",
- cex.legend = 0.8, plot.type = "line")
-
- \method{chart.Weights}{optimize.portfolio.random} (object, neighbors = NULL, ..., main = "Weights",
- las = 3, xlab = NULL, cex.lab = 1,
- element.color = "darkgray", cex.axis = 0.8,
- colorset = NULL, legend.loc = "topright",
- cex.legend = 0.8, plot.type = "line")
-
- \method{chart.Weights}{optimize.portfolio.ROI} (object,
- neighbors = NULL, ..., main = "Weights", las = 3,
- xlab = NULL, cex.lab = 1, element.color = "darkgray",
- cex.axis = 0.8, colorset = NULL,
- legend.loc = "topright", cex.legend = 0.8,
- plot.type = "line")
-
- \method{chart.Weights}{optimize.portfolio.pso} (object,
- neighbors = NULL, ..., main = "Weights", las = 3,
- xlab = NULL, cex.lab = 1, element.color = "darkgray",
- cex.axis = 0.8, colorset = NULL,
- legend.loc = "topright", cex.legend = 0.8,
- plot.type = "line")
-
- \method{chart.Weights}{optimize.portfolio.GenSA} (object,
- neighbors = NULL, ..., main = "Weights", las = 3,
- xlab = NULL, cex.lab = 1, element.color = "darkgray",
- cex.axis = 0.8, colorset = NULL,
- legend.loc = "topright", cex.legend = 0.8,
- plot.type = "line")
-
- chart.Weights(object, neighbors = NULL, ...,
- main = "Weights", las = 3, xlab = NULL, cex.lab = 1,
- element.color = "darkgray", cex.axis = 0.8)
-
- \method{chart.Weights}{opt.list} (object,
- neighbors = NULL, ..., main = "Weights", las = 3,
- xlab = NULL, cex.lab = 1, element.color = "darkgray",
- cex.axis = 0.8, colorset = NULL,
- legend.loc = "topright", cex.legend = 0.8,
- plot.type = "line")
-}
-\arguments{
- \item{object}{optimal portfolio object created by
- \code{\link{optimize.portfolio}}.}
-
- \item{neighbors}{set of 'neighbor' portfolios to
- overplot. See Details.}
-
- \item{\dots}{any other passthru parameters .}
-
- \item{main}{an overall title for the plot: see
- \code{\link{title}}}
-
- \item{las}{numeric in \{0,1,2,3\}; the style of axis
- labels \describe{ \item{0:}{always parallel to the axis,}
- \item{1:}{always horizontal,} \item{2:}{always
- perpendicular to the axis,} \item{3:}{always vertical
- [\emph{default}].} }}
-
- \item{xlab}{a title for the x axis: see
- \code{\link{title}}}
-
- \item{cex.lab}{The magnification to be used for x and y
- labels relative to the current setting of \code{cex}}
-
- \item{element.color}{provides the color for drawing
- less-important chart elements, such as the box lines,
- axis lines, etc.}
-
- \item{cex.axis}{The magnification to be used for axis
- annotation relative to the current setting of
- \code{cex}.}
-
- \item{colorset}{color palette or vector of colors to
- use.}
-
- \item{legend.loc}{location of the legend. If NULL, the
- legend will not be plotted.}
-
- \item{cex.legend}{The magnification to be used for legend
- annotation relative to the current setting of
- \code{cex}.}
-
- \item{plot.type}{"line" or "barplot" to plot.}
-}
-\description{
- Chart the optimal weights and upper and lower bounds on
- weights of a portfolio run via
- \code{\link{optimize.portfolio}}.
-}
-\seealso{
- \code{\link{optimize.portfolio}}
-}
-
More information about the Returnanalytics-commits
mailing list