[Returnanalytics-commits] r3333 - in pkg/PerformanceAnalytics: . R man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 23 17:21:50 CET 2014


Author: braverock
Date: 2014-02-23 17:21:50 +0100 (Sun, 23 Feb 2014)
New Revision: 3333

Modified:
   pkg/PerformanceAnalytics/.Rbuildignore
   pkg/PerformanceAnalytics/DESCRIPTION
   pkg/PerformanceAnalytics/NAMESPACE
   pkg/PerformanceAnalytics/R/CAPM.dynamic.R
   pkg/PerformanceAnalytics/R/MSquaredExcess.R
   pkg/PerformanceAnalytics/R/MarketTiming.R
   pkg/PerformanceAnalytics/R/StdDev.annualized.R
   pkg/PerformanceAnalytics/R/TreynorRatio.R
   pkg/PerformanceAnalytics/R/chart.TimeSeries.R
   pkg/PerformanceAnalytics/R/charts.RollingPerformance.R
   pkg/PerformanceAnalytics/R/lpm.R
   pkg/PerformanceAnalytics/R/table.AnnualizedReturns.R
   pkg/PerformanceAnalytics/R/table.Arbitrary.R
   pkg/PerformanceAnalytics/R/table.Autocorrelation.R
   pkg/PerformanceAnalytics/R/table.CAPM.R
   pkg/PerformanceAnalytics/R/table.CalendarReturns.R
   pkg/PerformanceAnalytics/R/table.CaptureRatios.R
   pkg/PerformanceAnalytics/R/table.Correlation.R
   pkg/PerformanceAnalytics/R/table.DownsideRisk.R
   pkg/PerformanceAnalytics/R/table.Drawdowns.R
   pkg/PerformanceAnalytics/R/table.HigherMoments.R
   pkg/PerformanceAnalytics/R/table.MonthlyReturns.R
   pkg/PerformanceAnalytics/R/table.RollingPeriods.R
   pkg/PerformanceAnalytics/R/textplot.R
   pkg/PerformanceAnalytics/R/zzz.R
   pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd
   pkg/PerformanceAnalytics/man/MSquaredExcess.Rd
   pkg/PerformanceAnalytics/man/MarketTiming.Rd
   pkg/PerformanceAnalytics/man/TreynorRatio.Rd
   pkg/PerformanceAnalytics/man/chart.TimeSeries.Rd
   pkg/PerformanceAnalytics/man/charts.RollingPerformance.Rd
   pkg/PerformanceAnalytics/man/table.AnnualizedReturns.Rd
   pkg/PerformanceAnalytics/man/table.Arbitrary.Rd
   pkg/PerformanceAnalytics/man/table.Autocorrelation.Rd
   pkg/PerformanceAnalytics/man/table.CAPM.Rd
   pkg/PerformanceAnalytics/man/table.CalendarReturns.Rd
   pkg/PerformanceAnalytics/man/table.CaptureRatios.Rd
   pkg/PerformanceAnalytics/man/table.Correlation.Rd
   pkg/PerformanceAnalytics/man/table.DownsideRisk.Rd
   pkg/PerformanceAnalytics/man/table.Drawdowns.Rd
   pkg/PerformanceAnalytics/man/table.HigherMoments.Rd
   pkg/PerformanceAnalytics/man/table.MonthlyReturns.Rd
   pkg/PerformanceAnalytics/man/table.RollingPeriods.Rd
   pkg/PerformanceAnalytics/man/textplot.Rd
   pkg/PerformanceAnalytics/vignettes/PA-Bacon.Rnw
   pkg/PerformanceAnalytics/vignettes/PA-charts.Rnw
   pkg/PerformanceAnalytics/vignettes/PerformanceAnalyticsChartsPresentation-Meielisalp-2007.Rnw
   pkg/PerformanceAnalytics/vignettes/PerformanceAnalyticsPresentation-UseR-2007.Rnw
   pkg/PerformanceAnalytics/vignettes/textplotPresentation-CRUG-2011.Rnw
Log:
- more fixes for R CMD check prior to CRAN release

Modified: pkg/PerformanceAnalytics/.Rbuildignore
===================================================================
--- pkg/PerformanceAnalytics/.Rbuildignore	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/.Rbuildignore	2014-02-23 16:21:50 UTC (rev 3333)
@@ -3,3 +3,4 @@
 ChangeLog.1.0.0
 ^.*\.Rproj$
 ^\.Rproj\.user$
+codeblock.txt

