[Returnanalytics-commits] r2916 - in pkg/PerformanceAnalytics/sandbox/Shubhankit: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 28 10:55:04 CEST 2013


Author: shubhanm
Date: 2013-08-28 10:55:04 +0200 (Wed, 28 Aug 2013)
New Revision: 2916

Added:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/R/se.LoSharpe.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/man/se.LoSharpe.Rd
Modified:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/DESCRIPTION
   pkg/PerformanceAnalytics/sandbox/Shubhankit/NAMESPACE
   pkg/PerformanceAnalytics/sandbox/Shubhankit/man/LoSharpe.Rd
Log:
/ standard error LoSharpe

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/DESCRIPTION
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/DESCRIPTION	2013-08-28 05:08:11 UTC (rev 2915)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/DESCRIPTION	2013-08-28 08:55:04 UTC (rev 2916)
@@ -1,38 +1,39 @@
-Package: noniid.sm
-Type: Package
-Title: Non-i.i.d. GSoC 2013 Shubhankit
-Version: 0.1
-Date: $Date: 2013-05-13 14:30:22 -0500 (Mon, 13 May 2013) $
-Author: Shubhankit Mohan <shubhankit1 at gmail.com>
-Contributors: Peter Carl, Brian G. Peterson
-Depends:
-    xts,
-    PerformanceAnalytics
-Suggests:
-    PortfolioAnalytics
-Maintainer: Brian G. Peterson <brian at braverock.com>
-Description: GSoC 2013 project to replicate literature on drawdowns and
-    non-i.i.d assumptions in finance.
-License: GPL-3
-ByteCompile: TRUE
-Collate:
-    'ACStdDev.annualized.R'
-    'CalmarRatio.Normalized.R'
-    'CDDopt.R'
-    'CDrawdown.R'
-    'chart.Autocorrelation.R'
-    'EmaxDDGBM.R'
-    'GLMSmoothIndex.R'
-    'maxDDGBM.R'
-    'na.skip.R'
-    'Return.GLM.R'
-    'table.ComparitiveReturn.GLM.R'
-    'table.normDD.R'
-    'table.UnsmoothReturn.R'
-    'UnsmoothReturn.R'
-    'AcarSim.R'
-    'CDD.Opt.R'
-    'CalmarRatio.Norm.R'
-    'SterlingRatio.Norm.R'
-    'LoSharpe.R'
-    'Return.Okunev.R'
+Package: noniid.sm
+Type: Package
+Title: Non-i.i.d. GSoC 2013 Shubhankit
+Version: 0.1
+Date: $Date: 2013-05-13 14:30:22 -0500 (Mon, 13 May 2013) $
+Author: Shubhankit Mohan <shubhankit1 at gmail.com>
+Contributors: Peter Carl, Brian G. Peterson
+Depends:
+    xts,
+    PerformanceAnalytics
+Suggests:
+    PortfolioAnalytics
+Maintainer: Brian G. Peterson <brian at braverock.com>
+Description: GSoC 2013 project to replicate literature on drawdowns and
+    non-i.i.d assumptions in finance.
+License: GPL-3
+ByteCompile: TRUE
+Collate:
+    'ACStdDev.annualized.R'
+    'CalmarRatio.Normalized.R'
+    'CDDopt.R'
+    'CDrawdown.R'
+    'chart.Autocorrelation.R'
+    'EmaxDDGBM.R'
+    'GLMSmoothIndex.R'
+    'maxDDGBM.R'
+    'na.skip.R'
+    'Return.GLM.R'
+    'table.ComparitiveReturn.GLM.R'
+    'table.normDD.R'
+    'table.UnsmoothReturn.R'
+    'UnsmoothReturn.R'
+    'AcarSim.R'
+    'CDD.Opt.R'
+    'CalmarRatio.Norm.R'
+    'SterlingRatio.Norm.R'
+    'LoSharpe.R'
+    'Return.Okunev.R'
+    'se.LoSharpe.R'

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/NAMESPACE	2013-08-28 05:08:11 UTC (rev 2915)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/NAMESPACE	2013-08-28 08:55:04 UTC (rev 2916)
@@ -12,6 +12,7 @@
 export(QP.Norm)
 export(Return.GLM)
 export(Return.Okunev)
