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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 6 05:45:04 CEST 2013


Author: rossbennett34
Date: 2013-08-06 05:45:03 +0200 (Tue, 06 Aug 2013)
New Revision: 2726

Added:
   pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.GenSA.Rd
Modified:
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/extractstats.R
Log:
adding extractStats method for GenSA optimization method

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2013-08-06 03:38:07 UTC (rev 2725)
+++ pkg/PortfolioAnalytics/NAMESPACE	2013-08-06 03:45:03 UTC (rev 2726)
@@ -25,6 +25,7 @@
 export(diversification)
 export(extract.efficient.frontier)
 export(extractStats.optimize.portfolio.DEoptim)
+export(extractStats.optimize.portfolio.GenSA)
 export(extractStats.optimize.portfolio.parallel)
 export(extractStats.optimize.portfolio.pso)
 export(extractStats.optimize.portfolio.random)

Modified: pkg/PortfolioAnalytics/R/extractstats.R
===================================================================
--- pkg/PortfolioAnalytics/R/extractstats.R	2013-08-06 03:38:07 UTC (rev 2725)
+++ pkg/PortfolioAnalytics/R/extractstats.R	2013-08-06 03:45:03 UTC (rev 2726)
@@ -297,3 +297,25 @@
   rownames(result) <- paste(prefix, "pso.portf", index(tmp), sep=".")
   return(result)
 }
+
+#' extract some stats from a portfolio list run with GenSA via
+#' \code{\link{optimize.portfolio}}
+#' 
+#' This function will extract the optimal portfolio weights and objective measures
+#' The GenSA output does not store weights evaluated at each iteration
+#' The GenSA output for trace.mat contains nb.steps, temperature, function.value, and current.minimum
+#' 
+#' @param object list returned by optimize.portfolio
+#' @param prefix prefix to add to output row names
+#' @param ... any other passthru parameters
+#' @export 
+extractStats.optimize.portfolio.GenSA <- function(object, prefix=NULL, ...) {
+  
+  trow<-c(out=object$out, object$weights)
+  obj <- unlist(object$objective_measures)
+  result <- c(obj, trow)
+  
+  rnames<-c('out',paste('w',names(object$weights),sep='.'))
+  names(result)<-rnames
+  return(result)
+}

Added: pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.GenSA.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.GenSA.Rd	                        (rev 0)
+++ pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.GenSA.Rd	2013-08-06 03:45:03 UTC (rev 2726)
@@ -0,0 +1,23 @@
+\name{extractStats.optimize.portfolio.GenSA}
+\alias{extractStats.optimize.portfolio.GenSA}
+\title{extract some stats from a portfolio list run with GenSA via
+\code{\link{optimize.portfolio}}}
+\usage{
+  extractStats.optimize.portfolio.GenSA(object,
+    prefix = NULL, ...)
+}
+\arguments{
+  \item{object}{list returned by optimize.portfolio}
+
+  \item{prefix}{prefix to add to output row names}
+
+  \item{...}{any other passthru parameters}
+}
+\description{
+  This function will extract the optimal portfolio weights
+  and objective measures The GenSA output does not store
+  weights evaluated at each iteration The GenSA output for
+  trace.mat contains nb.steps, temperature, function.value,
+  and current.minimum
+}
+



More information about the Returnanalytics-commits mailing list