[Uwgarp-commits] r121 - in pkg/GARPFRM: R man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 22 05:03:26 CET 2014


Author: rossbennett34
Date: 2014-03-22 05:03:15 +0100 (Sat, 22 Mar 2014)
New Revision: 121

Modified:
   pkg/GARPFRM/R/efficient_frontier.R
   pkg/GARPFRM/man/plot.efficient.frontier.Rd
   pkg/GARPFRM/vignettes/DelineatingEfficientPortfolios.Rnw
   pkg/GARPFRM/vignettes/DelineatingEfficientPortfolios.pdf
Log:
Updating efficient frontier plot code and vignette

Modified: pkg/GARPFRM/R/efficient_frontier.R
===================================================================
--- pkg/GARPFRM/R/efficient_frontier.R	2014-03-15 19:43:23 UTC (rev 120)
+++ pkg/GARPFRM/R/efficient_frontier.R	2014-03-22 04:03:15 UTC (rev 121)
@@ -259,6 +259,7 @@
 #' @param \dots passthrough parameters
 #' @param rf risk free rate
 #' @param chartAssets TRUE/FALSE to include the assets in the plot
+#' @param labelAssets TRUE/FALSE to include the labels of the assets in the plot
 #' @param main a main title for the plot
 #' @param xlim set the x-axis limit, same as in \code{plot}
 #' @param ylim set the x-axis limit, same as in \code{plot}
@@ -269,12 +270,15 @@
 #' @method plot efficient.frontier
 #' @S3method plot efficient.frontier
 plot.efficient.frontier <- function(x, y, ..., rf=0, chartAssets=TRUE, 
+                                    labelAssets=TRUE,
                                     main="Efficient Frontier", 
                                     xlim=NULL, ylim=NULL, type="l",
                                     pchAssets=19, cexAssets=0.8){
   chart.EfficientFrontier(object=x, ...=..., match.col="StdDev", 
                           xlim=xlim, ylim=ylim, type=type, cex.axis=0.8, 
                           main=main, rf=rf, tangent.line=TRUE, 
-                          chart.assets=chartAssets, pch.assets=pchAssets, 
+                          chart.assets=chartAssets, 
+                          labels.assets=labelAssets,
+                          pch.assets=pchAssets, 
                           cex.assets=cexAssets)
 }

Modified: pkg/GARPFRM/man/plot.efficient.frontier.Rd
===================================================================
--- pkg/GARPFRM/man/plot.efficient.frontier.Rd	2014-03-15 19:43:23 UTC (rev 120)
+++ pkg/GARPFRM/man/plot.efficient.frontier.Rd	2014-03-22 04:03:15 UTC (rev 121)
@@ -3,9 +3,9 @@
 \title{Efficient Frontier Plot}
 \usage{
   \method{plot}{efficient.frontier} (x, y, ..., rf = 0,
-    chartAssets = TRUE, main = "Efficient Frontier",
-    xlim = NULL, ylim = NULL, type = "l", pchAssets = 19,
-    cexAssets = 0.8)
+    chartAssets = TRUE, labelAssets = TRUE,
+    main = "Efficient Frontier", xlim = NULL, ylim = NULL,
+    type = "l", pchAssets = 19, cexAssets = 0.8)
 }
 \arguments{
   \item{x}{object of class \code{efficient.frontier}}
@@ -19,6 +19,9 @@
   \item{chartAssets}{TRUE/FALSE to include the assets in
   the plot}
 
+  \item{labelAssets}{TRUE/FALSE to include the labels of
+  the assets in the plot}
+
   \item{main}{a main title for the plot}
 
   \item{xlim}{set the x-axis limit, same as in \code{plot}}

Modified: pkg/GARPFRM/vignettes/DelineatingEfficientPortfolios.Rnw
===================================================================
--- pkg/GARPFRM/vignettes/DelineatingEfficientPortfolios.Rnw	2014-03-15 19:43:23 UTC (rev 120)
+++ pkg/GARPFRM/vignettes/DelineatingEfficientPortfolios.Rnw	2014-03-22 04:03:15 UTC (rev 121)
@@ -6,7 +6,7 @@
 \begin{document}
 
 <<echo=FALSE>>=
-opts_chunk$set(warning=FALSE, fig.width=5, fig.height=5)
+opts_chunk$set(tidy=FALSE, warning=FALSE, fig.width=5, fig.height=5)
 @
 
 
@@ -191,11 +191,15 @@
 \sigma_P = (X_C^2 \sigma_C^2 + (1 - X_C)^2 \sigma_S^2 + 2 X_C (1 - X_C) \rho_{CS} \sigma_C \sigma_S)^{1/2}
 \end{equation}
 
-TODO: The derivative of this equation is
+The derivative of this equation is
 
+\begin{equation}
+\frac{\partial \sigma_P}{\partial X_c} = \frac{1}{2} \frac{2 X_c \sigma_c^2 - 2 \sigma_s^2 + 2 X_c \sigma_s^2 + 2 \sigma_c \sigma_s \rho_{cs} - 4 X_c \sigma_c \sigma_s \rho_{cs} }{\left( X_c^2 \sigma_c^2 + (1 - X_c)^2 \sigma_s^2 + 2 X_c (1 - X_c) \sigma_c \sigma_s \rho_{cs} \right)^{1/2}}
+\end{equation}
+
 Set the derivative equal to zero and solve for $X_C$. 
 \begin{equation}
-X_C = \frac{\sigma_S^2 - \sigma_C \sigma_S \rho_{CS}}{\sigma_C^2 + \sigma_S^2 - 2 \sigma_C \sigma_S \rho_{CS}}
+X_c = \frac{\sigma_s^2 - \sigma_c \sigma_s \rho_{cs}}{\sigma_c^2 + \sigma_s^2 - 2 \sigma_c \sigma_s \rho_{cs}}
 \end{equation}
 
 We can easily write an \code{R} function to solve for the weights of the minimum risk portfolio.
@@ -407,7 +411,7 @@
 # Specify the list of groups such that each market cap is in its own group
 groups <- list(c(1:5), c(6:10), c(11:15))
 
-# Specify the sum weights for each group:
+# Specify the sum of weights for each group:
 # largecap: no more than 60% and no less than 30%
 # midcap: no more than 50% and no less than 20%
 # smallcap: no more than 40% and no less than 15%
@@ -418,7 +422,7 @@
 efGroup <- efficientFrontier(R, groupList=groups, 
                              groupMin=groupMin, 
                              groupMax=groupMax)
-plot(efGroup)
+plot(efGroup, labelAssets=FALSE)
 @
 
 In this vignette, we have demonstrated the behavior of efficient frontiers of two assets as the correlation varies under the full investment constraint with and without short selling allowed. We have also presented the more general case for generating portfolios along an efficient frontier for more than 2 assets. We also demonstrated functionality to generate portfolios along the efficient frontier with box constraints as well as group constraints.

Modified: pkg/GARPFRM/vignettes/DelineatingEfficientPortfolios.pdf
===================================================================
(Binary files differ)



More information about the Uwgarp-commits mailing list