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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 31 12:39:53 CEST 2013


Author: shubhanm
Date: 2013-08-31 12:39:53 +0200 (Sat, 31 Aug 2013)
New Revision: 2948

Added:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/QP.Norm.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV-concordance.tex
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV.log
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV.synctex.gz
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV.tex
Removed:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/man/quad.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/maxDDGBM.R
Modified:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/R/GLMSmoothIndex.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/R/Return.Okunev.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/R/UnsmoothReturn.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/DESCRIPTION
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/EmaxDDGBM.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/GLMSmoothIndex.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/LoSharpe.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.GLM.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.AcarSim.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.EMaxDDGBM.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/EMaxDDGBM.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/GLMSmoothIndex.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/chart.AcarSim.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/quad.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.EmaxDDGBM.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV-Graph10.pdf
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV.pdf
   pkg/PerformanceAnalytics/sandbox/Shubhankit/vignettes/ACFSTDEV.rnw
Log:
Addition of material in package

Documentation editing

Complete removal of warning messages in checking of code/Rd file in R Check Process 

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/R/GLMSmoothIndex.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/R/GLMSmoothIndex.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/R/GLMSmoothIndex.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -17,10 +17,11 @@
 #' 
 #' @keywords ts multivariate distribution models non-iid 
 #' @examples
+#'     require(PerformanceAnalytics)
+#'  library(PerformanceAnalytics)
+#'  data(edhec)
+#' GLMSmoothIndex(edhec)
 #' 
-#' data(edhec)
-#' head(GLMSmoothIndex(edhec))
-#' 
 #' @export
 GLMSmoothIndex<-
   function(R = NULL, ...)
@@ -33,7 +34,7 @@
       columns = ncol(x)
       n = nrow(x)
       count = q
-        x=edhec
+       
         columns = ncol(x)
         columnnames = colnames(x)
         
@@ -59,6 +60,7 @@
         return(result.df)
       
     }  
+  edhec=NULL
   }
 
 ###############################################################################

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/R/Return.Okunev.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/R/Return.Okunev.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/R/Return.Okunev.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -16,8 +16,14 @@
 #'
 #'To remove the \bold{first m orders} of autocorrelation from a given return series we would proceed in a manner very similar to that detailed in \bold{ \code{\link{Return.Geltner}} \cr}. We would initially remove the first order autocorrelation, then proceed to eliminate the second order autocorrelation through the iteration process. In general, to remove any order, m, autocorrelations from a given return series we would make the following transformation to returns:
 #' autocorrelation structure in the original return series without making any assumptions regarding the actual time series properties of the underlying process. We are implicitly assuming by this approach that the autocorrelations that arise in reported returns are entirely due to the smoothing behavior funds engage in when reporting results. In fact, the method may be adopted to produce any desired level of autocorrelation at any lag and is not limited to simply eliminating all autocorrelations.
+#' @param
+#' R : an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param 
+#' q : order of autocorrelation coefficient lag factors
 #'
 #'
+#'
 #' @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
@@ -41,7 +47,7 @@
   }
   return(c(column.okunev))
 }
-#' 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/R/UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/R/UnsmoothReturn.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/R/UnsmoothReturn.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -9,13 +9,12 @@
       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)
+        y = checkData(R[,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))

Deleted: pkg/PerformanceAnalytics/sandbox/Shubhankit/man/quad.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/man/quad.Rd	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/man/quad.Rd	2013-08-31 10:39:53 UTC (rev 2948)
@@ -1,10 +0,0 @@
-\name{quad}
-\alias{quad}
-\title{Recusrsive Okunev Call Function}
-\usage{
-  quad(R, d)
-}
-\description{
-  Recusrsive Okunev Call Function
-}
-

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/DESCRIPTION
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/DESCRIPTION	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/DESCRIPTION	2013-08-31 10:39:53 UTC (rev 2948)
@@ -24,7 +24,6 @@
     'chart.Autocorrelation.R'
     'GLMSmoothIndex.R'
     'LoSharpe.R'
-    'maxDDGBM.R'
     'na.skip.R'
     'noniid.sm-internal.R'
     'Return.GLM.R'
@@ -34,6 +33,6 @@
     'table.ComparitiveReturn.GLM.R'
     'table.UnsmoothReturn.R'
     'UnsmoothReturn.R'