Modified: pkg/PerformanceAnalytics/DESCRIPTION
===================================================================
--- pkg/PerformanceAnalytics/DESCRIPTION	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/DESCRIPTION	2014-02-23 16:21:50 UTC (rev 3333)
@@ -15,7 +15,7 @@
     numbers of functions will work with P&L or price data
     where possible.
 Depends:
-    R (>= 2.14.0),
+    R (>= 3.0.0),
     zoo,
     xts (>= 0.8-9)
 Suggests:
@@ -32,8 +32,7 @@
 URL: http://r-forge.r-project.org/projects/returnanalytics/
 Copyright: (c) 2004-2014
 Contributors: Kris Boudt,  Diethelm Wuertz, Eric Zivot, Matthieu Lestel
-Thanks: A special thanks for additional contributions from
+Thanks: A special thanks for additional contributions or patches from
     Stefan Albrecht, Khahn Nygyen, Jeff Ryan,
     Josh Ulrich, Sankalp Upadhyay, Tobias Verbeke,
-    H. Felix Wittmann, Ram Ahluwalia
-
+    H. Felix Wittmann, Ram Ahluwalia, R. Douglas Martin

Modified: pkg/PerformanceAnalytics/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/NAMESPACE	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/NAMESPACE	2014-02-23 16:21:50 UTC (rev 3333)
@@ -230,6 +230,7 @@
 export(tol8qualitative)
 export(tol9qualitative)
 export(zerofill)
+import(xts)
 importFrom(stats,sd)
 importFrom(utils,packageDescription)
 importFrom(zoo,rollapply)

Modified: pkg/PerformanceAnalytics/R/CAPM.dynamic.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.dynamic.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/CAPM.dynamic.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -48,10 +48,15 @@
 #' @examples
 #' 
 #' data(managers)
-#' CAPM.dynamic(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12, Z=managers[, 9:10])
-#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,7,drop=FALSE], Rf=managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
-#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+#' CAPM.dynamic(managers[,1,drop=FALSE], managers[,8,drop=FALSE], 
+#'              Rf=.035/12, Z=managers[, 9:10])
 #' 
+#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,7,drop=FALSE], 
+#'              Rf=managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+#'              
+#' CAPM.dynamic(managers[80:120,1:6], managers[80:120,8:7],
+#'               managers[80:120,10,drop=FALSE], Z=managers[80:120, 9:10])
+#' 
 #' @rdname CAPM.dynamic 
 #' @export CAPM.dynamic SFM.dynamic 
 CAPM.dynamic <- SFM.dynamic <- function (Ra, Rb, Rf = 0, Z, lags = 1, ...)

Modified: pkg/PerformanceAnalytics/R/MSquaredExcess.R
===================================================================
--- pkg/PerformanceAnalytics/R/MSquaredExcess.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/MSquaredExcess.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -23,12 +23,13 @@
 #' @examples
 #'
 #' data(portfolio_bacon)
-#' print(MSquaredExcess(portfolio_bacon[,1], portfolio_bacon[,2])) #expected -0.00998
-#' print(MSquaredExcess(portfolio_bacon[,1], portfolio_bacon[,2], Method="arithmetic")) #expected -0.011
+#' MSquaredExcess(portfolio_bacon[,1], portfolio_bacon[,2]) #expected -0.00998
+#' 
+#' MSquaredExcess(portfolio_bacon[,1], portfolio_bacon[,2], Method="arithmetic") #expected -0.011
 #'
 #' data(managers)
-#' print(MSquaredExcess(managers['1996',1], managers['1996',8]))
-#' print(MSquaredExcess(managers['1996',1:5], managers['1996',8]))
+#' MSquaredExcess(managers['1996',1], managers['1996',8])
+#' MSquaredExcess(managers['1996',1:5], managers['1996',8])
 #'
 #' @export 
 MSquaredExcess <-

