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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 9 23:50:13 CEST 2014


Author: rossbennett34
Date: 2014-08-09 23:50:12 +0200 (Sat, 09 Aug 2014)
New Revision: 3503

Modified:
   pkg/PortfolioAnalytics/R/constraint_fn_map.R
   pkg/PortfolioAnalytics/R/generics.R
   pkg/PortfolioAnalytics/R/moment.functions.R
   pkg/PortfolioAnalytics/man/rp_transform.Rd
   pkg/PortfolioAnalytics/man/set.portfolio.moments.Rd
   pkg/PortfolioAnalytics/vignettes/portfolio_vignette.Rnw
Log:
cleaning up some vignettes and man files

Modified: pkg/PortfolioAnalytics/R/constraint_fn_map.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraint_fn_map.R	2014-08-08 02:38:34 UTC (rev 3502)
+++ pkg/PortfolioAnalytics/R/constraint_fn_map.R	2014-08-09 21:50:12 UTC (rev 3503)
@@ -408,6 +408,7 @@
 #' @param max_pos_short maximum number of assets with short (i.e. sell) positions
 #' @param leverage maximum leverage exposure where leverage is defined as \code{sum(abs(weights))}
 #' @param max_permutations integer: maximum number of iterations to try for a valid portfolio, default 200
+#' @param weight_seq vector of seed sequence of weights
 #' @return named weighting vector
 #' @author Peter Carl, Brian G. Peterson, Ross Bennett (based on an idea by Pat Burns)
 #' @export