-    'EmaxDDGBM.R'
+    'EMaxDDGBM.R'
     'table.EMaxDDGBM.R'
-
+    'QP.Norm.R'

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/AcarSim.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -10,6 +10,8 @@
 #' divided by volatility can be interpreted as the only function of the ratio mean divided by volatility.
 #' \deqn{MD/[\sigma]= Min (\sum[X(j)])/\sigma = F(\mu/\sigma)}
 #' Where j varies from 1 to n ,which is the number of drawdown's in simulation 
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
 #' @author Shubhankit Mohan
 #' @references Maximum Loss and Maximum Drawdown in Financial Markets,\emph{International Conference Sponsored by BNP and Imperial College on: 
 #' Forecasting Financial Markets, London, United Kingdom, May 1997} \url{http://www.intelligenthedgefundinvesting.com/pubs/easj.pdf}
@@ -22,9 +24,8 @@
 AcarSim <-
   function(R)
   {
-    
-    library(PerformanceAnalytics)
-    get("edhec")
+       library(PerformanceAnalytics)
+
     data(edhec)
     
     R = checkData(edhec, method="xts")
@@ -86,6 +87,7 @@
     
 title("Maximum Drawdown/Volatility as a function of Return/Volatility 
 36 monthly returns simulated 6,000 times") 
+       edhec=NULL
 }
 
 ###############################################################################

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/EmaxDDGBM.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/EmaxDDGBM.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/EmaxDDGBM.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -1,29 +1,17 @@
-#' @title Expected Drawdown using Brownian Motion Assumptions
+#' Expected Drawdown using Brownian Motion Assumptions
 #' 
-#' @description  Works on the model specified by Maddon-Ismail which investigates the behavior of this statistic for a Brownian motion 
-#' with drift.
-#' @details If X(t) is a random process on [0, T ], the maximum drawdown at time T , D(T), is defined by
-#' where \deqn{D(T) = sup [X(s) - X(t)]} where s belongs to [0,t] and s belongs to [0,T]
-#'Informally, this is the largest drop from a peak to a bottom. In this paper, we investigate the
-#'behavior of this statistic for a Brownian motion with drift. In particular, we give an infinite 
-#'series representation of its distribution, and consider its expected value. When the drift is zero,
-#'we give an analytic expression for the expected value, and for non-zero drift, we give an infinite
-#'series representation. For all cases, we compute the limiting \bold{(\eqn{T tends to \infty})} behavior, which can be
-#'logarithmic (\eqn{\mu} > 0), square root (\eqn{\mu} = 0), or linear (\eqn{\mu} < 0).
-#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of  asset returns
+#' Works on the model specified by Maddon-Ismail
+#' 
+#' 
+#' 
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
 #' @param digits significant number
-#' @author Shubhankit Mohan
+#' @author Shubhankit
 #' @keywords Expected Drawdown Using Brownian Motion Assumptions
-#' @references Magdon-Ismail, M., Atiya, A., Pratap, A., and Yaser S. Abu-Mostafa: On the Maximum Drawdown of a Browninan Motion, Journal of Applied Probability 41, pp. 147-161, 2004 \url{http://alumnus.caltech.edu/~amir/drawdown-jrnl.pdf}
-#' @keywords Drawdown models Brownian Motion Assumptions
-#' @examples
-#' 
-#'library(PerformanceAnalytics)
-#' data(edhec)
-#' table.EmaxDDGBM(edhec)
-#' @rdname table.EmaxDDGBM
+#'
 #' @export 
-table.EMaxDDGBM <-
+EMaxDDGBM <-
   function (R,digits =4)
   {# @author 
     
@@ -168,40 +156,19 @@
         
       }
       
-    #  return(Ed)
+       return(Ed[1]*100)
       
-      z = c((mu*100),
-            (sig*100),
-            (Ed*100))
-      znames = c(
-        "Annual Returns in %",
-        "Std Devetions in %",
-        "Expected Drawdown in %"
-      )
-      if(column == 1) {
-        resultingtable = data.frame(Value = z, row.names = znames)
-      }
-      else {
-        nextcolumn = data.frame(Value = z, row.names = znames)
-        resultingtable = cbind(resultingtable, nextcolumn)
-      }
-    }
-    colnames(resultingtable) = columnnames
-    ans = base::round(resultingtable, digits)
-    ans
-    
-    
+      
   }