Modified: pkg/PerformanceAnalytics/R/MarketTiming.R
===================================================================
--- pkg/PerformanceAnalytics/R/MarketTiming.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/MarketTiming.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -1,96 +1,96 @@
-#' Market timing models
-#' 
-#' Allows to estimate Treynor-Mazuy or Merton-Henriksson market timing model.
-#' The Treynor-Mazuy model is essentially a quadratic extension of the basic
-#' CAPM. It is estimated using a multiple regression. The second term in the
-#' regression is the value of excess return squared. If the gamma coefficient
-#' in the regression is positive, then the estimated equation describes a 
-#' convex upward-sloping regression "line". The quadratic regression is:
-#' \deqn{R_{p}-R_{f}=\alpha+\beta (R_{b} - R_{f})+\gamma (R_{b}-R_{f})^2+
-#' \varepsilon_{p}}{Rp - Rf = alpha + beta(Rb -Rf) + gamma(Rb - Rf)^2 + 
-#' epsilonp}
-#' \eqn{\gamma}{gamma} is a measure of the curvature of the regression line.
-#' If \eqn{\gamma}{gamma} is positive, this would indicate that the manager's
-#' investment strategy demonstrates market timing ability.
-#' 
-#' The basic idea of the Merton-Henriksson test is to perform a multiple 
-#' regression in which the dependent variable (portfolio excess return and a 
-#' second variable that mimics the payoff to an option). This second variable 
-#' is zero when the market excess return is at or below zero and is 1 when it 
-#' is above zero:
-#' \deqn{R_{p}-R_{f}=\alpha+\beta (R_{b}-R_{f})+\gamma D+\varepsilon_{p}}{Rp - 
-#' Rf = alpha + beta * (Rb - Rf) + gamma * D + epsilonp}
-#' where all variables are familiar from the CAPM model, except for the 
-#' up-market return \eqn{D=max(0,R_{b}-R_{f})}{D = max(0, Rb - Rf)} and market 
-#' timing abilities \eqn{\gamma}{gamma}
-#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
-#' the asset returns
-#' @param Rb an xts, vector, matrix, data frame, timeSeries or zoo object of 
-#' the benchmark asset return
-#' @param Rf risk free rate, in same period as your returns
-#' @param method used to select between Treynor-Mazuy and Henriksson-Merton
-#' models. May be any of: \itemize{ \item TM - Treynor-Mazuy model, 
-#' \item HM - Henriksson-Merton model} By default Treynor-Mazuy is selected
-#' @param \dots any other passthrough parameters
-#' @author Andrii Babii, Peter Carl
-#' @seealso \code{\link{CAPM.beta}}
-#' @references J. Christopherson, D. Carino, W. Ferson. \emph{Portfolio 
-#' Performance Measurement and Benchmarking}. 2009. McGraw-Hill, p. 127-133.
-#' \cr J. L. Treynor and K. Mazuy, "Can Mutual Funds Outguess the Market?" 
-#' \emph{Harvard Business Review}, vol44, 1966, pp. 131-136 
-#' \cr Roy D. Henriksson and Robert C. Merton, "On Market Timing and Investment
-#' Performance. II. Statistical Procedures for Evaluating Forecast Skills," 
-#' \emph{Journal of Business}, vol.54, October 1981, pp.513-533 \cr
-#' @examples
-#' 
-#' data(managers)
-#' MarketTiming(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12, method = "HM")
-#' MarketTiming(managers[80:120,1:6], managers[80:120,7,drop=FALSE], managers[80:120,10,drop=FALSE])
-#' MarketTiming(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10,drop=FALSE], method = "TM")
-#'
-#' @export
-MarketTiming <- function (Ra, Rb, Rf = 0, method = c("TM", "HM"))
-{ # @author Andrii Babii, Peter Carl
-  
-    # FUNCTION
-  
-    Ra = checkData(Ra)
-    Rb = checkData(Rb)
-    if (!is.null(dim(Rf))) 
-      Rf = checkData(Rf)
-    Ra.ncols = NCOL(Ra)
-    Rb.ncols = NCOL(Rb)
-    pairs = expand.grid(1:Ra.ncols, 1)
-    method = method[1]
-    xRa = Return.excess(Ra, Rf)
-    xRb = Return.excess(Rb, Rf)
-
-    mt <- function (xRa, xRb)
-    {
-      switch(method,
-             "HM" = { S = xRb > 0 },
-             "TM" = { S = xRb }
-      )
-      R = merge(xRa, xRb, xRb*S)
-      R.df = as.data.frame(R)
-      model = lm(R.df[, 1] ~ 1 + ., data = R.df[, -1])
-      return(coef(model))
-    }
-  
-    result = apply(pairs, 1, FUN = function(n, xRa, xRb) 
-      mt(xRa[, n[1]], xRb[, 1]), xRa = xRa, xRb = xRb)
-    result = t(result)
-    
-    if (ncol(Rb) > 1){
-      for (i in 2:ncol(xRb)){
-        res = apply(pairs, 1, FUN = function(n, xRa, xRb) 
-          mt(xRa[, n[1]], xRb[, i]), xRa = xRa, xRb = xRb)
-        res = t(res)
-        result = rbind(result, res)
-      }
-    }
-  
-    rownames(result) = paste(rep(colnames(Ra), ncol(Rb)), "to",  rep(colnames(Rb), each = ncol(Ra)))
-    colnames(result) = c("Alpha", "Beta", "Gamma")
-    return(result)
+#' Market timing models
+#' 
+#' Allows to estimate Treynor-Mazuy or Merton-Henriksson market timing model.
+#' The Treynor-Mazuy model is essentially a quadratic extension of the basic
+#' CAPM. It is estimated using a multiple regression. The second term in the
+#' regression is the value of excess return squared. If the gamma coefficient
+#' in the regression is positive, then the estimated equation describes a 
+#' convex upward-sloping regression "line". The quadratic regression is:
+#' \deqn{R_{p}-R_{f}=\alpha+\beta (R_{b} - R_{f})+\gamma (R_{b}-R_{f})^2+
+#' \varepsilon_{p}}{Rp - Rf = alpha + beta(Rb -Rf) + gamma(Rb - Rf)^2 + 
+#' epsilonp}
+#' \eqn{\gamma}{gamma} is a measure of the curvature of the regression line.
+#' If \eqn{\gamma}{gamma} is positive, this would indicate that the manager's
+#' investment strategy demonstrates market timing ability.
+#' 
+#' The basic idea of the Merton-Henriksson test is to perform a multiple 
+#' regression in which the dependent variable (portfolio excess return and a 
+#' second variable that mimics the payoff to an option). This second variable 
+#' is zero when the market excess return is at or below zero and is 1 when it 
+#' is above zero:
+#' \deqn{R_{p}-R_{f}=\alpha+\beta (R_{b}-R_{f})+\gamma D+\varepsilon_{p}}{Rp - 
+#' Rf = alpha + beta * (Rb - Rf) + gamma * D + epsilonp}
+#' where all variables are familiar from the CAPM model, except for the 
+#' up-market return \eqn{D=max(0,R_{b}-R_{f})}{D = max(0, Rb - Rf)} and market 
+#' timing abilities \eqn{\gamma}{gamma}
+#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' the asset returns
+#' @param Rb an xts, vector, matrix, data frame, timeSeries or zoo object of 
+#' the benchmark asset return
+#' @param Rf risk free rate, in same period as your returns
+#' @param method used to select between Treynor-Mazuy and Henriksson-Merton
+#' models. May be any of: \itemize{ \item TM - Treynor-Mazuy model, 
+#' \item HM - Henriksson-Merton model} By default Treynor-Mazuy is selected
+#' @param \dots any other passthrough parameters
+#' @author Andrii Babii, Peter Carl
+#' @seealso \code{\link{CAPM.beta}}
+#' @references J. Christopherson, D. Carino, W. Ferson. \emph{Portfolio 
+#' Performance Measurement and Benchmarking}. 2009. McGraw-Hill, p. 127-133.
+#' \cr J. L. Treynor and K. Mazuy, "Can Mutual Funds Outguess the Market?" 
+#' \emph{Harvard Business Review}, vol44, 1966, pp. 131-136 
+#' \cr Roy D. Henriksson and Robert C. Merton, "On Market Timing and Investment
+#' Performance. II. Statistical Procedures for Evaluating Forecast Skills," 
+#' \emph{Journal of Business}, vol.54, October 1981, pp.513-533 \cr
+#' @examples
+#' 
+#' data(managers)
+#' MarketTiming(managers[,1], managers[,8], Rf=.035/12, method = "HM")
+#' MarketTiming(managers[80:120,1:6], managers[80:120,7], managers[80:120,10])
+#' MarketTiming(managers[80:120,1:6], managers[80:120,8:7], managers[80:120,10], method = "TM")
+#'
+#' @export
+MarketTiming <- function (Ra, Rb, Rf = 0, method = c("TM", "HM"))
+{ # @author Andrii Babii, Peter Carl
+  
+    # FUNCTION
+  
+    Ra = checkData(Ra)
+    Rb = checkData(Rb)
+    if (!is.null(dim(Rf))) 
+      Rf = checkData(Rf)
+    Ra.ncols = NCOL(Ra)
+    Rb.ncols = NCOL(Rb)
+    pairs = expand.grid(1:Ra.ncols, 1)
+    method = method[1]
+    xRa = Return.excess(Ra, Rf)
+    xRb = Return.excess(Rb, Rf)
+
+    mt <- function (xRa, xRb)
+    {
+      switch(method,
+             "HM" = { S = xRb > 0 },
+             "TM" = { S = xRb }
+      )
+      R = merge(xRa, xRb, xRb*S)
+      R.df = as.data.frame(R)
+      model = lm(R.df[, 1] ~ 1 + ., data = R.df[, -1])
+      return(coef(model))
+    }
+  
+    result = apply(pairs, 1, FUN = function(n, xRa, xRb) 
+      mt(xRa[, n[1]], xRb[, 1]), xRa = xRa, xRb = xRb)
+    result = t(result)
+    
+    if (ncol(Rb) > 1){
+      for (i in 2:ncol(xRb)){
+        res = apply(pairs, 1, FUN = function(n, xRa, xRb) 
+          mt(xRa[, n[1]], xRb[, i]), xRa = xRa, xRb = xRb)
+        res = t(res)
+        result = rbind(result, res)
+      }
+    }
+  
+    rownames(result) = paste(rep(colnames(Ra), ncol(Rb)), "to",  rep(colnames(Rb), each = ncol(Ra)))
+    colnames(result) = c("Alpha", "Beta", "Gamma")
+    return(result)
 }
\ No newline at end of file

Modified: pkg/PerformanceAnalytics/R/StdDev.annualized.R
===================================================================
--- pkg/PerformanceAnalytics/R/StdDev.annualized.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/StdDev.annualized.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -45,7 +45,7 @@
 #'     sd.multiperiod(edhec[,6,drop=FALSE],scale=3)
 #' 
 #' @export StdDev.annualized sd.annualized sd.multiperiod
-#' @alias StdDev.annualized sd.annualized sd.multiperiod
+#' @aliases StdDev.annualized sd.annualized sd.multiperiod
 #' @rdname StdDev.annualized
 StdDev.annualized <- sd.annualized <- sd.multiperiod <-
 function (x, scale = NA, ...)

Modified: pkg/PerformanceAnalytics/R/TreynorRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/TreynorRatio.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/TreynorRatio.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -30,12 +30,12 @@
 #'
 #' data(portfolio_bacon) 
 #' data(managers)
-#' round(TreynorRatio(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf=.035/12),4) 
-#' round(TreynorRatio(managers[,1,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]),4) 
-#' round(TreynorRatio(managers[,1:6], managers[,8,drop=FALSE], Rf=.035/12),4) 
-#' round(TreynorRatio(managers[,1:6], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE]),4)
-#' round(TreynorRatio(managers[,1:6], managers[,8:7,drop=FALSE], Rf=.035/12),4) 
-#' round(TreynorRatio(managers[,1:6], managers[,8:7,drop=FALSE], Rf = managers[,10,drop=FALSE]),4)
+#' round(TreynorRatio(managers[,1], managers[,8], Rf=.035/12),4) 
+#' round(TreynorRatio(managers[,1], managers[,8], Rf = managers[,10]),4) 
+#' round(TreynorRatio(managers[,1:6], managers[,8], Rf=.035/12),4) 
+#' round(TreynorRatio(managers[,1:6], managers[,8], Rf = managers[,10]),4)
+#' round(TreynorRatio(managers[,1:6], managers[,8:7], Rf=.035/12),4) 
+#' round(TreynorRatio(managers[,1:6], managers[,8:7], Rf = managers[,10]),4)
 #'
 #' print(TreynorRatio(portfolio_bacon[,1], portfolio_bacon[,2], modified = TRUE)) #expected 0.7975 
 #'

Modified: pkg/PerformanceAnalytics/R/chart.TimeSeries.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.TimeSeries.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/chart.TimeSeries.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -135,7 +135,13 @@
 #' R=edhec[,"Funds of Funds",drop=FALSE]
 #' Return.cumulative = cumprod(1+R) - 1
 #' chart.TimeSeries(Return.cumulative)
-#' chart.TimeSeries(Return.cumulative, colorset = "darkblue", legend.loc = "bottomright", period.areas = cycles.dates, period.color = "lightblue", event.lines = risk.dates, event.labels = risk.labels, event.color = "red", lwd = 2)
+#' chart.TimeSeries(Return.cumulative, colorset = "darkblue", 
+#'                  legend.loc = "bottomright", 
+#'                  period.areas = cycles.dates, 
+#'                  period.color = "lightblue", 
+#'                  event.lines = risk.dates, 
+#'                  event.labels = risk.labels, 
+#'                  event.color = "red", lwd = 2)
 #' 
 #' @export 
 chart.TimeSeries <-

Modified: pkg/PerformanceAnalytics/R/charts.RollingPerformance.R
===================================================================
--- pkg/PerformanceAnalytics/R/charts.RollingPerformance.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/charts.RollingPerformance.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -21,7 +21,11 @@
 #' @examples
 #' 
 #' data(managers)
-#' charts.RollingPerformance(managers[,1:8], Rf=managers[,10,drop=FALSE], colorset=tim8equal, main="Rolling 12-Month Performance", legend.loc="topleft")
+#' charts.RollingPerformance(managers[,1:8], 
+#'                           Rf=managers[,10,drop=FALSE], 
+#'                           colorset=tim8equal, 
+#'                           main="Rolling 12-Month Performance", 
+#'                           legend.loc="topleft")
 #' 
 #' @export 
 charts.RollingPerformance <-

Modified: pkg/PerformanceAnalytics/R/lpm.R
===================================================================
--- pkg/PerformanceAnalytics/R/lpm.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/lpm.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -19,35 +19,33 @@
 #' @export
 lpm <- function(R,n=2,threshold=0,about_mean=FALSE){
 
+  R <- checkData(R)
   if(about_mean==TRUE){
     #Calculate Number of obs less than threshold
-    nb = nrow(x[x<threshold,])
+    nb = nrow(R[R<threshold,])
     #Calculate mean of all obs less than threshold
-    R_avg = mean(x[x<threshold,],na.rm=T)
+    R_avg = mean(R[R<threshold,],na.rm=T)
     #subset data as less than threshold
-    x_cond = x[x<threshold,]
+    x_cond = R[R<threshold,]
     #Calculate LPM
 
     LPM = (1/nb) * sum(max(0,R_avg-x_cond)^n)
   } else {
 
   #Calculate Number of obs less than threshold
-    nb = nrow(x[x<threshold,])
+    nb = nrow(R[R<threshold,])
     #Calculate mean of all obs less than threshold
     R_avg = threshold
     #subset data as less than threshold
-    x_cond = x[x<threshold,]
+    x_cond = R[R<threshold,]
     #Calculate LPM
 
     LPM = (1/nb) * sum(max(0,R_avg-x_cond)^n)
 
   }
-
   return(LPM)
 }
 
-
-
 ###############################################################################
 # R (http://r-project.org/) Econometrics for Performance and Risk Analysis
 #

Modified: pkg/PerformanceAnalytics/R/table.AnnualizedReturns.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.AnnualizedReturns.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.AnnualizedReturns.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -23,7 +23,12 @@
 #' require("Hmisc")
 #' result = t(table.AnnualizedReturns(managers[,1:8], Rf=.04/12))
 #' 
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=c(3,3,1)), rmar = 0.8, cmar = 2,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=20, wrap.colnames=10, col.rownames=c("red", rep("darkgray",5), rep("orange",2)), mar = c(0,0,3,0)+0.1)
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#'          cdec=c(3,3,1)), rmar = 0.8, cmar = 2,  max.cex=.9, 
+#'          halign = "center", valign = "top", row.valign="center", 
+#'          wrap.rownames=20, wrap.colnames=10, col.rownames=c("red", 
+#'          rep("darkgray",5), rep("orange",2)), mar = c(0,0,3,0)+0.1)
+#'          
 #' title(main="Annualized Performance")
 #' 
 #' @export

