[Returnanalytics-commits] r2878 - pkg/PortfolioAnalytics/sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Aug 24 22:33:49 CEST 2013
Author: rossbennett34
Date: 2013-08-24 22:33:49 +0200 (Sat, 24 Aug 2013)
New Revision: 2878
Modified:
pkg/PortfolioAnalytics/sandbox/testing_efficient_frontier.R
Log:
Adding a couple examples to testing_efficient_frontier
Modified: pkg/PortfolioAnalytics/sandbox/testing_efficient_frontier.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/testing_efficient_frontier.R 2013-08-24 20:16:35 UTC (rev 2877)
+++ pkg/PortfolioAnalytics/sandbox/testing_efficient_frontier.R 2013-08-24 20:33:49 UTC (rev 2878)
@@ -14,6 +14,8 @@
data(edhec)
R <- edhec[, 1:5]
+# change the column names for better legends in plotting
+colnames(R) <- c("CA", "CTAG", "DS", "EM", "EQM")
funds <- colnames(R)
# initial portfolio object
@@ -41,10 +43,16 @@
# run optimize.portfolio and chart the efficient frontier for that object
opt_meanvar <- optimize.portfolio(R=R, portfolio=meanvar.portf, optimize_method="ROI", trace=TRUE)
chart.EfficientFrontier(opt_meanvar, match.col="var", n.portfolios=50)
+# The weights along the efficient frontier can be plotted by passing in the
+# optimize.portfolio output object
+chart.Weights.EF(opt_meanvar, match.col="var")
+# or we can extract the efficient frontier and then plot it
+ef <- extractEfficientFrontier(object=opt_meanvar, match.col="var", n.portfolios=15)
+chart.Weights.EF(ef, match.col="var", colorset=bluemono)
# mean-etl efficient frontier
meanetl.ef <- create.EfficientFrontier(R=R, portfolio=meanetl.portf, type="mean-etl")
-chart.EfficientFrontier(meanetl.ef, match.col="ES", main="mean-ETL Efficient Frontier", type="b", col="blue")
+chart.EfficientFrontier(meanetl.ef, match.col="ES", main="mean-ETL Efficient Frontier", type="l", col="blue")
chart.Weights.EF(meanetl.ef, colorset=bluemono, match.col="ES")
# mean-etl efficient frontier using random portfolios
More information about the Returnanalytics-commits
mailing list