-
+}
 ###############################################################################
-################################################################################
-# R (http://r-project.org/) Econometrics for Performance and Risk Analysis
+# R (http://r-project.org/) 
 #
-# Copyright (c) 2004-2012 Peter Carl and Brian G. Peterson
+# Copyright (c) 2004-2013 
 #
 # This R package is distributed under the terms of the GNU Public License (GPL)
 # for full details see the file COPYING
 #
-# $Id: EmaxDDGBM.R 2271 2012-09-02 01:56:23Z braverock $
+# $Id: EMaxDDGBM
 #
 ###############################################################################

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/GLMSmoothIndex.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/GLMSmoothIndex.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/GLMSmoothIndex.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -11,19 +11,21 @@
 #'Where j belongs to 0 to k,which is the number of lag factors input.
 #' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
 #' asset returns
+#' @param ... Additional Parameters
 #' @author Peter Carl, Brian Peterson, Shubhankit Mohan
 #' @aliases Return.Geltner
 #' @references \emph{Getmansky, Mila, Lo, Andrew W. and Makarov, Igor} An Econometric Model of Serial Correlation and Illiquidity in Hedge Fund Returns (March 1, 2003). MIT Sloan Working Paper No. 4288-03; MIT Laboratory for Financial Engineering Working Paper No. LFE-1041A-03; EFMA 2003 Helsinki Meetings. Available at SSRN: \url{http://ssrn.com/abstract=384700}
 #' 
 #' @keywords ts multivariate distribution models non-iid 
 #' @examples
+#'     require(PerformanceAnalytics)
+#'  library(PerformanceAnalytics)
+#'  data(edhec)
+#' GLMSmoothIndex(edhec)
 #' 
-#' data(edhec)
-#' head(GLMSmoothIndex(edhec))
-#' 
 #' @export
 GLMSmoothIndex<-
-  function(R = NULL)
+  function(R = NULL, ...)
   {
     columns = 1
     columnnames = NULL
@@ -33,32 +35,33 @@
       columns = ncol(x)
       n = nrow(x)
       count = q
-        x=edhec
-        columns = ncol(x)
-        columnnames = colnames(x)
+      
+      columns = ncol(x)
+      columnnames = colnames(x)
+      
+      # Calculate AutoCorrelation Coefficient
+      for(column in 1:columns) { # for each asset passed in as R
+        y = checkData(x[,column], method="vector", na.rm = TRUE)
+        sum = sum(abs(acf(y,plot=FALSE,lag.max=6)[[1]][2:7]));
+        acflag6 = acf(y,plot=FALSE,lag.max=6)[[1]][2:7]/sum;
+        values = sum(acflag6*acflag6)
         
-        # Calculate AutoCorrelation Coefficient
-        for(column in 1:columns) { # for each asset passed in as R
-          y = checkData(x[,column], method="vector", na.rm = TRUE)
-          sum = sum(abs(acf(y,plot=FALSE,lag.max=6)[[1]][2:7]));
-          acflag6 = acf(y,plot=FALSE,lag.max=6)[[1]][2:7]/sum;
-          values = sum(acflag6*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)
-          }
+        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)
+        }
+      }
       rownames(result.df)= paste("GLM Smooth Index")
       
-        return(result.df)
+      return(result.df)
       
     }  
+    edhec=NULL
   }
 
 ###############################################################################

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/LoSharpe.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/LoSharpe.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/LoSharpe.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -48,7 +48,7 @@
     columns.a = ncol(R)
     columnnames.a = colnames(R)
     # Time used for daily Return manipulations
