[Returnanalytics-commits] r2444 - in pkg/PerformanceAnalytics/sandbox/pulkit: . week1/code week2/vignette
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 26 17:05:42 CEST 2013
Author: pulkit
Date: 2013-06-26 17:05:42 +0200 (Wed, 26 Jun 2013)
New Revision: 2444
Added:
pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/table.PSR.R
pkg/PerformanceAnalytics/sandbox/pulkit/week2/vignette/SharepRatioEfficientFrontier.Rnw
Removed:
pkg/PerformanceAnalytics/sandbox/pulkit/chart.PSR.R
Log:
vignette update
Deleted: pkg/PerformanceAnalytics/sandbox/pulkit/chart.PSR.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/chart.PSR.R 2013-06-26 14:54:05 UTC (rev 2443)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/chart.PSR.R 2013-06-26 15:05:42 UTC (rev 2444)
@@ -1,35 +0,0 @@
-#'@title Probabilistic Sharpe Ratio
-#'@description
-#'Given a predefined
-#'benchmark4 Sharpe ratio (), the observed Sharpe Ratiô can be expressed
-#' in probabilistic
-#'
-#'@param R the return series
-#'@param Rf the risk free rate of return
-#'@param refSR the reference Sharpe Ratio
-#'@param the confidence level
-#'@param weights the weights for the portfolio
-chart.PSR<-function(x,Rf,refSR,p=0.95,...){
- for(column in 1:columns){
- column.probsharpe <- psr(x[,column],Rf,p,refSR)
- column.mintrack <- mintrl(x[,column],Rf,p,refSR)
- if(column == 1){
- probsharpe = column.probsharpe
- mintrack = column.mintrack
- }
- else {
- probsharpe = merge(probsharpe, column.probsharpe)
- mintrack = merge(mintrack, column.mintrack)
- }
-
- }
-
- probsharpe = rbind(probsharpe,mintrack)
-
- colnames(probsharpe) = columnnames
- probsharpe = reclass(probsharpe, x)
- rownames(probsharpe)=c("PSR","MinTRL")
- return(probsharpe)
-
-}
-
Added: pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/table.PSR.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/table.PSR.R (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/table.PSR.R 2013-06-26 15:05:42 UTC (rev 2444)
@@ -0,0 +1,70 @@
+#'@title Probabilistic Sharpe Ratio
+#'
+#'@description
+#'A table to display the Probabilistic Sharpe Ratio Along with
+#'the Minimum Track Record Length for better assessment of the returns.
+#'
+#'@aliases table.PSR
+#'
+#'@param R the return series
+#'@param Rf the risk free rate of return
+#'@param refSR the reference Sharpe Ratio
+#'@param the confidence level
+#'@param weights the weights for the portfolio
+#'
+#'@reference Bailey, David H. and Lopez de Prado, Marcos, \emph{The Sharpe Ratio
+#'Efficient Frontier} (July 1, 2012). Journal of Risk, Vol. 15, No. 2, Winter
+#' 2012/13
+#'@keywords ts multivariate distribution models
+#'@examples
+#'
+#'data(edhec)
+#'table.PSR(edhec[,1],0.20)
+#'
+table.PSR<-function(R=NULL,refSR,Rf=0,p=0.95,weights = NULL,...){
+
+ if(!is.null(R)){
+ x = checkData(R)
+ columns = ncol(x)
+ n = nrow(x)
+ #Checking if the weights are provided or not
+ if(!is.null(weights)){
+ if(length(weights)!=columns){
+ stop("number of items in weights is not equal to the number of columns in R")
+ }
+ else{
+ # A potfolio is constructed by applying the weights
+ x = Return.portfolio(R,weights)
+ }
+ }
+
+ }
+ else{
+ stop("Returns series not provided")
+ }
+
+ columnnames = colnames(x)
+
+ for(column in 1:columns){
+ column.probsharpe <- ProbSharpeRatio(x[,column],refSR,Rf,p,weights)
+ column.mintrack <- MinTrackRecord(x[,column],refSR,Rf,p,weights)
+ if(column == 1){
+ probsharpe = column.probsharpe
+ mintrack = column.mintrack
+ }
+ else {
+ probsharpe = merge(probsharpe, column.probsharpe)
+ mintrack = merge(mintrack, column.mintrack)
+ }
+
+ }
+
+ probsharpe = rbind(probsharpe,mintrack)
+
+ colnames(probsharpe) = columnnames
+ probsharpe = reclass(probsharpe, x)
+ rownames(probsharpe)=c("PSR","MinTRL")
+ return(probsharpe)
+
+}
+
Added: pkg/PerformanceAnalytics/sandbox/pulkit/week2/vignette/SharepRatioEfficientFrontier.Rnw
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week2/vignette/SharepRatioEfficientFrontier.Rnw (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week2/vignette/SharepRatioEfficientFrontier.Rnw 2013-06-26 15:05:42 UTC (rev 2444)
@@ -0,0 +1,60 @@
+\documentclass[12pt,letterpaper,english]{article}
+\usepackage{times}
+\usepackage[T1]{fontenc}
+\IfFileExists{url.sty}{\usepackage{url}}
+ {\newcommand{\url}{\texttt}}
+
+\usepackage{babel}
+\usepackage{Rd}
+
+\usepackage{Sweave}
+\SweaveOpts{engine=R,eps = FALSE}
+%\VignetteIndexEntry{Sharpe Ratio Indifference Curve}
+%\VignetteDepends{PerformanceAnalytics}
+%\VignetteKeywords{Benchmark Sharpe Ratio,Sharpe Ratio Indifference Curve,Benchmark Sharpe Ratio Plots}
+%\VignettePackage{PerformanceAnalytics}
+
+\begin{document}
+\SweaveOpts{concordance=TRUE}
+
+\title{Sharpe Ratio Indifference Curve}
+% \keywords{Sharpe Ratio Indifference Curve,Benchmark Sharpe Ratio,risk,benchmark,portfolio}
+
+\makeatletter
+\makeatother
+\maketitle
+
+\begin{abstract}
+
+ This vignette gives an overview of the Benchmark Sharpe Ratio, Sharpe Ratio Indifference Curve and various plots associated with a Benchmark Sharpe Ratio.It gives an overview of the usability of the functions and its application.
+
+ \end{abstract}
+
+<<echo=FALSE>>=
+library(PerformanceAnalytics)
+data(edhec)
+@
+
+<<echo=FALSE>>=
+source("/home/pulkit/workspace/GSOC/PerformanceAnalytics/sandbox/pulkit/week2/code/BenchmarkSR.R")
+@
+
+ \section{Benchmark Sharpe Ratio}
+
+ The performance of an Equal Volatility Weights benchmark ($SR_B$) is fully characterized in terms of:
+
+1. Number of approved strategies (S).
+2. Average SR among strategies (SR).
+3. Average off-diagonal correlations among strategies($\bar{\rho}$)).
+
+The benchmark SR is a linear function of the average SR of the individual strategies, and a decreasing convex function of the number of strategies and the average pairwise correlation.
+
+The benchmark Sharpe Ratio is given by the following equation.
+
+\deqn{SR_B = \bar{SR}\sqrt{\frac{S}{1+(S-1)\bar{\rho}}}}
+
+<<>>=
+BenchmanrkSR(edhec)
+@
+
+\end{document}
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list