Modified: pkg/PerformanceAnalytics/R/table.Arbitrary.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.Arbitrary.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.Arbitrary.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -63,7 +63,8 @@
 #' @examples
 #' 
 #' data(edhec)
-#' table.Arbitrary(edhec,metrics=c("VaR", "ES"),metricsNames=c("Modified VaR","Modified Expected Shortfall"))
+#' table.Arbitrary(edhec,metrics=c("VaR", "ES"),
+#'                 metricsNames=c("Modified VaR","Modified Expected Shortfall"))
 #' 
 #' @export
 table.Arbitrary <-

Modified: pkg/PerformanceAnalytics/R/table.Autocorrelation.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.Autocorrelation.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.Autocorrelation.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -24,7 +24,11 @@
 #' t(table.Autocorrelation(managers))
 #' 
 #' result = t(table.Autocorrelation(managers[,1:8]))
-#' textplot(result, rmar = 0.8, cmar = 2,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' 
+#' textplot(result, rmar = 0.8, cmar = 2,  max.cex=.9, halign = "center", 
+#'          valign = "top", row.valign="center", wrap.rownames=15, 
+#'          wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#'          
 #' title(main="Autocorrelation")
 #' 
 #' @export

Modified: pkg/PerformanceAnalytics/R/table.CAPM.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.CAPM.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.CAPM.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -21,10 +21,12 @@
 #' @examples
 #'
 #' data(managers)
