[Returnanalytics-commits] r2942 - in pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 30 12:29:17 CEST 2013


Author: shubhanm
Date: 2013-08-30 12:29:17 +0200 (Fri, 30 Aug 2013)
New Revision: 2942

Modified:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd
Log:
/R code modification and addition of features

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R	2013-08-30 08:41:17 UTC (rev 2941)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R	2013-08-30 10:29:17 UTC (rev 2942)
@@ -20,7 +20,7 @@
 #' @rdname AcarSim
 #' @export 
 AcarSim <-
-  function()
+  function(R)
   {
     
     library(PerformanceAnalytics)
@@ -30,13 +30,16 @@
     R = checkData(edhec, method="xts")
     # Get dimensions and labels
     # simulated parameters using edhec data
-mu=mean(Return.annualized(edhec))
+mu=mean(Return.annualized(R))
 monthly=(1+mu)^(1/12)-1
-sig=StdDev.annualized(edhec[,1])[1];
+    vol = as.numeric(StdDev.annualized(R));
+    ret=as.numeric(Return.annualized(R))
+    drawdown =as.numeric(maxDrawdown(R))
+    sig=mean(StdDev.annualized(R));
 T= 36
 j=1
 dt=1/T
-nsim=6000;
+nsim=1;
 thres=4;
 r=matrix(0,nsim,T+1)
 monthly = 0
@@ -77,9 +80,10 @@
 lines(((fddown[,2])/(sig*nsim)),type='o',col="pink")
 lines(((fddown[,3])/(sig*nsim)),type='o',col="green")
 lines(((fddown[,4])/(sig*nsim)),type='o',col="red")
-legend(32,-4, c("%99", "%95", "%90","%85"), col = c("blue","pink","green","red"), text.col= "black",
-       lty = c(2, -1, 1), pch = c(-1, 3, 4), merge = TRUE, bg='gray90')
-
+    points((ret/vol), (-drawdown/vol), col = "black", pch=10)
+    legend(32,-4, c("%99", "%95", "%90","%85","Fund"), col = c("blue","pink","green","red","black"), text.col= "black",
+       lty = c(2, -1, 1,2), pch = c(-1, 3, 4,10), merge = TRUE, bg='gray90')
+    
 title("Maximum Drawdown/Volatility as a function of Return/Volatility 
 36 monthly returns simulated 6,000 times") 
 }

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R	2013-08-30 08:41:17 UTC (rev 2941)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R	2013-08-30 10:29:17 UTC (rev 2942)
@@ -21,7 +21,7 @@
 #' @param q number of lag factors for autocorrelation
 #' @references Okunev, John and White, Derek R., \emph{ Hedge Fund Risk Factors and Value at Risk of Credit Trading Strategies} (October 2003). 
 #' Available at SSRN: \url{http://ssrn.com/abstract=460641} 
-#' @author Peter Carl, Brian Peterson, Shubhankit Mohan
+#' @author Shubhankit Mohan
 #' @seealso  \code{\link{Return.Geltner}} \cr
 #' @keywords ts multivariate distribution models
 #' @examples
@@ -33,8 +33,12 @@
 #' @export
 Return.Okunev<-function(R,q=3)
 {
+  
   column.okunev=R
-  column.okunev <- column.okunev[!is.na(column.okunev)]
+ col=ncol(R)
+  for(j in 1:col){
+  column.okunev[,j] <- column.okunev[,j][!is.na(column.okunev[,j])]
+}
   for(i in 1:q)
   {
     lagR = lag(column.okunev, k=i)
@@ -42,7 +46,8 @@
   }
   return(c(column.okunev))
 }
-#' Recusrsive Okunev Call Function
+# Recusrsive Okunev Call Function
+
 quad <- function(R,d)
 {
   coeff = as.numeric(acf(as.numeric(edhec[,1]), plot = FALSE)[1:2][[1]])

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R	2013-08-30 08:41:17 UTC (rev 2941)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R	2013-08-30 10:29:17 UTC (rev 2942)
@@ -31,7 +31,7 @@
 #' @rdname table.UnsmoothReturn
 #' @export 
 table.UnsmoothReturn <-
-  function (R, n = 3, p= 0.95, digits = 4)
+  function (R, n = 2, p= 0.95, digits = 4)
   {# @author 
     
     # DESCRIPTION:
@@ -53,17 +53,17 @@
     # for each column, do the following:
     for(column in 1:columns) {
       x = y[,column]
-      
-      z = c(arma(x,0,2)$theta[1],
-        arma(x,0,2)$se.theta[1],
-        arma(x,0,2)$theta[2],
-        arma(x,0,2)$se.theta[2],
-            arma(x,0,2)$se.theta[2])
+      ma.stats= arma(x, order = c(0, 2))
+
+      z = c(as.numeric(ma.stats$coef[1]),
+        sqrt(as.numeric(ma.stats$vcov[1]))*100,
+            as.numeric(ma.stats$coef[2]),
+            sqrt(as.numeric(ma.stats$vcov[4]))*100,sum(as.numeric(ma.stats$coef[1:2])*as.numeric(ma.stats$coef[1:2])))
       znames = c(
-        "Moving Average(1)",
-        "Std Error of MA(1)",
-        "Moving Average(2)",
-        "Std Error of MA(2)",
+        "MA(1)",
+        "Std Error of MA(1)(in %)",
+        "MA(2)",
+        "Std Error of MA(2)(in %)",
         "Smoothing Invest"
         
       )

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd	2013-08-30 08:41:17 UTC (rev 2941)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd	2013-08-30 10:29:17 UTC (rev 2942)
@@ -2,7 +2,7 @@
 \alias{AcarSim}
 \title{Acar-Shane Maximum Loss Plot}
 \usage{
-  AcarSim()
+  AcarSim(R)
 }
 \description{
   To get some insight on the relationships between maximum

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd	2013-08-30 08:41:17 UTC (rev 2941)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd	2013-08-30 10:29:17 UTC (rev 2942)
@@ -59,7 +59,7 @@
 head(Return.Okunev(managers[,1:3]),n=3)
 }
 \author{
-  Peter Carl, Brian Peterson, Shubhankit Mohan
+  Shubhankit Mohan
 }
 \references{
   Okunev, John and White, Derek R., \emph{ Hedge Fund Risk

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd	2013-08-30 08:41:17 UTC (rev 2941)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd	2013-08-30 10:29:17 UTC (rev 2942)
@@ -2,7 +2,7 @@
 \alias{table.UnsmoothReturn}
 \title{Table of Unsmooth Returns}
 \usage{
-  table.UnsmoothReturn(R, n = 3, p = 0.95, digits = 4)
+  table.UnsmoothReturn(R, n = 2, p = 0.95, digits = 4)
 }
 \arguments{
   \item{R}{an xts, vector, matrix, data frame, timeSeries



More information about the Returnanalytics-commits mailing list