[Returnanalytics-commits] r2844 - pkg/PortfolioAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 21 19:36:37 CEST 2013


Author: rossbennett34
Date: 2013-08-21 19:36:36 +0200 (Wed, 21 Aug 2013)
New Revision: 2844

Modified:
   pkg/PortfolioAnalytics/R/extract.efficient.frontier.R
   pkg/PortfolioAnalytics/R/extractstats.R
Log:
Modifying extractStats method for optimize.portfolio.ROI objects. Modifying extract.efficient.frontier to use the max 'mean' as opposed to min 'out'

Modified: pkg/PortfolioAnalytics/R/extract.efficient.frontier.R
===================================================================
--- pkg/PortfolioAnalytics/R/extract.efficient.frontier.R	2013-08-21 05:01:14 UTC (rev 2843)
+++ pkg/PortfolioAnalytics/R/extract.efficient.frontier.R	2013-08-21 17:36:36 UTC (rev 2844)
@@ -68,7 +68,8 @@
     
     result <- foreach(i=1:nrow(set),.inorder=TRUE, .combine=rbind, .errorhandling='remove') %do% {
         tmp<-xtract[which(xtract[,mtc]>=set[i,1] & xtract[,mtc]<set[i,2]),]
-        tmp<-tmp[which.min(tmp[,'out']),]
+        #tmp<-tmp[which.min(tmp[,'out']),]
+        tmp<-tmp[which.max(tmp[,'mean']),]
         #tmp
     }
     return(result)

Modified: pkg/PortfolioAnalytics/R/extractstats.R
===================================================================
--- pkg/PortfolioAnalytics/R/extractstats.R	2013-08-21 05:01:14 UTC (rev 2843)
+++ pkg/PortfolioAnalytics/R/extractstats.R	2013-08-21 17:36:36 UTC (rev 2844)
@@ -232,9 +232,12 @@
 extractStats.optimize.portfolio.ROI <- function(object, prefix=NULL, ...) {
   if(!inherits(object, "optimize.portfolio.ROI")) stop("object must be of class optimize.portfolio.ROI")
   trow<-c(out=object$out, object$weights)
-  result<-trow
   
-  rnames<-c('out',paste('w',names(object$weights),sep='.'))
+  objmeas <- extractObjectiveMeasures(object)
+  objnames <- names(objmeas)
+  obj <- unlist(objmeas)
+  result <- c(obj, trow)
+  rnames<-c(objnames, 'out',paste('w',names(object$weights),sep='.'))
   names(result)<-rnames
   return(result)
 }



More information about the Returnanalytics-commits mailing list