-#' table.SFM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE])
+#' table.SFM(managers[,1:3], managers[,8], Rf = managers[,10])
 #'
-#' result = table.SFM(managers[,1:3,drop=FALSE], managers[,8,drop=FALSE], Rf = managers[,10,drop=FALSE])
-#' textplot(result, rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' result = table.SFM(managers[,1:3], managers[,8], Rf = managers[,10])
+#' textplot(result, rmar = 0.8, cmar = 1.5,  max.cex=.9, 
+#'          halign = "center", valign = "top", row.valign="center", 
+#'          wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
 #' title(main="Single Factor Model Related Statistics")
 #'
 #' @rdname table.CAPM

Modified: pkg/PerformanceAnalytics/R/table.CalendarReturns.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.CalendarReturns.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.CalendarReturns.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -27,7 +27,14 @@
 #' # prettify with format.df in hmisc package
 #' require("Hmisc")
 #' result = t(table.CalendarReturns(managers[,c(1,8)]))
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=rep(1,dim(result)[2])), rmar = 0.8, cmar = 1,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=20, wrap.colnames=10, col.rownames=c( rep("darkgray",12), "black", "blue"), mar = c(0,0,3,0)+0.1)
+#' 
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#'          cdec=rep(1,dim(result)[2])), rmar = 0.8, cmar = 1,  
+#'          max.cex=.9, halign = "center", valign = "top", 
+#'          row.valign="center", wrap.rownames=20, wrap.colnames=10, 
+#'          col.rownames=c( rep("darkgray",12), "black", "blue"), 
+#'          mar = c(0,0,3,0)+0.1)
+#'          
 #' title(main="Calendar Returns")
 #' 
 #' @export

