[Returnanalytics-commits] r3106 - pkg/PortfolioAnalytics/sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Sep 14 19:26:06 CEST 2013
Author: rossbennett34
Date: 2013-09-14 19:26:06 +0200 (Sat, 14 Sep 2013)
New Revision: 3106
Modified:
pkg/PortfolioAnalytics/sandbox/rp_method_comparison.R
Log:
Adding comparison of sample vs simplex method for random portfolios.
Modified: pkg/PortfolioAnalytics/sandbox/rp_method_comparison.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/rp_method_comparison.R 2013-09-14 11:10:00 UTC (rev 3105)
+++ pkg/PortfolioAnalytics/sandbox/rp_method_comparison.R 2013-09-14 17:26:06 UTC (rev 3106)
@@ -45,3 +45,19 @@
ylab="mean", xlab="StdDev", col=rgb(0, 0, 100, 50, maxColorValue=255))
}
par(mfrow=c(1,1))
+
+# charts to compare simplex and sample random portfolio generation
+par(mfrow=c(1, 2))
+# simplex
+rp_simplex <- random_portfolios(portfolio=pspec, permutations=2000, rp_method='simplex', fev=0:5)
+tmp.mean <- apply(rp_simplex, 1, function(x) mean(R %*% x))
+tmp.StdDev <- apply(rp_simplex, 1, function(x) StdDev(R=R, weights=x))
+plot(x=tmp.StdDev, y=tmp.mean, main="rp_method=simplex fev=0:5",
+ ylab="mean", xlab="StdDev", col=rgb(0, 0, 100, 50, maxColorValue=255))
+#sample
+rp_sample <- random_portfolios(portfolio=pspec, permutations=2000, rp_method='sample')
+tmp.mean <- apply(rp_sample, 1, function(x) mean(R %*% x))
+tmp.StdDev <- apply(rp_sample, 1, function(x) StdDev(R=R, weights=x))
+plot(x=tmp.StdDev, y=tmp.mean, main="rp_method=sample",
+ ylab="mean", xlab="StdDev", col=rgb(0, 0, 100, 50, maxColorValue=255))
+par(mfrow=c(1,1))
More information about the Returnanalytics-commits
mailing list