[Returnanalytics-commits] r2738 - in pkg/PerformanceAnalytics/sandbox/pulkit: week1/code week3_4/code

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 7 19:52:05 CEST 2013


Author: pulkit
Date: 2013-08-07 19:52:05 +0200 (Wed, 07 Aug 2013)
New Revision: 2738

Modified:
   pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R
   pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/GoldenSection.R
Log:
documentation changes in PSR and golden section

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R	2013-08-07 16:33:06 UTC (rev 2737)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/PSRopt.R	2013-08-07 17:52:05 UTC (rev 2738)
@@ -1,7 +1,19 @@
 #'@title Implementation of PSR Portfolio Optimization
 #'@description
-#'Maximizing for PSR leads to better diversified and more balanced hedge fund allocations compared to the concentrated outcomes of Sharpe ratio maximization.We would like to find the vector of weights that maximize the expression.Gradient Ascent Logic is used to compute the weights using the Function PsrPortfolio
+#'Maximizing for PSR leads to better diversified and more balanced hedge fund allocations compared to the concentrated 
+#'outcomes of Sharpe ratio maximization.We would like to find the vector of weights that maximize the expression
 #'
+#'\deqn{\hat{PSR}(SR^\ast) = Z\biggl[\frac{(\hat{SR}-SR^\ast)\sqrt{n-1}}{\sqrt{1-\hat{\gamma_3}SR^\ast + \frac{\hat{\gamma_4}-1}{4}\hat{SR^2}}}\biggr]}
+#'
+#'where \eqn{\sigma = \sqrt{E[(r-\mu)^2]}} ,its standard deviation.\eqn{\gamma_3=\frac{E\biggl[(r-\mu)^3\biggr]}{\sigma^3}} its skewness,
+#'\eqn{\gamma_4=\frac{E\biggl[(r-\mu)^4\biggr]}{\sigma^4}} its kurtosis and \eqn{SR = \frac{\mu}{\sigma}} its Sharpe Ratio.
+#'Because \eqn{\hat{PSR}(SR^\ast)=Z[\hat{Z^\ast}]} is a monotonic increasing function of 
+#'\eqn{\hat{Z^\ast}} ,it suffices to compute the vector that maximizes \eqn{\hat{Z^\ast}}
+#'
+#'This optimal vector is invariant of the value adopted by the parameter $SR^\ast$. 
+#'Gradient Ascent Logic is used to compute the weights using the Function PsrPortfolio
+
+
 #'@aliases PsrPortfolio
 #'
 #'@param R The return series
@@ -22,7 +34,18 @@
 #'PsrPortfolio(edhec) 
 
 PsrPortfolio<-function(R,refSR=0,bounds=NULL,MaxIter = 1000,delta = 0.005){
-
+    # DESCRIPTION:
+    # This function returns the weight for which Probabilistic Sharpe Ratio 
+    # is maximized.
+    #
+    # INPUT:
+    # The return series of the portfolio is taken as the input
+    # refSR , bounds of the weights for each series in the portfolio , 
+    # max iteration for the optimization , delta by which the z value will 
+    # change is also taken as the input.
+    #
+    # OUTPUT:
+    # The weights is given as the output.
     x = checkData(R)
     columns = ncol(x)
     n = nrow(x)

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/GoldenSection.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/GoldenSection.R	2013-08-07 16:33:06 UTC (rev 2737)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/GoldenSection.R	2013-08-07 17:52:05 UTC (rev 2738)
@@ -2,6 +2,19 @@
 #' Golden Section Algorithm
 #'
 #' @description
+#'
+#' The Golden Section Search method is used to find the maximum or minimum of a unimodal
+#" function. (A unimodal function contains only one minimum or maximum on the interval 
+#' [a,b].) To make the discussion of the method simpler, let us assume that we are trying to find 
+#' the maximum of a function. choose three points \eqn{x_l},\eqn{x_1} and \eqn{x_u} \eqn{(x_l \textless x_1 \textless x_u)}
+#' along the x-axis with the corresponding values of the function \eqn{f(x_l)},\eqn{f(x_1)} and \eqn{f(x_u)}, respectively. Since
+#' \eqn{f(x_1)\textgreater f(x_l)} and \eqn{f(x_1) \textgreater f(x_u)}, the maximum must lie between \eqn{x_l} and \eqn{x_u}. Now 
+#' a fourth point denoted by \eqn{x_2} is chosen to be between the larger of the two intervals of \eqn{[x_l,x_1]} and \eqn{[x_1,x_u]}/
+#' Assuming that the interval \eqn{[x_l,x_1]} is larger than the interval \eqn{[x_1,x_u]} we would choose \eqn{[x_l,x_1]} as the interval 
+#' in which \eqn{x_2} is chosen. If \eqn{f(x_2)>f(x_1)} then the new three points would be \eqn{x_l \textless x_2 \textless x_1} else if
+#' \eqn{f(x_2)<f(x_1)} then the three new points are \eqn{x_2<x_1<x_u}. This process is continued until the distance between the outer point
+#' is sufficiently small.
+
 #' @reference Bailey, David H. and Lopez de Prado, Marcos, Drawdown-Based Stop-Outs and the ‘Triple Penance’ Rule(January 1, 2013).
 #' 
 #'@param a initial point



More information about the Returnanalytics-commits mailing list