[Returnanalytics-commits] r3317 - in pkg/PerformanceAnalytics: . R man sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 20 18:07:25 CET 2014
Author: braverock
Date: 2014-02-20 18:07:25 +0100 (Thu, 20 Feb 2014)
New Revision: 3317
Added:
pkg/PerformanceAnalytics/man/HurstIndex.Rd
pkg/PerformanceAnalytics/sandbox/Return.wealthindex.R
Removed:
pkg/PerformanceAnalytics/R/Return.index.R
pkg/PerformanceAnalytics/R/Return.wealthindex.R
Modified:
pkg/PerformanceAnalytics/NAMESPACE
pkg/PerformanceAnalytics/R/ActivePremium.R
pkg/PerformanceAnalytics/R/HurstIndex.R
pkg/PerformanceAnalytics/R/mean.utils.R
pkg/PerformanceAnalytics/R/zerofill.R
Log:
- export more functions prior to CRAN release
- move Return.index/wealthindex to sandbox
Modified: pkg/PerformanceAnalytics/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/NAMESPACE 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/NAMESPACE 2014-02-20 17:07:25 UTC (rev 3317)
@@ -1,11 +1,8 @@
-S3method(mean,LCL)
-S3method(mean,UCL)
-S3method(mean,geometric)
-S3method(mean,stderr)
S3method(textplot,character)
S3method(textplot,data.frame)
S3method(textplot,default)
S3method(textplot,matrix)
+export(ActivePremium)
export(ActiveReturn)
export(AdjustedSharpeRatio)
export(AppraisalRatio)
@@ -43,6 +40,7 @@
export(ETL)
export(FamaBeta)
export(Frequency)
+export(HurstIndex)
export(InformationRatio)
export(Kappa)
export(KellyRatio)
@@ -166,6 +164,10 @@
export(macro.dates)
export(macro.labels)
export(maxDrawdown)
+export(mean.LCL)
+export(mean.UCL)
+export(mean.geometric)
+export(mean.stderr)
export(opensymbols)
export(rainbow10equal)
export(rainbow12equal)
Modified: pkg/PerformanceAnalytics/R/ActivePremium.R
===================================================================
--- pkg/PerformanceAnalytics/R/ActivePremium.R 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/R/ActivePremium.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -29,7 +29,7 @@
#' @aliases
#' ActivePremium
#' ActiveReturn
-#' @export
+#' @export ActiveReturn ActivePremium
ActiveReturn <- ActivePremium <- function (Ra, Rb, scale = NA)
{ # @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/HurstIndex.R
===================================================================
--- pkg/PerformanceAnalytics/R/HurstIndex.R 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/R/HurstIndex.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -1,38 +1,50 @@
+#' calculate the Hurst Index
+#' The Hurst index can be used to measure whether returns are mean reverting,
+#' totally random, or persistent.
+#'
+#' Hurst obtained a dimensionless statistical exponent by dividing the range
+#' by the standard deviation of the observations,
+#' so this approach is commonly referred to as rescaled range (R/S) analysis.
+#'
+#' \deqn{H = log(m)/log(n)}
+#'
+#' where
+#' \eqn{m = [max(r_i) - min(r_i)]/sigma_p} and
+#' \eqn{n = number of observations}
+#
+#' A Hurst index between 0.5 and 1 suggests that the returns are persistent.
+#' At 0.5, the index suggests returns are totally random. Between 0 and 0.5
+#' it suggests that the returns are mean reverting.
+#'
+#' H.E. Hurst originally developed the Hurst index to help establish optimal
+#' water storage along the Nile. Nile floods are extremely persistent,
+#' measuring a Hurst index of 0.9. Peters (1991) notes that Equity markets
+#' have a Hurst index in excess of 0.5, with typical values of around 0.7.
+#' That appears to be anomalous in the context of the mainstream 'rational
+#' behaviour' theories of economics, and suggests existence of a powerful
+#' 'long-term memory' causal dependence. Clarkson (2001) suggests that an
+#' 'over-reaction bias' could be expected to generate a powerful 'long-term
+#' memory' effect in share prices.
+#'
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
+#' @param \dots any other passthru parameters
+#' @references
+#' Clarkson, R. (2001) FARM: a financial actuarial risk model. In Chapter
+#' 12 of Managing Downside Risk in Financial Markets, F. Sortino and S.
+#'
+#' Satchel. Butterworth-Heinemann Finance.
+#'
+#' Peters, E.E (1991) Chaos and Order in Capital Markets, New York: Wiley.
+#'
+#' Bacon, Carl. (2008) Practical Portfolio Performance Measurement and Attribution, 2nd Edition. London: John Wiley & Sons.
+#'
+#' @export
HurstIndex <-
function (R, ...) {
- # The Hurst index can be used to measure whether returns are mean reverting,
- # totally random, or persistent. Hurst obtained a dimensionless statistical
- # exponent by dividing the range by the standard deviation of the
- # observations, so this approach is generally referred to as rescaled range
- # (R/S) analysis.
- #
- # H = log(m)/log(n) where
- # m = [max(r_i) - min(r_i)]/sigma_p
- # n = number of observations
- #
- # A Hurst index between 0.5 and 1 suggests that the returns are persistent.
- # At 0.5, the index suggests returns are totally random. Between 0 and 0.5
- # it suggests that the returns are mean reverting.
- #
- # H.E. Hurst originally developed the Hurst index to help establish optimal
- # water storage along the Nile. Nile floods are extremely persistent,
- # measuring a Hurst index of 0.9. Peters (1991) notes that Equity markets
- # have a Hurst index in excess of 0.5, with typical values of around 0.7.
- # That appears to be anomalous in the context of the mainstream 'rational
- # behaviour' theories of economics, and suggests existence of a powerful
- # 'long-term memory' causal dependence. Clarkson (2001) suggests that an
- # 'over-reaction bias' could be expected to generate a powerful 'long-term
- # memory' effect in share prices.
- #
- # Clarkson, R. (2001) FARM: a financial actuarial risk model. In Chapter
- # 12 of Managing Downside Risk in Financial Markets, F. Sortino and S.
- # Satchel. Butterworth-Heinemann Finance.
- # Peters, E.E (1991) Chaos and Order in Capital Markets, New York: Wiley.
- # Bacon, Carl. (2008) Practical Portfolio Performance Measurement and
- # Attribution, 2nd Edition. London: John Wiley & Sons.
+
R = checkData(R)
rs <- function(R) {
Deleted: pkg/PerformanceAnalytics/R/Return.index.R
===================================================================
--- pkg/PerformanceAnalytics/R/Return.index.R 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/R/Return.index.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -1,54 +0,0 @@
-Return.index <-
-function (R, wealth.index = TRUE, ...)
-{ # @author Peter Carl
-
- # DESCRIPTION:
- # Cumulates the returns given as a cumulative return or a "wealth index".
-
- # Inputs:
- # R: a matrix, data frame, or timeSeries of returns
- # wealth.index: if true, shows the "value of $1", starting the cumulation
- # of returns at 1 rather than zero
-
- # Outputs:
- # A timeseries line chart of the cumulative return series
-
- # FUNCTION:
-
- # Transform input data to a matrix
- x = checkData(R)
-
- # Get dimensions and labels
- columns = ncol(x)
- columnnames = colnames(x)
-
- # Calculate the cumulative return
- one = 0
- if(!wealth.index)
- one = 1
-
- for(column in 1:columns) {
- column.Return.cumulative = na.skip(x[,column,drop=FALSE],FUN = function(x,one) {cumprod(1+x) - one},one=one)
- if(column == 1)
- Return.cumulative = column.Return.cumulative
- else
- Return.cumulative = merge(Return.cumulative,column.Return.cumulative)
- }
- if(columns == 1)
- Return.cumulative = as.xts(Return.cumulative)
- colnames(Return.cumulative) = columnnames
- reclass(Return.cumulative,match.to=x)
-
-}
-
-###############################################################################
-# R (http://r-project.org/) Econometrics for Performance and Risk Analysis
-#
-# Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson
-#
-# This R package is distributed under the terms of the GNU Public License (GPL)
-# for full details see the file COPYING
-#
-# $Id$
-#
-###############################################################################
\ No newline at end of file
Deleted: pkg/PerformanceAnalytics/R/Return.wealthindex.R
===================================================================
--- pkg/PerformanceAnalytics/R/Return.wealthindex.R 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/R/Return.wealthindex.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -1,54 +0,0 @@
-Return.wealthindex <-
-function (R, wealth.index = TRUE, ...)
-{ # @author Peter Carl
-
- # DESCRIPTION:
- # Cumulates the returns given as a cumulative return or a "wealth index".
-
- # Inputs:
- # R: a matrix, data frame, or timeSeries of returns
- # wealth.index: if true, shows the "value of $1", starting the cumulation
- # of returns at 1 rather than zero
-
- # Outputs:
- # A timeseries line chart of the cumulative return series
-
- # FUNCTION:
-
- # Transform input data to a matrix
- x = checkData(R)
-
- # Get dimensions and labels
- columns = ncol(x)
- columnnames = colnames(x)
-
- # Calculate the cumulative return
- one = 0
- if(!wealth.index)
- one = 1
-
- for(column in 1:columns) {
- column.Return.cumulative = na.skip(x[,column,drop=FALSE],FUN = function(x,one) {cumprod(1+x) - one},one=one)
- if(column == 1)
- Return.cumulative = column.Return.cumulative
- else
- Return.cumulative = merge(Return.cumulative,column.Return.cumulative)
- }
- if(columns == 1)
- Return.cumulative = as.xts(Return.cumulative)
- colnames(Return.cumulative) = columnnames
- reclass(Return.cumulative,match.to=x)
-
-}
-
-###############################################################################
-# R (http://r-project.org/) Econometrics for Performance and Risk Analysis
-#
-# Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson
-#
-# This R package is distributed under the terms of the GNU Public License (GPL)
-# for full details see the file COPYING
-#
-# $Id$
-#
-###############################################################################
\ No newline at end of file
Modified: pkg/PerformanceAnalytics/R/mean.utils.R
===================================================================
--- pkg/PerformanceAnalytics/R/mean.utils.R 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/R/mean.utils.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -31,7 +31,7 @@
#' mean.LCL(edhec[,"Funds of Funds"])
#' @rdname mean.geometric
#' @method mean geometric
-#' @export
+#' @export mean.geometric
mean.geometric <-
function (x, ...)
{# @author Peter Carl
@@ -63,7 +63,7 @@
#' @rdname mean.geometric
#' @method mean stderr
-#' @export
+#' @export mean.stderr
mean.stderr <-
function (x, ...)
{# @author Peter Carl
@@ -95,7 +95,7 @@
#' @rdname mean.geometric
#' @method mean LCL
-#' @export
+#' @export mean.LCL
mean.LCL <-
function (x, ci = 0.95, ...)
{# @author Peter Carl
@@ -134,7 +134,7 @@
#' @rdname mean.geometric
#' @method mean UCL
-#' @export
+#' @export mean.UCL
mean.UCL <-
function (x, ci = 0.95, ...)
{# @author Peter Carl
Modified: pkg/PerformanceAnalytics/R/zerofill.R
===================================================================
--- pkg/PerformanceAnalytics/R/zerofill.R 2014-02-20 14:48:26 UTC (rev 3316)
+++ pkg/PerformanceAnalytics/R/zerofill.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -25,6 +25,7 @@
#' that this will skew your results.
#'
#' @param x time series to zero fill
+#' @export
zerofill <- function (x) {
mat<-checkData(x,"matrix")
for(column in 1:ncol(mat)){
Added: pkg/PerformanceAnalytics/man/HurstIndex.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/HurstIndex.Rd (rev 0)
+++ pkg/PerformanceAnalytics/man/HurstIndex.Rd 2014-02-20 17:07:25 UTC (rev 3317)
@@ -0,0 +1,57 @@
+\name{HurstIndex}
+\alias{HurstIndex}
+\title{calculate the Hurst Index
+The Hurst index can be used to measure whether returns are mean reverting,
+totally random, or persistent.}
+\usage{
+ HurstIndex(R, ...)
+}
+\arguments{
+ \item{R}{an xts, vector, matrix, data frame, timeSeries
+ or zoo object of asset returns}
+
+ \item{\dots}{any other passthru parameters}
+}
+\description{
+ Hurst obtained a dimensionless statistical exponent by
+ dividing the range by the standard deviation of the
+ observations, so this approach is commonly referred to as
+ rescaled range (R/S) analysis.
+}
+\details{
+ \deqn{H = log(m)/log(n)}
+
+ where \eqn{m = [max(r_i) - min(r_i)]/sigma_p} and \eqn{n
+ = number of observations} A Hurst index between 0.5 and 1
+ suggests that the returns are persistent. At 0.5, the
+ index suggests returns are totally random. Between 0 and
+ 0.5 it suggests that the returns are mean reverting.
+
+ H.E. Hurst originally developed the Hurst index to help
+ establish optimal water storage along the Nile. Nile
+ floods are extremely persistent, measuring a Hurst index
+ of 0.9. Peters (1991) notes that Equity markets have a
+ Hurst index in excess of 0.5, with typical values of
+ around 0.7. That appears to be anomalous in the context
+ of the mainstream 'rational behaviour' theories of
+ economics, and suggests existence of a powerful
+ 'long-term memory' causal dependence. Clarkson (2001)
+ suggests that an 'over-reaction bias' could be expected
+ to generate a powerful 'long-term memory' effect in share
+ prices.
+}
+\references{
+ Clarkson, R. (2001) FARM: a financial actuarial risk
+ model. In Chapter 12 of Managing Downside Risk in
+ Financial Markets, F. Sortino and S.
+
+ Satchel. Butterworth-Heinemann Finance.
+
+ Peters, E.E (1991) Chaos and Order in Capital Markets,
+ New York: Wiley.
+
+ Bacon, Carl. (2008) Practical Portfolio Performance
+ Measurement and Attribution, 2nd Edition. London: John
+ Wiley & Sons.
+}
+
Copied: pkg/PerformanceAnalytics/sandbox/Return.wealthindex.R (from rev 3315, pkg/PerformanceAnalytics/R/Return.wealthindex.R)
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Return.wealthindex.R (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Return.wealthindex.R 2014-02-20 17:07:25 UTC (rev 3317)
@@ -0,0 +1,54 @@
+Return.wealthindex <-
+function (R, wealth.index = TRUE, ...)
+{ # @author Peter Carl
+
+ # DESCRIPTION:
+ # Cumulates the returns given as a cumulative return or a "wealth index".
+
+ # Inputs:
+ # R: a matrix, data frame, or timeSeries of returns
+ # wealth.index: if true, shows the "value of $1", starting the cumulation
+ # of returns at 1 rather than zero
+
+ # Outputs:
+ # A timeseries line chart of the cumulative return series
+
+ # FUNCTION:
+
+ # Transform input data to a matrix
+ x = checkData(R)
+
+ # Get dimensions and labels
+ columns = ncol(x)
+ columnnames = colnames(x)
+
+ # Calculate the cumulative return
+ one = 0
+ if(!wealth.index)
+ one = 1
+
+ for(column in 1:columns) {
+ column.Return.cumulative = na.skip(x[,column,drop=FALSE],FUN = function(x,one) {cumprod(1+x) - one},one=one)
+ if(column == 1)
+ Return.cumulative = column.Return.cumulative
+ else
+ Return.cumulative = merge(Return.cumulative,column.Return.cumulative)
+ }
+ if(columns == 1)
+ Return.cumulative = as.xts(Return.cumulative)
+ colnames(Return.cumulative) = columnnames
+ reclass(Return.cumulative,match.to=x)
+
+}
+
+###############################################################################
+# R (http://r-project.org/) Econometrics for Performance and Risk Analysis
+#
+# Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson
+#
+# This R package is distributed under the terms of the GNU Public License (GPL)
+# for full details see the file COPYING
+#
+# $Id$
+#
+###############################################################################
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list