[Returnanalytics-commits] r2718 - pkg/PerformanceAnalytics/sandbox/pulkit/week6

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 5 12:51:30 CEST 2013


Author: pulkit
Date: 2013-08-05 12:51:30 +0200 (Mon, 05 Aug 2013)
New Revision: 2718

Modified:
   pkg/PerformanceAnalytics/sandbox/pulkit/week6/DrawdownBeta.R
Log:
Changes in Drawdown beta

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week6/DrawdownBeta.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week6/DrawdownBeta.R	2013-08-04 21:22:13 UTC (rev 2717)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week6/DrawdownBeta.R	2013-08-05 10:51:30 UTC (rev 2718)
@@ -34,12 +34,28 @@
 #'@param \dots any passthru variable.
 #'
 #'@references
-#'Zabarankin, M., Pavlikov, K., and S. Uryasev. Capital Asset Pricing Model (CAPM)
-#'with Drawdown Measure.Research Report 2012-9, ISE Dept., University of Florida, 
-#'September 2012. 
+#'Zabarankin, M., Pavlikov, K., and S. Uryasev. Capital Asset Pricing Model 
+#'(CAPM) with Drawdown Measure.Research Report 2012-9, ISE Dept., University 
+#'of Florida,September 2012.
+#'
+#'@examples
+#'
+#'BetaDrawdown(edhec[,1],edhec[,2]) #expected value 
 
-BetaDrawdown<-function(R,Rm,h=0,p=0.95,weights=NULL,geometric=TRUE,invert=TRUE,...){
+BetaDrawdown<-function(R,Rm,h=0,p=0.95,weights=NULL,geometric=TRUE,...){
 
+    # DESCRIPTION:
+    #
+    # The function is used to find the Drawdown Beta.
+    # 
+    # INPUT:
+    # The Return series of the portfolio and the optimal portfolio
+    # is taken as the input.
+    #
+    # OUTPUT:
+    # The Drawdown beta is given as the output.   
+
+
     x = checkData(R)
     xm = checkData(Rm)
     columnnames = colnames(R)
@@ -56,7 +72,7 @@
         cumul_x = cumsum(x)
         cumul_xm = cumsum(xm)
     }
-    beta<-function(x){
+    DDbeta<-function(x){
         q = NULL
         q_quantile = quantile(drawdowns_m,1-p)
         for(i in 1:nrow(Rm)){
@@ -71,7 +87,7 @@
     }
 
     for(column in 1:columns){
-        column.beta = beta(cumul_x[,column])
+        column.beta = DDbeta(cumul_x[,column])
         if(column == 1){
             beta = column.beta
         }
@@ -79,10 +95,13 @@
             beta = cbind(beta,column.beta)
         }
     }
-    if(invert){
+    
+    if(columns==1){
+        return(beta)
     }
-    print(columnnames)
+    print(beta)
     colnames(beta) = columnnames
+    rownames(beta) = paste("Drawdown Beta (p =",p*100,"%)")
     beta = reclass(beta,R)
     return(beta)
 



More information about the Returnanalytics-commits mailing list