+export(se.LoSharpe)
 export(SterlingRatio.Norm)
 export(SterlingRatio.Normalized)
 export(table.ComparitiveReturn.GLM)

Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/R/se.LoSharpe.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/R/se.LoSharpe.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/R/se.LoSharpe.R	2013-08-28 08:55:04 UTC (rev 2916)
@@ -0,0 +1,92 @@
+#'@title Andrew Lo Sharpe Ratio Statistics
+#'@description
+#' Although the Sharpe ratio has become part of the canon of modern financial 
+#' analysis, its applications typically do not account for the fact that it is an
+#' estimated quantity, subject to estimation errors which can be substantial in 
+#' some cases.
+#' 
+#' Many studies have documented various violations of the assumption of 
+#' IID returns for financial securities.
+#' 
+#' Under the assumption of stationarity,a version of the Central Limit Theorem can 
+#' still be  applied to the estimator .
+#' @details
+#' The relationship between SR and SR(q) is somewhat more involved for non-
+#'IID returns because the variance of Rt(q) is not just the sum of the variances of component returns but also includes all the covariances. Specifically, under
+#' the assumption that returns \eqn{R_t}  are stationary,
+#' \deqn{ Var[(R_t)] =   \sum \sum Cov(R(t-i),R(t-j)) = q{\sigma^2} + 2{\sigma^2} \sum (q-k)\rho(k) }
+#' Where  \eqn{ \rho(k) = Cov(R(t),R(t-k))/Var[(R_t)]} is the \eqn{k^{th}} order autocorrelation coefficient of the series of returns.This yields the following relationship between SR and SR(q):
+#' and i,j belongs to 0 to q-1
+#'\deqn{SR(q)  =  \eta(q) }
+#'Where :
+#' \deqn{ }{\eta(q) = [q]/[\sqrt(q\sigma^2) + 2\sigma^2 \sum(q-k)\rho(k)] }
+#' Where k belongs to 0 to q-1
+#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' daily asset returns
+#' @param Rf an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' annualized Risk Free Rate
+#' @param q Number of autocorrelated lag periods. Taken as 3 (Default)
+#' @param \dots any other pass thru parameters
+#' @author Brian G. Peterson, Peter Carl, Shubhankit Mohan
+#' @references Getmansky, Mila, Lo, Andrew W. and Makarov, Igor,\emph{ 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.
+#'\code{\link[stats]{}} \cr
+#' \url{http://ssrn.com/abstract=384700}
+#' @keywords ts multivariate distribution models non-iid 
+#' @examples
+#' 
+#' data(edhec)
+#' head(se.LoSharpe(edhec,0,3)
+#' @rdname se.LoSharpe
+#' @export
+se.LoSharpe <-
+  function (Ra,Rf = 0,q = 3, ...)
+  { # @author Brian G. Peterson, Peter Carl
+    
+    
+    # Function:
+    R = checkData(Ra, method="xts")
+    # Get dimensions and labels
+    columns.a = ncol(R)
+    columnnames.a = colnames(R)
+    # Time used for daily Return manipulations
+    Time= 252*nyears(edhec)
+    clean.lo <- function(column.R,q) {
+      # compute the lagged return series
+      gamma.k =matrix(0,q)
+      mu = sum(column.R)/(Time)
+      Rf= Rf/(Time)
+      for(i in 1:q){
+        lagR = lag(column.R, k=i)
+        # compute the Momentum Lagged Values
+        gamma.k[i]= (sum(((column.R-mu)*(lagR-mu)),na.rm=TRUE))
+      }
+      return(gamma.k)
+    }
+    neta.lo <- function(pho.k,q) {
+      # compute the lagged return series
+      sumq = 0
+      for(j in 1:q){
+        sumq = sumq+ (q-j)*pho.k[j]
+      }
+      return(q/(sqrt(q+2*sumq)))
+    }
+    for(column.a in 1:columns.a) { # for each asset passed in as R
+      # clean the data and get rid of NAs
+      mu = sum(R[,column.a])/(Time)
+      sig=sqrt(((R[,column.a]-mu)^2/(Time)))
+      pho.k = clean.lo(R[,column.a],q)/(as.numeric(sig[1]))
+      netaq=neta.lo(pho.k,q)
+      column.lo = (netaq*((mu-Rf)/as.numeric(sig[1])))
+      column.lo= 1.96*sqrt((1+(column.lo*column.lo/2))/(Time))
+      if(column.a == 1)  { lo = column.lo }
+      else { lo = cbind (lo, column.lo) }
+      
+    }
+    colnames(lo) = columnnames.a
+    rownames(lo)= paste("Standard Error of Sharpe Ratio Estimates(95% Confidence)")
+    return(lo)
+    
+    
+    # RESULTS:
+    
+  }

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/man/LoSharpe.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/man/LoSharpe.Rd	2013-08-28 05:08:11 UTC (rev 2915)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/man/LoSharpe.Rd	2013-08-28 08:55:04 UTC (rev 2916)
@@ -1,70 +1,70 @@
-\name{LoSharpe}
-\alias{LoSharpe}
-\title{Andrew Lo Sharpe Ratio}
-\usage{
-  LoSharpe(Ra, Rf = 0, q = 3, ...)
-}
-\arguments{
-  \item{Ra}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of daily asset returns}
-
-  \item{Rf}{an xts, vector, matrix, data frame, timeSeries
-  or zoo object of annualized Risk Free Rate}
-
-  \item{q}{Number of autocorrelated lag periods. Taken as 3
-  (Default)}
-
-  \item{\dots}{any other pass thru parameters}
-}
-\description{
-  Although the Sharpe ratio has become part of the canon of
-  modern financial analysis, its applications typically do
-  not account for the fact that it is an estimated
-  quantity, subject to estimation errors that can be
-  substantial in some cases.
-
-  Many studies have documented various violations of the
-  assumption of IID returns for financial securities.
-
-  Under the assumption of stationarity,a version of the
-  Central Limit Theorem can still be applied to the
-  estimator .
-}
-\details{
-  The relationship between SR and SR(q) is somewhat more
-  involved for non- IID returns because the variance of
-  Rt(q) is not just the sum of the variances of component
-  returns but also includes all the covariances.
-  Specifically, under the assumption that returns \eqn{R_t}
-  are stationary, \deqn{ Var[(R_t)] = \sum \sum
-  Cov(R(t-i),R(t-j)) = q{\sigma^2} + 2{\sigma^2} \sum
-  (q-k)\rho(k) } Where \eqn{ \rho(k) =
-  Cov(R(t),R(t-k))/Var[(R_t)]} is the \eqn{k^{th}} order
-  autocorrelation coefficient of the series of returns.This
-  yields the following relationship between SR and SR(q):
-  and i,j belongs to 0 to q-1 \deqn{SR(q) = \eta(q) } Where
-  : \deqn{ }{\eta(q) = [q]/[\sqrt(q\sigma^2) + 2\sigma^2
-  \sum(q-k)\rho(k)] } Where k belongs to 0 to q-1
-}
-\examples{
-data(edhec)
-head(LoSharpe(edhec,0,3)
-}
-\author{
-  Brian G. Peterson, Peter Carl, Shubhankit Mohan
-}
-\references{
-  Getmansky, Mila, Lo, Andrew W. and Makarov, Igor,\emph{
-  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. \code{\link[stats]{}} \cr
-  \url{http://ssrn.com/abstract=384700}
-}
-\keyword{distribution}
-\keyword{models}
-\keyword{multivariate}
-\keyword{non-iid}
-\keyword{ts}
-
+\name{LoSharpe}
+\alias{LoSharpe}
+\title{Andrew Lo Sharpe Ratio}
+\usage{
+  LoSharpe(Ra, Rf = 0, q = 3, ...)
+}
+\arguments{
+  \item{Ra}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of daily asset returns}
+
+  \item{Rf}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of annualized Risk Free Rate}
+
+  \item{q}{Number of autocorrelated lag periods. Taken as 3
+  (Default)}
+
+  \item{\dots}{any other pass thru parameters}
+}
+\description{
+  Although the Sharpe ratio has become part of the canon of
+  modern financial analysis, its applications typically do
+  not account for the fact that it is an estimated
+  quantity, subject to estimation errors that can be
+  substantial in some cases.
+
+  Many studies have documented various violations of the
+  assumption of IID returns for financial securities.
+
+  Under the assumption of stationarity,a version of the
+  Central Limit Theorem can still be applied to the
+  estimator .
+}
+\details{
+  The relationship between SR and SR(q) is somewhat more
+  involved for non- IID returns because the variance of
+  Rt(q) is not just the sum of the variances of component
+  returns but also includes all the covariances.
+  Specifically, under the assumption that returns \eqn{R_t}
+  are stationary, \deqn{ Var[(R_t)] = \sum \sum
+  Cov(R(t-i),R(t-j)) = q{\sigma^2} + 2{\sigma^2} \sum
+  (q-k)\rho(k) } Where \eqn{ \rho(k) =
+  Cov(R(t),R(t-k))/Var[(R_t)]} is the \eqn{k^{th}} order
+  autocorrelation coefficient of the series of returns.This
+  yields the following relationship between SR and SR(q):
+  and i,j belongs to 0 to q-1 \deqn{SR(q) = \eta(q) } Where
+  : \deqn{ }{\eta(q) = [q]/[\sqrt(q\sigma^2) + 2\sigma^2
+  \sum(q-k)\rho(k)] } Where k belongs to 0 to q-1
+}
+\examples{
+data(edhec)
+head(LoSharpe(edhec,0,3)
+}
+\author{
+  Brian G. Peterson, Peter Carl, Shubhankit Mohan
+}
+\references{
+  Getmansky, Mila, Lo, Andrew W. and Makarov, Igor,\emph{
+  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. \code{\link[stats]{}} \cr
+  \url{http://ssrn.com/abstract=384700}
+}
+\keyword{distribution}
+\keyword{models}
+\keyword{multivariate}
+\keyword{non-iid}
+\keyword{ts}
+

Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/man/se.LoSharpe.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/man/se.LoSharpe.Rd	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/man/se.LoSharpe.Rd	2013-08-28 08:55:04 UTC (rev 2916)
@@ -0,0 +1,70 @@
+\name{se.LoSharpe}
+\alias{se.LoSharpe}
+\title{Andrew Lo Sharpe Ratio Statistics}
+\usage{
+  se.LoSharpe(Ra, Rf = 0, q = 3, ...)
+}
+\arguments{
+  \item{Ra}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of daily asset returns}
+
+  \item{Rf}{an xts, vector, matrix, data frame, timeSeries
+  or zoo object of annualized Risk Free Rate}
+
+  \item{q}{Number of autocorrelated lag periods. Taken as 3
+  (Default)}
+
+  \item{\dots}{any other pass thru parameters}
+}
+\description{
+  Although the Sharpe ratio has become part of the canon of
+  modern financial analysis, its applications typically do
+  not account for the fact that it is an estimated
+  quantity, subject to estimation errors which can be
+  substantial in some cases.
+
+  Many studies have documented various violations of the
+  assumption of IID returns for financial securities.
+
+  Under the assumption of stationarity,a version of the
+  Central Limit Theorem can still be applied to the
+  estimator .
+}
+\details{
+  The relationship between SR and SR(q) is somewhat more
+  involved for non- IID returns because the variance of
+  Rt(q) is not just the sum of the variances of component
+  returns but also includes all the covariances.
+  Specifically, under the assumption that returns \eqn{R_t}
+  are stationary, \deqn{ Var[(R_t)] = \sum \sum
+  Cov(R(t-i),R(t-j)) = q{\sigma^2} + 2{\sigma^2} \sum
+  (q-k)\rho(k) } Where \eqn{ \rho(k) =
+  Cov(R(t),R(t-k))/Var[(R_t)]} is the \eqn{k^{th}} order
+  autocorrelation coefficient of the series of returns.This
+  yields the following relationship between SR and SR(q):
+  and i,j belongs to 0 to q-1 \deqn{SR(q) = \eta(q) } Where
+  : \deqn{ }{\eta(q) = [q]/[\sqrt(q\sigma^2) + 2\sigma^2
+  \sum(q-k)\rho(k)] } Where k belongs to 0 to q-1
+}
+\examples{
+data(edhec)
+head(se.LoSharpe(edhec,0,3)
+}
+\author{
+  Brian G. Peterson, Peter Carl, Shubhankit Mohan
+}
+\references{
+  Getmansky, Mila, Lo, Andrew W. and Makarov, Igor,\emph{
+  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. \code{\link[stats]{}} \cr
+  \url{http://ssrn.com/abstract=384700}
+}
+\keyword{distribution}
+\keyword{models}
+\keyword{multivariate}
+\keyword{non-iid}
+\keyword{ts}
+



More information about the Returnanalytics-commits mailing list