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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 7 15:42:34 CEST 2013


Author: shubhanm
Date: 2013-09-07 15:42:33 +0200 (Sat, 07 Sep 2013)
New Revision: 3019

Added:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/UnSmoothReturn.Rd
Modified:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/NAMESPACE
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.Autocorrelation.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.ComparitiveReturn.GLM.Rd
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd
Log:
Addition of examples, bug correction in "Return functions" + Clean Build 

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/NAMESPACE	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/NAMESPACE	2013-09-07 13:42:33 UTC (rev 3019)
@@ -12,3 +12,4 @@
 export(table.ComparitiveReturn.GLM)
 export(table.EMaxDDGBM)
 export(table.UnsmoothReturn)
+export(UnsmoothReturn)

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/UnsmoothReturn.R	2013-09-07 13:42:33 UTC (rev 3019)
@@ -1,5 +1,40 @@
-UnSmoothReturn<-
-  function(R = NULL,q,  ...)
+#' @title  Unsmooth Time Series Return 
+#' 
+#' @description Creates a table of estimates of moving averages for comparison across
+#' multiple instruments or funds as well as their standard error and
+#' smoothing index , which is Compenent Decomposition of Table of Unsmooth Returns
+#' 
+#' @details The estimation method is based on a maximum likelihood estimation of a moving average 
+#' process (we use the innovations algorithm proposed by \bold{Brockwell and Davis} [1991]). The first 
+#' step of this approach consists in computing a series of de-meaned observed returns:
+#' \deqn{X(t) = R(0,t)- \mu}
+#' where \eqn{\mu} is the expected value of the series of observed returns.
+#' As a consequence, the above equation can be written as :
+#' \deqn{X(t)= \theta(0)\eta(t) + \theta(1)\eta(t-1) + .....   + \theta(k)\eta(t-k)}
+#' with the additional assumption that : \bold{\eqn{\eta(k)= N(0,\sigma(\eta)^2)}}
+#' The structure of the model and the two constraints suppose that the complete integration of 
+#'information in the price of the considered asset may take up to k periods because of its illiquidity. 
+#'In addition, according to Getmansky et al., this model is in line with previous models of nonsynchronous trading such as the one developed by \bold{Cohen, Maier, Schwartz and Whitcomb} 
+#' [1986].
+#' Smoothing has an impact on the third and fourth moments of the returns distribution too.
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param q number of series lags
+#' @param ... any other passthru parameter
+#' @references   Cavenaile, Laurent, Coen, Alain and Hubner, Georges,\emph{ The Impact of Illiquidity and Higher Moments of Hedge Fund Returns on Their Risk-Adjusted Performance and Diversification Potential} (October 30, 2009). Journal of Alternative Investments, Forthcoming. Available at SSRN: \url{http://ssrn.com/abstract=1502698} Working paper is at \url{http://www.hec.ulg.ac.be/sites/default/files/workingpapers/WP_HECULg_20091001_Cavenaile_Coen_Hubner.pdf}
+#' @author Shubhankit Mohan
+#' @keywords ts smooth return models
+#' @seealso Reutrn.Geltner Reutrn.GLM  Return.Okunev
+#' @rdname UnSmoothReturn
+#' @examples
+#' library(PerformanceAnalytics)
+#' library(tseries)
+#' data(managers)
+#' UnsmoothReturn(managers,3)
+#' @export 
+
+UnsmoothReturn<-
+  function(R = NULL,q=2,  ...)
   {
     columns = 1
     columnnames = NULL
@@ -14,7 +49,8 @@
       
       # Calculate AutoCorrelation Coefficient
       for(column in 1:columns) { # for each asset passed in as R
-        y = checkData(R[,column], method="vector", na.rm = TRUE)
+        y = R[,column]
+        y=na.omit(y)
         
         acflag6 = acf(y,plot=FALSE,lag.max=6)[[1]][2:7]
         values = sum(acflag6*acflag6)/(sum(acflag6)*sum(acflag6))
@@ -29,7 +65,7 @@
           result.df = cbind(result.df, nextcol)
         }
       }
-      return(result.df[1:q,]*R)  # Unsmooth Return
+      return(as.numeric(result.df)*R)  # Unsmooth Return
       
     }  
   }
\ No newline at end of file

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.Autocorrelation.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.Autocorrelation.R	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/chart.Autocorrelation.R	2013-09-07 13:42:33 UTC (rev 3019)
@@ -36,7 +36,7 @@
  
 aa= table.Autocorrelation(R)
     chart.StackedBar(as.matrix(aa), main="ACF Lag Plot", ylab= "Value of Coefficient",
-                   , xlab = NULL,col=bluemono)
+                   , xlab = NULL,colorset=bluemono)
 
    # Place the legend at the top-left corner with no frame  
    # using rainbow colors

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R	2013-09-07 13:42:33 UTC (rev 3019)
@@ -13,6 +13,11 @@
 #' @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} 
 #' @rdname table.ComparitiveReturn.GLM