Modified: pkg/PerformanceAnalytics/R/table.CaptureRatios.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.CaptureRatios.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.CaptureRatios.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -22,9 +22,12 @@
 #' table.CaptureRatios(managers[,1:6], managers[,7,drop=FALSE])
 #' table.UpDownRatios(managers[,1:6], managers[,7,drop=FALSE])
 #' 
-#' result = t(table.UpDownRatios(managers[,1:6], managers[,7,drop=FALSE]))
+#' result = t(table.UpDownRatios(managers[,1:6], managers[,7,drop=FALSE])) 
 #' colnames(result)=colnames(managers[,1:6])
-#' textplot(result, rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' textplot(result, rmar = 0.8, cmar = 1.5,  max.cex=.9, 
+#'          halign = "center", valign = "top", row.valign="center", 
+#'          wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#'          
 #' title(main="Capture Ratios for EDHEC LS EQ")
 #' 
 #' @aliases table.CaptureRatios table.UpDownRatios

Modified: pkg/PerformanceAnalytics/R/table.Correlation.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.Correlation.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.Correlation.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -20,7 +20,10 @@
 #' result=table.Correlation(managers[,1:6],managers[,8])
 #' rownames(result)=colnames(managers[,1:6])
 #' require("Hmisc")
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=20, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#'          cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  
+#'          max.cex=.9, halign = "center", valign = "top", row.valign="center"
+#'          , wrap.rownames=20, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
 #' title(main="Correlations to SP500 TR")
 #' 
 #' ctable = table.Correlation(managers[,1:6],managers[,8,drop=FALSE], conf.level=.99)