Modified: pkg/PortfolioAnalytics/R/generics.R
===================================================================
--- pkg/PortfolioAnalytics/R/generics.R	2014-08-08 02:38:34 UTC (rev 3502)
+++ pkg/PortfolioAnalytics/R/generics.R	2014-08-09 21:50:12 UTC (rev 3503)
@@ -296,7 +296,7 @@
 #' @method summary portfolio
 #' @export
 summary.portfolio <- function(object, ...){
-  if(!is.portfolio(x)) stop("object passed in is not of class 'portfolio'")
+  if(!is.portfolio(object)) stop("object passed in is not of class 'portfolio'")
   
   out <- list()
   
@@ -308,13 +308,15 @@
   out$enabled_constraints <- list()
   out$disabled_constraints <- list()
   constraints <- object$constraints
-  for(i in 1:length(constraints)){
-    if(constraints[[i]]$enabled){
-      tmp <- length(out$enabled_constraints)
-      out$enabled_constraints[[tmp+1]] <- constraints[[i]]
-    } else {
-      tmp <- length(out$disabled_constraints)
-      out$disabled_constraints[[tmp+1]] <- constraints[[i]]
+  if(length(constraints) >= 1){
+    for(i in 1:length(constraints)){
+      if(constraints[[i]]$enabled){
+        tmp <- length(out$enabled_constraints)
+        out$enabled_constraints[[tmp+1]] <- constraints[[i]]
+      } else {
+        tmp <- length(out$disabled_constraints)
+        out$disabled_constraints[[tmp+1]] <- constraints[[i]]
+      }
     }
   }
   
@@ -322,13 +324,15 @@
   out$enabled_objectives <- list()
   out$disabled_objectives <- list()
   objectives <- object$objectives
-  for(i in 1:length(objectives)){
-    if(objectives[[i]]$enabled){
-      tmp <- length(out$enabled_objectives)
-      out$enabled_objectives[[tmp+1]] <- objectives[[i]]
-    } else {
-      tmp <- length(out$disabled_objectives)
-      out$disabled_objectives[[tmp+1]] <- objectives[[i]]
+  if(length(objectives) >= 1){
+    for(i in 1:length(objectives)){
+      if(objectives[[i]]$enabled){
+        tmp <- length(out$enabled_objectives)
+        out$enabled_objectives[[tmp+1]] <- objectives[[i]]
+      } else {
+        tmp <- length(out$disabled_objectives)
+        out$disabled_objectives[[tmp+1]] <- objectives[[i]]
+      }
     }
   }
   class(out) <- "summary.portfolio"

Modified: pkg/PortfolioAnalytics/R/moment.functions.R
===================================================================
--- pkg/PortfolioAnalytics/R/moment.functions.R	2014-08-08 02:38:34 UTC (rev 3502)
+++ pkg/PortfolioAnalytics/R/moment.functions.R	2014-08-09 21:50:12 UTC (rev 3503)
@@ -149,7 +149,7 @@
 #'   \item{sample: }{sample estimates are used for the moments}
 #'   \item{boudt: }{estimate the second, third, and fourth moments using a 
 #'   statistical factor model based on the work of Kris Boudt.}
-#'   See \code{\link{fit.statistical.factor.model}}
+#'   See \code{\link{statistical.factor.model}}
 #'   \item{black_litterman: }{estimate the first and second moments using the 
 #'   Black Litterman Formula. See \code{\link{black.litterman}}}.
 #' }

Modified: pkg/PortfolioAnalytics/man/rp_transform.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/rp_transform.Rd	2014-08-08 02:38:34 UTC (rev 3502)
+++ pkg/PortfolioAnalytics/man/rp_transform.Rd	2014-08-09 21:50:12 UTC (rev 3503)
@@ -36,6 +36,8 @@
 \item{leverage}{maximum leverage exposure where leverage is defined as \code{sum(abs(weights))}}
 
 \item{max_permutations}{integer: maximum number of iterations to try for a valid portfolio, default 200}
+
+\item{weight_seq}{vector of seed sequence of weights}
 }
 \value{
 named weighting vector

Modified: pkg/PortfolioAnalytics/man/set.portfolio.moments.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/set.portfolio.moments.Rd	2014-08-08 02:38:34 UTC (rev 3502)
+++ pkg/PortfolioAnalytics/man/set.portfolio.moments.Rd	2014-08-09 21:50:12 UTC (rev 3503)
@@ -27,7 +27,7 @@
   \item{sample: }{sample estimates are used for the moments}
   \item{boudt: }{estimate the second, third, and fourth moments using a
   statistical factor model based on the work of Kris Boudt.}
-  See \code{\link{fit.statistical.factor.model}}
+  See \code{\link{statistical.factor.model}}
   \item{black_litterman: }{estimate the first and second moments using the
   Black Litterman Formula. See \code{\link{black.litterman}}}.
 }

Modified: pkg/PortfolioAnalytics/vignettes/portfolio_vignette.Rnw
===================================================================
--- pkg/PortfolioAnalytics/vignettes/portfolio_vignette.Rnw	2014-08-08 02:38:34 UTC (rev 3502)
+++ pkg/PortfolioAnalytics/vignettes/portfolio_vignette.Rnw	2014-08-09 21:50:12 UTC (rev 3503)
@@ -87,9 +87,9 @@
 \section{Adding Constraints to the Portfolio Object}
 Adding constraints to the portfolio object is done with \code{add.constraint}. The \code{add.constraint} function is the main interface for adding and/or updating constraints to the portfolio object. This function allows the user to specify the portfolio to add the constraints to, the type of constraints, arguments for the constraint, and whether or not to enable the constraint (\code{enabled=TRUE} is the default). If updating an existing constraint, the indexnum argument can be specified.
 
-\subsection{Leverage Constraint}
+\subsection{Sum of Weights Constraint}
 
-The \code{leverage} constraint specifies the constraint on the sum of the weights. Aliases for the \code{leverage} constraint type include \code{weight\_sum}, \code{weight}, and \code{leverage}. Here we add a constraint that the weights must sum to 1, or the full investment constraint.
+The \code{weight_sum} constraint specifies the constraint on the sum of the weights. Aliases for the \code{weight\_sum} constraint type include \code{weight} and \code{leverage}. Here we add a constraint that the weights must sum to 1, or the full investment constraint.
 <<tidy=FALSE>>=
 # Add the full investment constraint that specifies the weights must sum to 1.
 pspec <- add.constraint(portfolio=pspec, 
@@ -198,7 +198,7 @@
 print(pspec)
 @
 
-The \code{summary} function gives a more detailed view of the constraints.
+The summary method gives a more detailed view of the constraints.
 <<>>=
 summary(pspec)
 @



More information about the Returnanalytics-commits mailing list