[Returnanalytics-commits] r2483 - pkg/PerformanceAnalytics/sandbox/Shubhankit

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 1 14:52:03 CEST 2013


Author: shubhanm
Date: 2013-07-01 14:52:03 +0200 (Mon, 01 Jul 2013)
New Revision: 2483

Added:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/UnsmoothReturn.R
Log:


Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/UnsmoothReturn.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/UnsmoothReturn.R	2013-07-01 12:52:03 UTC (rev 2483)
@@ -0,0 +1,36 @@
+UnSmoothReturn<-
+  function(R = NULL,q,  ...)
+  {
+    columns = 1
+    columnnames = NULL
+    #Error handling if R is not NULL
+    if(!is.null(R)){
+      x = checkData(R)
+      columns = ncol(x)
+      n = nrow(x)
+      count = q
+      x=edhec
+      columns = ncol(x)
+      columnnames = colnames(x)
+      
+      # Calculate AutoCorrelation Coefficient
+      for(column in 1:columns) { # for each asset passed in as R
+        y = checkData(edhec[,column], method="vector", na.rm = TRUE)
+        
+        acflag6 = acf(y,plot=FALSE,lag.max=6)[[1]][2:7]
+        values = sum(acflag6*acflag6)/(sum(acflag6)*sum(acflag6))
+        
+        if(column == 1) {
+          result.df = data.frame(Value = values)
+          colnames(result.df) = columnnames[column]
+        }
+        else {
+          nextcol = data.frame(Value = values)
+          colnames(nextcol) = columnnames[column]
+          result.df = cbind(result.df, nextcol)
+        }
+      }
+      return(result.df[1:q,]*R)  # Unsmooth Return
+      
+    }  
+  }
\ No newline at end of file



More information about the Returnanalytics-commits mailing list