Modified: pkg/PerformanceAnalytics/R/table.DownsideRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.DownsideRisk.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.DownsideRisk.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -28,7 +28,10 @@
 #' 
 #' result=t(table.DownsideRisk(edhec, Rf=.04/12, MAR =.05/12, p=.95))
 #' require("Hmisc")
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#'          cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  
+#'          max.cex=.9, halign = "center", valign = "top", row.valign="center", 
+#'          wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
 #' title(main="Downside Risk Statistics")
 #'
 #' @export 

Modified: pkg/PerformanceAnalytics/R/table.Drawdowns.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.Drawdowns.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.Drawdowns.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -40,7 +40,10 @@
 #' 
 #' # This was really nice before Hmisc messed up 'format' from R-base
 #' #require("Hmisc")
-#' #textplot(Hmisc::format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=c(rep(3,4), rep(0,3))), rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=5, wrap.colnames=10, mar = c(0,0,3,0)+0.1) 
+#' #textplot(Hmisc::format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#' #           cdec=c(rep(3,4), rep(0,3))), rmar = 0.8, cmar = 1.5,  
+#' #           max.cex=.9, halign = "center", valign = "top", row.valign="center", 
+#' #           wrap.rownames=5, wrap.colnames=10, mar = c(0,0,3,0)+0.1) 
 #' # title(main="Largest Drawdowns for HAM1")
 #' 
 #' @export

Modified: pkg/PerformanceAnalytics/R/table.HigherMoments.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.HigherMoments.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.HigherMoments.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -30,7 +30,10 @@
 #' result=t(table.HigherMoments(managers[,1:6],managers[,8,drop=FALSE]))
 #' rownames(result)=colnames(managers[,1:6])
 #' require("Hmisc")
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=5, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#'          cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  
+#'          max.cex=.9, halign = "center", valign = "top", row.valign="center", 
+#'          wrap.rownames=5, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
 #' title(main="Higher Co-Moments with SP500 TR")
 #' 
 #' @export