+#' @examples
+#' library(PerformanceAnalytics)
+#' library(tseries)
+#' data(managers)
+#' table.ComparitiveReturn.GLM(managers,3)
 #' @export 
 table.ComparitiveReturn.GLM <-
   function (R, n = 3, digits = 4)

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R	2013-09-07 13:42:33 UTC (rev 3019)
@@ -29,6 +29,11 @@
 #' 
 #' 
 #' @rdname table.UnsmoothReturn
+#' @examples
+#' library(PerformanceAnalytics)
+#' library(tseries)
+#' data(managers)
+#' table.UnsmoothReturn(managers,3)
 #' @export 
 table.UnsmoothReturn <-
   function (R, n = 2, p= 0.95, digits = 4)

Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/UnSmoothReturn.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/UnSmoothReturn.Rd	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/UnSmoothReturn.Rd	2013-09-07 13:42:33 UTC (rev 3019)
@@ -0,0 +1,69 @@
+\name{UnsmoothReturn}
+\alias{UnsmoothReturn}
+\title{Unsmooth Time Series Return}
+\usage{
+  UnsmoothReturn(R = NULL, q = 2, ...)
+}
+\arguments{
+  \item{R}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of asset returns}
+
+  \item{q}{number of series lags}
+
+  \item{...}{any other passthru parameter}
+}
+\description{
+  Creates a table of estimates of moving averages for
+  comparison across multiple instruments or funds as well
+  as their standard error and smoothing index , which is
+  Compenent Decomposition of Table of Unsmooth Returns
+}
+\details{
+  The estimation method is based on a maximum likelihood
+  estimation of a moving average process (we use the
+  innovations algorithm proposed by \bold{Brockwell and
+  Davis} [1991]). The first step of this approach consists
+  in computing a series of de-meaned observed returns:
+  \deqn{X(t) = R(0,t)- \mu} where \eqn{\mu} is the expected
+  value of the series of observed returns. As a
+  consequence, the above equation can be written as :
+  \deqn{X(t)= \theta(0)\eta(t) + \theta(1)\eta(t-1) + .....
+  + \theta(k)\eta(t-k)} with the additional assumption that
+  : \bold{\eqn{\eta(k)= N(0,\sigma(\eta)^2)}} The structure
+  of the model and the two constraints suppose that the
+  complete integration of information in the price of the
+  considered asset may take up to k periods because of its
+  illiquidity. In addition, according to Getmansky et al.,
+  this model is in line with previous models of
+  nonsynchronous trading such as the one developed by
+  \bold{Cohen, Maier, Schwartz and Whitcomb} [1986].
+  Smoothing has an impact on the third and fourth moments
+  of the returns distribution too.
+}
+\examples{
+library(PerformanceAnalytics)
+library(tseries)
+data(managers)
+UnsmoothReturn(managers,3)
+}
+\author{
+  Shubhankit Mohan
+}
+\references{
+  Cavenaile, Laurent, Coen, Alain and Hubner,
+  Georges,\emph{ The Impact of Illiquidity and Higher
+  Moments of Hedge Fund Returns on Their Risk-Adjusted
+  Performance and Diversification Potential} (October 30,
+  2009). Journal of Alternative Investments, Forthcoming.
+  Available at SSRN: \url{http://ssrn.com/abstract=1502698}
+  Working paper is at
+  \url{http://www.hec.ulg.ac.be/sites/default/files/workingpapers/WP_HECULg_20091001_Cavenaile_Coen_Hubner.pdf}
+}
+\seealso{
+  Reutrn.Geltner Reutrn.GLM Return.Okunev
+}
+\keyword{models}
+\keyword{return}
+\keyword{smooth}
+\keyword{ts}
+

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.ComparitiveReturn.GLM.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.ComparitiveReturn.GLM.Rd	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.ComparitiveReturn.GLM.Rd	2013-09-07 13:42:33 UTC (rev 3019)
@@ -18,6 +18,12 @@
   Skewness and Kurtosis for Orignal and Unsmooth Returns
   Respectively
 }
+\examples{
+library(PerformanceAnalytics)
+library(tseries)
+data(managers)
+table.ComparitiveReturn.GLM(managers,3)
+}
 \author{
   Peter Carl, Brian Peterson, Shubhankit Mohan
 }

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd	2013-09-07 12:48:30 UTC (rev 3018)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.UnsmoothReturn.Rd	2013-09-07 13:42:33 UTC (rev 3019)
@@ -42,6 +42,12 @@
   Smoothing has an impact on the third and fourth moments
   of the returns distribution too.
 }
+\examples{
+library(PerformanceAnalytics)
+library(tseries)
+data(managers)
+table.UnsmoothReturn(managers,3)
+}
 \author{
   Peter Carl, Brian Peterson, Shubhankit Mohan
 }



More information about the Returnanalytics-commits mailing list