-    Time= 252*nyears(edhec)
+    Time= 252*nyears(R)
     clean.lo <- function(column.R,q) {
       # compute the lagged return series
       gamma.k =matrix(0,q)
@@ -85,7 +85,7 @@
     rownames(lo)= paste("Lo Sharpe Ratio")
     return(lo)
     
-    
+    edhec=NULL
     # RESULTS:
     
   }

Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/QP.Norm.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/QP.Norm.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/QP.Norm.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -0,0 +1,53 @@
+#' calculate a Normalized Calmar or Sterling reward/risk ratio
+#'  
+#' Normalized Calmar and Sterling Ratios are yet another method of creating a
+#' risk-adjusted measure for ranking investments similar to the
+#' \code{\link{SharpeRatio}}.
+#' 
+#' Both the Normalized Calmar and the Sterling ratio are the ratio of annualized return
+#' over the absolute value of the maximum drawdown of an investment. The
+#' Sterling ratio adds an excess risk measure to the maximum drawdown,
+#' traditionally and defaulting to 10\%.
+#' 
+#' It is also traditional to use a three year return series for these
+#' calculations, although the functions included here make no effort to
+#' determine the length of your series.  If you want to use a subset of your
+#' series, you'll need to truncate or subset the input data to the desired
+#' length.
+#' 
+#' Many other measures have been proposed to do similar reward to risk ranking.
+#' It is the opinion of this author that newer measures such as Sortino's
+#' \code{\link{UpsidePotentialRatio}} or Favre's modified
+#' \code{\link{SharpeRatio}} are both \dQuote{better} measures, and
+#' should be preferred to the Calmar or Sterling Ratio.
+#' 
+#' @aliases Normalized.CalmarRatio Normalized.SterlingRatio
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param tau Time Scale Translations Factor
+#' @param scale number of periods in a year (daily scale = 252, monthly scale =
+#' 12, quarterly scale = 4)
+#' @author Shubhankit
+#' @seealso 
+#' \code{\link{Return.annualized}}, \cr 
+#' \code{\link{maxDrawdown}}, \cr
+#' \code{\link{SharpeRatio.modified}}, \cr 
+#' \code{\link{UpsidePotentialRatio}}
+#' @references Bacon, Carl. \emph{Magdon-Ismail, M. and Amir Atiya, Maximum drawdown. Risk Magazine, 01 Oct 2004.
+#' @keywords ts multivariate distribution models
+#' @examples
+#' 
+#'     data(managers)
+#'     Normalized.CalmarRatio(managers[,1,drop=FALSE])
+#'     Normalized.CalmarRatio(managers[,1:6]) 
+#'     Normalized.SterlingRatio(managers[,1,drop=FALSE])
+#'     Normalized.SterlingRatio(managers[,1:6])
+#' 
+#' @rdname QP.Norm
+#' QP function fo calculation of Sharpe Ratio
+#' @export 
+QP.Norm <- function (R, tau,scale = NA)
+{
+  Sharpe= as.numeric(SharpeRatio.annualized(R))
+  return(.63519+(.5*log(tau))+log(Sharpe))
+}

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.GLM.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.GLM.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.GLM.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -48,7 +48,7 @@
     columnnames.a = colnames(R)
     
     clean.GLM <- function(column.R,q=3) {
-      ma.coeff = as.numeric((arma(edhec[,1],order=c(0,q)))$coef[1:q])
+      ma.coeff = as.numeric((arma(column.R,order=c(0,q)))$coef[1:q])
  column.glm = ma.coeff[q]*lag(column.R,q)
      
     return(column.glm)

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -16,12 +16,17 @@
 #'
 #'To remove the \bold{first m orders} of autocorrelation from a given return series we would proceed in a manner very similar to that detailed in \bold{ \code{\link{Return.Geltner}} \cr}. We would initially remove the first order autocorrelation, then proceed to eliminate the second order autocorrelation through the iteration process. In general, to remove any order, m, autocorrelations from a given return series we would make the following transformation to returns:
 #' autocorrelation structure in the original return series without making any assumptions regarding the actual time series properties of the underlying process. We are implicitly assuming by this approach that the autocorrelations that arise in reported returns are entirely due to the smoothing behavior funds engage in when reporting results. In fact, the method may be adopted to produce any desired level of autocorrelation at any lag and is not limited to simply eliminating all autocorrelations.
-#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' @param
+#' R : an xts, vector, matrix, data frame, timeSeries or zoo object of
 #' asset returns
-#' @param q number of lag factors for autocorrelation
+#' @param 
+#' q : order of autocorrelation coefficient lag factors
+#'
+#'
+#'
 #' @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 Shubhankit Mohan
+#' @author Peter Carl, Brian Peterson, Shubhankit Mohan
 #' @seealso  \code{\link{Return.Geltner}} \cr
 #' @keywords ts multivariate distribution models
 #' @examples
@@ -33,12 +38,8 @@
 #' @export
 Return.Okunev<-function(R,q=3)
 {
-  
   column.okunev=R
- col=ncol(R)
-  for(j in 1:col){
-  column.okunev[,j] <- column.okunev[,j][!is.na(column.okunev[,j])]
-}
+  column.okunev <- column.okunev[!is.na(column.okunev)]
   for(i in 1:q)
   {
     lagR = lag(column.okunev, k=i)
@@ -46,13 +47,40 @@
   }
   return(c(column.okunev))
 }
-# Recusrsive Okunev Call Function
-
+#'@title OW Return Model
+#'@description The objective is to determine the true underlying return by removing the 
+#' autocorrelation structure in the original return series without making any assumptions 
+#' regarding the actual time series properties of the underlying process. We are 
+#' implicitly assuming by this approach that the autocorrelations that arise in reported 
+#'returns are entirely due to the smoothing behavior funds engage in when reporting 
+#' results. In fact, the method may be adopted to produce any desired 
+#' level of autocorrelation at any lag and is not limited to simply eliminating all 
+#'autocorrelations.It can be be said as the general form of Geltner Return Model
+#'@details 
+#'Given a sample of historical returns \eqn{R(1),R(2), . . .,R(T)},the method assumes the fund manager smooths returns in the following manner:
+#' \deqn{ r(0,t)  =  \sum \beta (i) r(0,t-i) + (1- \alpha)r(m,t) }
+#' Where :\deqn{  \sum \beta (i) = (1- \alpha) }
+#' \bold{r(0,t)} : is the observed (reported) return at time t (with 0 adjustments to reported returns), 
+#'\bold{r(m,t)} : is the true underlying (unreported) return at time t (determined by making m adjustments to reported returns).
+#'
+#'To remove the \bold{first m orders} of autocorrelation from a given return series we would proceed in a manner very similar to that detailed in \bold{ \code{\link{Return.Geltner}} \cr}. We would initially remove the first order autocorrelation, then proceed to eliminate the second order autocorrelation through the iteration process. In general, to remove any order, m, autocorrelations from a given return series we would make the following transformation to returns:
+#' autocorrelation structure in the original return series without making any assumptions regarding the actual time series properties of the underlying process. We are implicitly assuming by this approach that the autocorrelations that arise in reported returns are entirely due to the smoothing behavior funds engage in when reporting results. In fact, the method may be adopted to produce any desired level of autocorrelation at any lag and is not limited to simply eliminating all autocorrelations.
+#' @param
+#' R : an xts column of
+#' asset returns
+#' @param 
+#' d : order of autocorrelation coefficient lag factors
+#' @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
+#' @seealso  \code{\link{Return.Geltner}} \cr
+#' @keywords ts multivariate distribution models
+#' @export
 quad <- function(R,d)
 {
-  coeff = as.numeric(acf(as.numeric(edhec[,1]), plot = FALSE)[1:2][[1]])
-b=-(1+coeff[2]-2*d*coeff[1])
-c=(coeff[1]-d)
+  coeff = as.numeric(acf(as.numeric(R, plot = FALSE)[1:2][[1]]))
+  b=-(1+coeff[2]-2*d*coeff[1])
+  c=(coeff[1]-d)
   ans= (-b-sqrt(b*b-4*c*c))/(2*c)
   #a <- a[!is.na(a)]
   return(c(ans))               
@@ -68,4 +96,3 @@
 # $Id: Return.Okunev.R 2163 2012-07-16 00:30:19Z braverock $
 #
 ###############################################################################
-

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -9,13 +9,12 @@
       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)
+        y = checkData(R[,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))

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.AcarSim.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.AcarSim.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.AcarSim.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -17,14 +17,20 @@
 #' Forecasting Financial Markets, London, United Kingdom, May 1997} \url{http://www.intelligenthedgefundinvesting.com/pubs/easj.pdf}
 #' @keywords Maximum Loss Simulated Drawdown
 #' @examples
-#' library(PerformanceAnalytics)
+#'     require(PerformanceAnalytics)
+#'  library(PerformanceAnalytics)
+#'  data(edhec)
 #' chart.AcarSim(edhec)
 #' @rdname chart.AcarSim
 #' @export 
 chart.AcarSim <-
   function(R)
   {
-    R = checkData(Ra, method="xts")
+    
+    require(PerformanceAnalytics)
+    library(PerformanceAnalytics)
+    data(edhec)
+    R = checkData(R, method="xts")
     # Get dimensions and labels
     # simulated parameters using edhec data
     mu=mean(Return.annualized(edhec))
@@ -79,6 +85,7 @@
     
     title("Maximum Drawdown/Volatility as a function of Return/Volatility 
 36 monthly returns simulated 6,000 times") 
+  edhec= NULL
   }
 
 ###############################################################################

Deleted: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/maxDDGBM.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/maxDDGBM.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/maxDDGBM.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -1,174 +0,0 @@
-#' Expected Drawdown using Brownian Motion Assumptions
-#' 
-#' Works on the model specified by Maddon-Ismail
-#' 
-#' 
-#' 
-#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
-#' asset returns
-
-#' @author R
-#' @keywords Expected Drawdown Using Brownian Motion Assumptions
-#'
-#' @export 
-EMaxDDGBM <-
-  function (R,digits =4)
-  {# @author 
-    
-    # DESCRIPTION:
-    # Downside Risk Summary: Statistics and Stylized Facts
-    
-    # Inputs:
-    # R: a regular timeseries of returns (rather than prices)
-    # Output: Table of Estimated Drawdowns 
-    
-    y = checkData(R, method = "xts")
-    columns = ncol(y)
-    rows = nrow(y)
-    columnnames = colnames(y)
-    rownames = rownames(y)
-    T= nyears(y);
-    
-    # for each column, do the following:
-    for(column in 1:columns) {
-      x = y[,column]
-      mu = Return.annualized(x, scale = NA, geometric = TRUE)
-      sig=StdDev(x)
-      gamma<-sqrt(pi/8)
-      
-      if(mu==0){
-        
-        Ed<-2*gamma*sig*sqrt(T)
-        
-      }
-      
-      else{
-        
-        alpha<-mu*sqrt(T/(2*sig^2))
-        
-        x<-alpha^2
-        
-        if(mu>0){
-          
-          mQp<-matrix(c(
-            
-            0.0005, 0.0010, 0.0015, 0.0020, 0.0025, 0.0050, 0.0075, 0.0100, 0.0125,
-            
-            0.0150, 0.0175, 0.0200, 0.0225, 0.0250, 0.0275, 0.0300, 0.0325, 0.0350,
-            
-            0.0375, 0.0400, 0.0425, 0.0450, 0.0500, 0.0600, 0.0700, 0.0800, 0.0900,
-            
-            0.1000, 0.2000, 0.3000, 0.4000, 0.5000, 1.5000, 2.5000, 3.5000, 4.5000,
-            
-            10, 20, 30, 40, 50, 150, 250, 350, 450, 1000, 2000, 3000, 4000, 5000, 0.019690,
-            
-            0.027694, 0.033789, 0.038896, 0.043372, 0.060721, 0.073808, 0.084693, 0.094171,
-            
-            0.102651, 0.110375, 0.117503, 0.124142, 0.130374, 0.136259, 0.141842, 0.147162,
-            
-            0.152249, 0.157127, 0.161817, 0.166337, 0.170702, 0.179015, 0.194248, 0.207999,
-            
-            0.220581, 0.232212, 0.243050, 0.325071, 0.382016, 0.426452, 0.463159, 0.668992,
-            
-            0.775976, 0.849298, 0.905305, 1.088998, 1.253794, 1.351794, 1.421860, 1.476457,
-            
-            1.747485, 1.874323, 1.958037, 2.020630, 2.219765, 2.392826, 2.494109, 2.565985,
-            
-            2.621743),ncol=2)
-          
-          
-          
-          if(x<0.0005){
-            
-            Qp<-gamma*sqrt(2*x)
-            
-          }
-          
-          if(x>0.0005 & x<5000){
-            
-            Qp<-spline(log(mQp[,1]),mQp[,2],n=1,xmin=log(x),xmax=log(x))$y
-            
-          }
-          
-          if(x>5000){
-            
-            Qp<-0.25*log(x)+0.49088
-            
-          }
-          
-          Ed<-(2*sig^2/mu)*Qp
-          
-        }
-        
-        if(mu<0){
-          
-          mQn<-matrix(c(
-            
-            0.0005, 0.0010, 0.0015, 0.0020, 0.0025, 0.0050, 0.0075, 0.0100, 0.0125, 0.0150,
-            
-            0.0175, 0.0200, 0.0225, 0.0250, 0.0275, 0.0300, 0.0325, 0.0350, 0.0375, 0.0400,
-            
-            0.0425, 0.0450, 0.0475, 0.0500, 0.0550, 0.0600, 0.0650, 0.0700, 0.0750, 0.0800,
-            
-            0.0850, 0.0900, 0.0950, 0.1000, 0.1500, 0.2000, 0.2500, 0.3000, 0.3500, 0.4000,
-            
-            0.5000, 1.0000, 1.5000, 2.0000, 2.5000, 3.0000, 3.5000, 4.0000, 4.5000, 5.0000,
-            
-            0.019965, 0.028394, 0.034874, 0.040369, 0.045256, 0.064633, 0.079746, 0.092708,
-            
-            0.104259, 0.114814, 0.124608, 0.133772, 0.142429, 0.150739, 0.158565, 0.166229,
-            
-            0.173756, 0.180793, 0.187739, 0.194489, 0.201094, 0.207572, 0.213877, 0.220056,
-            
-            0.231797, 0.243374, 0.254585, 0.265472, 0.276070, 0.286406, 0.296507, 0.306393,
-            
-            0.316066, 0.325586, 0.413136, 0.491599, 0.564333, 0.633007, 0.698849, 0.762455,
-            
-            0.884593, 1.445520, 1.970740, 2.483960, 2.990940, 3.492520, 3.995190, 4.492380,
-            
-            4.990430, 5.498820),ncol=2)
-          
-          
-          
-          
-          
-          if(x<0.0005){
-            
-            Qn<-gamma*sqrt(2*x)
-            
-          }
-          
-          if(x>0.0005 & x<5000){
-            
-            Qn<-spline(mQn[,1],mQn[,2],n=1,xmin=x,xmax=x)$y
-            
-          }
-          
-          if(x>5000){
-            
-            Qn<-x+0.50
-            
-          }
-          
-          Ed<-(2*sig^2/mu)*(-Qn)
-          
-        }
-        
-      }
-      
-       return(Ed[1]*100)
-      
-      
-  }
-}
-###############################################################################
-# R (http://r-project.org/) 
-#
-# Copyright (c) 2004-2013 
-#
-# This R package is distributed under the terms of the GNU Public License (GPL)
-# for full details see the file COPYING
-#
-# $Id: EMaxDDGBM
-#
-###############################################################################

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -48,7 +48,7 @@
     columns.a = ncol(R)
     columnnames.a = colnames(R)
     # Time used for daily Return manipulations
-    Time= 252*nyears(edhec)
+    Time= 252*nyears(R)
     clean.lo <- function(column.R,q) {
       # compute the lagged return series
       gamma.k =matrix(0,q)

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.EMaxDDGBM.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.EMaxDDGBM.R	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.EMaxDDGBM.R	2013-08-31 10:39:53 UTC (rev 2948)
@@ -20,8 +20,8 @@
 #' 
 #'library(PerformanceAnalytics)
 #' data(edhec)
-#' table.EmaxDDGBM(edhec)
-#' @rdname table.EmaxDDGBM
+#' table.EMaxDDGBM(edhec)
+#' @rdname table.EMaxDDGBM
 #' @export 
 table.EMaxDDGBM <-
   function (R,digits =4)

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/AcarSim.Rd	2013-08-31 10:39:53 UTC (rev 2948)
@@ -4,6 +4,10 @@
 \usage{
   AcarSim(R)
 }
+\arguments{
+  \item{R}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of asset returns}
+}
 \description{
   To get some insight on the relationships between maximum
   drawdown per unit of volatility and mean return divided

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/EMaxDDGBM.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/EMaxDDGBM.Rd	2013-08-31 00:39:21 UTC (rev 2947)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/EMaxDDGBM.Rd	2013-08-31 10:39:53 UTC (rev 2948)
@@ -7,12 +7,14 @@
 \arguments{
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 2948


More information about the Returnanalytics-commits mailing list