Modified: pkg/PerformanceAnalytics/R/table.MonthlyReturns.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.MonthlyReturns.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.MonthlyReturns.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -24,7 +24,9 @@
 #' 
 #' result=t(table.Stats(edhec))
 #' require("Hmisc")
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=c(rep(1,2),rep(3,14))), rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=10, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=c(rep(1,2),rep(3,14))), 
+#'          rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", 
+#'          row.valign="center", wrap.rownames=10, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
 #' title(main="Statistics for EDHEC Indexes")
 #' 
 #' @rdname table.MonthlyReturns

Modified: pkg/PerformanceAnalytics/R/table.RollingPeriods.R
===================================================================
--- pkg/PerformanceAnalytics/R/table.RollingPeriods.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/table.RollingPeriods.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -25,14 +25,14 @@
 #' @examples
 #' 
 #' data(edhec)
-#' #table.TrailingPeriods(edhec[,10:13], FUNCS=c("SharpeRatio","VaR"), funcs.names = c("Sharpe Ratio", "Modified VaR"), periods=c(12,24,36))
-#' 
-#' #result=table.TrailingPeriods(edhec[,10:13], FUNCS=c("SharpeRatio","VaR"), funcs.names = c("Sharpe Ratio", "Modified VaR"), periods=c(12,24,36))
 #' table.TrailingPeriods(edhec[,10:13], periods=c(12,24,36))
 #' 
 #' result=table.TrailingPeriods(edhec[,10:13], periods=c(12,24,36))
 #' require("Hmisc")
-#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
+#' textplot(format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#'                    cdec=rep(3,dim(result)[2])), rmar = 0.8, cmar = 1.5,  
+#'                    max.cex=.9, halign = "center", valign = "top", row.valign="center", 
+#'                    wrap.rownames=15, wrap.colnames=10, mar = c(0,0,3,0)+0.1)
 #' title(main="Trailing Period Statistics")
 #' 
 #' @export

Modified: pkg/PerformanceAnalytics/R/textplot.R
===================================================================
--- pkg/PerformanceAnalytics/R/textplot.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/textplot.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -86,10 +86,14 @@
 #' # This was really nice before Hmisc messed up 'format' from R-base
 #' # prettify with format.df in hmisc package
 #' # require("Hmisc")
-#'   result = t(table.CalendarReturns(managers[,1:8]))[-1:-12,]
+#' # result = t(table.CalendarReturns(managers[,1:8]))[-1:-12,]
 #' 
-#' #  textplot(Hmisc::format.df(result, na.blank=TRUE, numeric.dollar=FALSE, cdec=rep(1,dim(result)[2])), rmar = 0.8, cmar = 1,  max.cex=.9, halign = "center", valign = "top", row.valign="center", wrap.rownames=20, wrap.colnames=10, col.rownames=c("red", rep("darkgray",5), rep("orange",2)), mar = c(0,0,4,0)+0.1)
-#' 
+#' #  textplot(Hmisc::format.df(result, na.blank=TRUE, numeric.dollar=FALSE, 
+#' #           cdec=rep(1,dim(result)[2])), rmar = 0.8, cmar = 1,  max.cex=.9, 
+#' #           halign = "center", valign = "top", row.valign="center", wrap.rownames=20, 
+#' #           wrap.colnames=10, col.rownames=c("red", rep("darkgray",5), 
+#' #           rep("orange",2)), mar = c(0,0,4,0)+0.1)
+#' #
 #' # title(main="Calendar Returns")
 #'
 #' @S3method textplot default 

Modified: pkg/PerformanceAnalytics/R/zzz.R
===================================================================
--- pkg/PerformanceAnalytics/R/zzz.R	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/R/zzz.R	2014-02-23 16:21:50 UTC (rev 3333)
@@ -20,6 +20,7 @@
 #' @importFrom utils packageDescription
 #' @importFrom stats sd
 #' @importFrom zoo rollapply
+#' @import xts
 NULL
 
 ###############################################################################

Modified: pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd	2014-02-23 12:51:48 UTC (rev 3332)
+++ pkg/PerformanceAnalytics/man/CAPM.dynamic.Rd	2014-02-23 16:21:50 UTC (rev 3333)
@@ -57,9 +57,14 @@
 }
 \examples{
 data(managers)
[TRUNCATED]

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


More information about the Returnanalytics-commits mailing list