[Returnanalytics-commits] r2187 - in pkg/PerformanceAnalytics: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jul 21 18:23:23 CEST 2012
Author: matthieu_lestel
Date: 2012-07-21 18:23:23 +0200 (Sat, 21 Jul 2012)
New Revision: 2187
Added:
pkg/PerformanceAnalytics/R/Frequency.R
pkg/PerformanceAnalytics/R/MSquaredExcess.R
pkg/PerformanceAnalytics/man/Frequency.Rd
pkg/PerformanceAnalytics/man/MSquaredExcess.Rd
Modified:
pkg/PerformanceAnalytics/NAMESPACE
pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
pkg/PerformanceAnalytics/R/BernadoLedoitratio.R
pkg/PerformanceAnalytics/R/BurkeRatio.R
pkg/PerformanceAnalytics/R/CAPM.epsilon.R
pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R
pkg/PerformanceAnalytics/R/CoMoments.R
pkg/PerformanceAnalytics/R/DRatio.R
pkg/PerformanceAnalytics/R/DownsideDeviation.R
pkg/PerformanceAnalytics/R/DownsideFrequency.R
pkg/PerformanceAnalytics/R/DrawdownPeak.R
pkg/PerformanceAnalytics/R/MSquared.R
pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R
pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R
pkg/PerformanceAnalytics/R/PainIndex.R
pkg/PerformanceAnalytics/R/PainRatio.R
pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
pkg/PerformanceAnalytics/R/SystematicRisk.R
pkg/PerformanceAnalytics/R/TotalRisk.R
pkg/PerformanceAnalytics/R/TreynorRatio.R
pkg/PerformanceAnalytics/R/UpsideFrequency.R
pkg/PerformanceAnalytics/R/UpsideRisk.R
pkg/PerformanceAnalytics/R/VolatilitySkewness.R
pkg/PerformanceAnalytics/R/chart.Correlation.R
pkg/PerformanceAnalytics/R/kurtosis.R
pkg/PerformanceAnalytics/R/skewness.R
pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd
pkg/PerformanceAnalytics/man/BurkeRatio.Rd
pkg/PerformanceAnalytics/man/CAPM.epsilon.Rd
pkg/PerformanceAnalytics/man/CAPM.jensenAlpha.Rd
pkg/PerformanceAnalytics/man/CoMoments.Rd
pkg/PerformanceAnalytics/man/DRatio.Rd
pkg/PerformanceAnalytics/man/DownsideDeviation.Rd
pkg/PerformanceAnalytics/man/DownsideFrequency.Rd
pkg/PerformanceAnalytics/man/MSquared.Rd
pkg/PerformanceAnalytics/man/MeanAbsoluteDeviation.Rd
pkg/PerformanceAnalytics/man/OmegaSharpeRatio.Rd
pkg/PerformanceAnalytics/man/PainIndex.Rd
pkg/PerformanceAnalytics/man/PainRatio.Rd
pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
pkg/PerformanceAnalytics/man/SystematicRisk.Rd
pkg/PerformanceAnalytics/man/TotalRisk.Rd
pkg/PerformanceAnalytics/man/TreynorRatio.Rd
pkg/PerformanceAnalytics/man/UpsideFrequency.Rd
pkg/PerformanceAnalytics/man/UpsideRisk.Rd
pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd
pkg/PerformanceAnalytics/man/chart.Correlation.Rd
pkg/PerformanceAnalytics/man/kurtosis.Rd
pkg/PerformanceAnalytics/man/skewness.Rd
Log:
frequency with examples and documentation + MSquaredExcess with examples and documentation + correction of all latex equations in the doc to avoid the html part to appear in the pdf + some warning corrected in R CMD check
Modified: pkg/PerformanceAnalytics/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/NAMESPACE 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/NAMESPACE 2012-07-21 16:23:23 UTC (rev 2187)
@@ -49,6 +49,7 @@
CVaR,
DrawdownPeak,
findDrawdowns,
+ Frequency,
InformationRatio,
Kappa,
KellyRatio,
@@ -60,6 +61,7 @@
mean.stderr,
mean.UCL,
MSquared,
+ MSquaredExcess,
Omega,
OmegaSharpeRatio,
# pfolioReturn,
Modified: pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -4,12 +4,11 @@
#' for skewness and kurtosis by incorporating a penalty factor for negative skewness
#' and excess kurtosis.
#'
-#' \deqn{Adjusted Sharpe Ratio = SR * [1 + (\frac{S}{6}) * SR - (\frac{K - 3}{24}) * SR^2]}
-#' {Adjusted Sharpe ratio = SR x [1 + (S/6) x SR - ((K-3) / 24) x SR^2]}
+#' \deqn{Adjusted Sharpe Ratio = SR * [1 + (\frac{S}{6}) * SR - (\frac{K - 3}{24}) * SR^2]}{Adjusted Sharpe ratio = SR x [1 + (S/6) x SR - ((K-3) / 24) x SR^2]}
#'
#' where \eqn{SR} is the sharpe ratio with data annualized, \eqn{S} is the skewness and \eqn{K} is the kurtosis
#'
-#' @aliases Adusted Sharpe ratio
+#' @aliases AdjustedSharpeRatio
#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
#' asset returns
#' @param Rf the risk free rate
Modified: pkg/PerformanceAnalytics/R/BernadoLedoitratio.R
===================================================================
--- pkg/PerformanceAnalytics/R/BernadoLedoitratio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/BernadoLedoitratio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -4,9 +4,7 @@
#' returns that are above 0 and we divide it by the opposite of the sum of
#' the subset of returns that are below 0
#'
-#' \deqn{BernardoLedoitRatio(R) = \frac{\frac{1}{n}\sum^{n}_{t=1}{max(R_{t},0)}}{\frac{1}{n}\sum^{n}_{t=1}
-#' {max(-R_{t},0)}}}{BernardoLedoitRatio(R) = 1/n*sum
-#' (t=1..n)(max(R(t),0)) / 1/n*sum(t=1..n)(max(-R(t),0))}
+#' \deqn{BernardoLedoitRatio(R) = \frac{\frac{1}{n}\sum^{n}_{t=1}{max(R_{t},0)}}{\frac{1}{n}\sum^{n}_{t=1}{max(-R_{t},0)}}}{BernardoLedoitRatio(R) = 1/n*sum(t=1..n)(max(R(t),0)) / 1/n*sum(t=1..n)(max(-R(t),0))}
#'
#' where \eqn{n} is the number of observations of the entire series
#'
Modified: pkg/PerformanceAnalytics/R/BurkeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/BurkeRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/BurkeRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -5,15 +5,13 @@
#' sum of the square of the drawdowns. To calculate the modified Burke ratio
#' we just multiply the Burke ratio by the square root of the number of datas.
#'
-#' \deqn{Burke Ratio = \frac{r_P - r_F}{\sqrt{\sum^{d}_{t=1}{D_t}^2}}}
-#' {Burke Ratio = (Rp - Rf) / (sqrt(sum(t=1..n)(Dt^2)))}
+#' \deqn{Burke Ratio = \frac{r_P - r_F}{\sqrt{\sum^{d}_{t=1}{D_t}^2}}}{Burke Ratio = (Rp - Rf) / (sqrt(sum(t=1..n)(Dt^2)))}
#'
-#' \deqn{Burke Ratio = \frac{r_P - r_F}{\sqrt{\sum^{d}_{t=1}\frac{{D_t}^2}{n}}}}
-#' {Burke Ratio = (Rp - Rf) / (sqrt(sum(t=1..n)(Dt^2 / n)))}
+#' \deqn{Modified Burke Ratio = \frac{r_P - r_F}{\sqrt{\sum^{d}_{t=1}\frac{{D_t}^2}{n}}}}{Modified Burke Ratio = (Rp - Rf) / (sqrt(sum(t=1..n)(Dt^2 / n)))}
#'
#' where \eqn{n} is the number of observations of the entire series, \eqn{d} is number of drawdowns, \eqn{r_P} is the portfolio return, \eqn{r_F} is the risk free rate and \eqn{D_t} the \eqn{t^{th}} drawdown.
#'
-#' @aliases Burke ratio
+#' @aliases BurkeRatio
#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
#' asset returns
#' @param Rf the risk free rate
Modified: pkg/PerformanceAnalytics/R/CAPM.epsilon.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.epsilon.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/CAPM.epsilon.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -3,8 +3,7 @@
#' The regression epsilon is an error term measuring the vertical distance between
#' the return predicted by the equation and the real result.
#'
-#' \deqn{\epsilon_r = r_p - \alpha_r - \beta_r * b}
-#' {epsilon_r = r_p - alpha_r - beta_r * b}
+#' \deqn{\epsilon_r = r_p - \alpha_r - \beta_r * b}{epsilon_r = r_p - alpha_r - beta_r * b}
#'
#' where \eqn{\alpha_r} is the regression alpha, \eqn{\beta_r} is the regression beta,
#' \eqn{r_p} is the portfolio return and b is the benchmark return
Modified: pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/CAPM.jensenAlpha.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -3,8 +3,7 @@
#' The Jensen's alpha is the intercept of the regression equation in the Capital
#' Asset Pricing Model and is in effect the exess return adjusted for systematic risk.
#'
-#' \deqn{\alpha = r_p - r_f - \beta_p * (b - r_f)}
-#' {alpha = r_p - r_f - beta_p * (b - r_f)}
+#' \deqn{\alpha = r_p - r_f - \beta_p * (b - r_f)}{alpha = r_p - r_f - beta_p * (b - r_f)}
#'
#' where \eqn{r_f} is the risk free rate, \eqn{\beta_r} is the regression beta,
#' \eqn{r_p} is the portfolio return and b is the benchmark return
Modified: pkg/PerformanceAnalytics/R/CoMoments.R
===================================================================
--- pkg/PerformanceAnalytics/R/CoMoments.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/CoMoments.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -181,7 +181,7 @@
#' index, benchmark, portfolio, or secondary asset returns to compare against
#' @author Kris Boudt, Peter Carl, Brian Peterson
#' @seealso \code{\link{BetaCoSkewness}} \cr \code{\link{BetaCoKurtosis}} \cr
-#' \code{\link{BetaCoMoments}} \cr % \code{\link{MultivariateMoments}}
+#' \code{\link{BetaCoMoments}}
#' @references Boudt, Kris, Brian G. Peterson, and Christophe Croux. 2008.
#' Estimation and Decomposition of Downside Risk for Portfolios with Non-Normal
#' Returns. Journal of Risk. Winter.
Modified: pkg/PerformanceAnalytics/R/DRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/DRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/DRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -9,7 +9,7 @@
#' zero and a value of infinity indicating there are no returns greater than zero.
#'
#' \deqn{DRatio(R) = \frac{n_{d}*\sum^{n}_{t=1}{max(-R_{t},0)}}{n_{u}*\sum^{n}_{t=1}
-#' {max(R_{t},0)}}}{BernadoLedoitratio(R) = nd*sum
+#' {max(R_{t},0)}}}{DRatio(R) = nd*sum
#' (t=1..n)(max(-R(t),0)) / nu*sum(t=1..n)(max(R(t),0))}
#'
#' where \eqn{n} is the number of observations of the entire series,
Modified: pkg/PerformanceAnalytics/R/DownsideDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideDeviation.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/DownsideDeviation.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -16,13 +16,11 @@
#' returns to get a below-target semi-variance.
#'
#'
-#' \deqn{ DownsideDeviation(R , MAR)= \delta_{MAR} = \sqrt{\sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]^2}{n}}{DownsideDeviation(R, MAR) = sqrt(1/n * sum(t=1..n)((min(R(t)-MAR, 0))^2))}}
+#' \deqn{DownsideDeviation(R , MAR) = \delta_{MAR} = \sqrt{\sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]^2}{n}}}{DownsideDeviation(R, MAR) = sqrt(1/n * sum(t=1..n)((min(R(t)-MAR, 0))^2))}
#'
-#' \deqn{ DownsideVariance(R, MAR) = \sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]^2} {n}}
-#' {DownsideVariance(R, MAR) = 1/n * sum(t=1..n)((min(R(t)-MAR, 0))^2)}
+#' \deqn{ DownsideVariance(R, MAR) = \sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]^2}{n}}{DownsideVariance(R, MAR) = 1/n * sum(t=1..n)((min(R(t)-MAR, 0))^2)}
#'
-#' \deqn{DownsidePotential(R, MAR) = \sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]} {n}}
-#' {DownsidePotential(R, MAR) = 1/n * sum(t=1..n)(min(R(t)-MAR, 0))}
+#' \deqn{DownsidePotential(R, MAR) = \sum^{n}_{t=1}\frac{min[(R_{t} - MAR), 0]} {n}}{DownsidePotential(R, MAR) = 1/n * sum(t=1..n)(min(R(t)-MAR, 0))}
#'
#' where \eqn{n} is either the number of observations of the entire series or
#' the number of observations in the subset of the series falling below the
Modified: pkg/PerformanceAnalytics/R/DownsideFrequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideFrequency.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/DownsideFrequency.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -5,7 +5,7 @@
#' divide the length of this subset by the total number of returns.
#'
#' \deqn{ DownsideFrequency(R , MAR) = \sum^{n}_{t=1}\frac{min[(R_{t} - MAR),
-#' 0]}{R_{t}*n}} {DownsideFrequency(R, MAR) = length(subset of returns below MAR) /
+#' 0]}{R_{t}*n}}{DownsideFrequency(R, MAR) = length(subset of returns below MAR) /
#' length(total returns)}
#'
#' where \eqn{n} is the number of observations of the entire series
Modified: pkg/PerformanceAnalytics/R/DrawdownPeak.R
===================================================================
--- pkg/PerformanceAnalytics/R/DrawdownPeak.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/DrawdownPeak.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -1,3 +1,16 @@
+#' Drawdawn peak of the return distribution
+#'
+#' Drawdawn peak is for each return its drawdown since the previous peak
+#'
+#' @aliases DrawdownPeak
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param \dots any other passthru parameters
+#' @author Matthieu Lestel
+#'
+#' @keywords ts multivariate distribution models
+#' @export
+
DrawdownPeak <- function (R, ...)
{
R0 <- R
Added: pkg/PerformanceAnalytics/R/Frequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/Frequency.R (rev 0)
+++ pkg/PerformanceAnalytics/R/Frequency.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -0,0 +1,58 @@
+#' Frequency of the return distribution
+#'
+#' Gives the period of the return distribution (ie 12 if monthly return, 4 if quarterly return)
+#'
+#' @aliases Frequency
+#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset returns
+#' @param \dots any other passthru parameters
+#' @author Matthieu Lestel
+#'
+#' @keywords ts multivariate distribution models
+#' @examples
+#' data(portfolio_bacon)
+#' print(Frequency(portfolio_bacon[,1])) #expected 12
+#' data(managers)
+#' print(Frequency(managers['1996',1:5]))
+#'
+#' @export
+
+Frequency <- function (R, ...)
+{
+ R = checkData(R)
+
+ if (ncol(R)==1 || is.null(R) || is.vector(R)) {
+
+ calcul = FALSE
+ for (i in (1:length(R))) {
+ if (!is.na(R[i])) {
+ calcul = TRUE
+ }
+ }
+
+ if (calcul) {
+ freq = periodicity(R)
+ switch(freq$scale,
+ minute = {stop("Data periodicity too high")},
+ hourly = {stop("Data periodicity too high")},
+ daily = {result = 252}, #252 trading days in any given year
+ weekly = {result = 52},
+ monthly = {result = 12},
+ quarterly = {result = 4},
+ yearly = {result = 1}
+ )
+ }
+ else
+ {
+ result = NA
+ }
+ return(result)
+ }
+ else {
+ result = apply(R, MARGIN = 2, Frequency, ...)
+ result<-t(result)
+ colnames(result) = colnames(R)
+ rownames(result) = paste("Frequency", sep="")
+ return(result)
+ }
+}
\ No newline at end of file
Modified: pkg/PerformanceAnalytics/R/MSquared.R
===================================================================
--- pkg/PerformanceAnalytics/R/MSquared.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/MSquared.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -4,8 +4,7 @@
#' performance between differents portfolios. With it you can compare portfolios
#' with different levels of risk.
#'
-#' \deqn{M^2 = r_P + SR * (\sigma_M - \sigma_P) = (r_P - r_F) * \frac{\sigma_M}{\sigma_P} + r_F}
-#' {M squared = Rp + SR * (Market risk - Portfolio risk) = (Rp - Rf) * Market risk / Portfolio risk + Rf}
+#' \deqn{M^2 = r_P + SR * (\sigma_M - \sigma_P) = (r_P - r_F) * \frac{\sigma_M}{\sigma_P} + r_F}{M squared = Rp + SR * (Market risk - Portfolio risk) = (Rp - Rf) * Market risk / Portfolio risk + Rf}
#'
#' where \eqn{r_P} is the portfolio return annualized, \eqn{\sigma_M} is the market
#' risk and \eqn{\sigma_P} is the portfolio risk
Added: pkg/PerformanceAnalytics/R/MSquaredExcess.R
===================================================================
--- pkg/PerformanceAnalytics/R/MSquaredExcess.R (rev 0)
+++ pkg/PerformanceAnalytics/R/MSquaredExcess.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -0,0 +1,71 @@
+#' M squared excess of the return distribution
+#'
+#' M squared excess is the quantity above the standard M. There is a geometric excess return which is better for Bacon and an arithmetic excess return
+#'
+#' \deqn{M^2 excess (geometric) = \frac{1 + M^2}{1 + b} - 1}{MSquared excess (geometric) = (1+M^2)/(1+b) - 1}
+#' \deqn{M^2 excess (arithmetic) = M^2 - b}{MSquared excess (arithmetic) = M^2 - b}
+#'
+#' where \eqn{M^2} is MSquared and \eqn{b} is the benchmark annualised return.
+#'
+#' @aliases MSquaredExcess
+#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' asset return
+#' @param Rb return vector of the benchmark asset
+#' @param Rf risk free rate, in same period as your returns
+#' @param Period the number of return in a year in the asset return
+#' @param Method one of "geometric" or "arithmetic" indicating the method to use
+#' to calculate MSquareExcess
+#' @param \dots any other passthru parameters
+#' @author Matthieu Lestel
+#' @references Carl Bacon, \emph{Practical portfolio performance measurement
+#' and attribution}, second edition 2008 p.68
+#'
+#' @keywords ts multivariate distribution models
+#' @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
+#'
+#' data(managers)
+#' print(MSquaredExcess(managers['1996',1], managers['1996',8]))
+#' print(MSquaredExcess(managers['1996',1:5], managers['1996',8]))
+#'
+#' @export
+MSquaredExcess <-
+function (Ra, Rb, Rf = 0, Period = 12, Method = c("geometric", "arithmetic"), ...)
+{
+ Method = Method[1]
+
+ Ra = checkData(Ra)
+ Rb = checkData(Rb)
+
+ if (ncol(Ra)==1 || is.null(Ra) || is.vector(Ra)) {
+ calcul = FALSE
+ for (i in (1:length(Ra))) {
+ if (!is.na(Ra[i])) {
+ calcul = TRUE
+ }
+ }
+
+ if (calcul) {
+ Rbp = Return.annualized(Rb)
+
+ switch(Method,
+ geometric = {result = (1+MSquared(Ra,Rb))/(1+Rbp) - 1},
+ arithmetic = {result = MSquared(Ra,Rb) - Rbp}
+ ) # end switch
+ }
+ else {
+ result = NA
+ }
+ return(result)
+ }
+ else {
+ result = apply(Ra, MARGIN = 2, MSquaredExcess, Rb = Rb, Rf = Rf, Period = Period, Method = Method, ...)
+ result<-t(result)
+ colnames(result) = colnames(Ra)
+ rownames(result) = paste("MSquaredExcess (Risk free = ",Rf,")", sep="")
+ return(result)
+ }
+}
Modified: pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -2,8 +2,7 @@
#'
#' To calculate Mean absolute deviation we take the sum of the absolute value of the difference between the returns and the mean of the returns and we divide it by the number of returns.
#'
-#' \deqn{MeanAbsoluteDeviation = \frac{\sum^{n}_{i=1}\mid r_i - \overline{r}\mid}{n}}
-#' {MeanAbsoluteDeviation = sum(|r-mean(r)|)/n }
+#' \deqn{MeanAbsoluteDeviation = \frac{\sum^{n}_{i=1}\mid r_i - \overline{r}\mid}{n}}{MeanAbsoluteDeviation = sum(|r-mean(r)|)/n }
#'
#' where \eqn{n} is the number of observations of the entire series, \eqn{r_i} is the
#' return in month i and \eqn{\overline{r}} is the mean return
Modified: pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -7,8 +7,7 @@
#' Acceptable Returns (MAR)) return from the portfolio return and we divide
#' it by the opposite of the Downside Deviation.
#'
-#' \deqn{OmegaSharpeRatio(R,MAR) = \frac{r_p - r_t}{\sum^n_{t=1}\frac{max(r_t - r_i, 0)}{n}}}
-#' {OmegaSharpeRatio(R,MAR) = (Rp - Rt) / -DownsidePotential(R,MAR)}
+#' \deqn{OmegaSharpeRatio(R,MAR) = \frac{r_p - r_t}{\sum^n_{t=1}\frac{max(r_t - r_i, 0)}{n}}}{OmegaSharpeRatio(R,MAR) = (Rp - Rt) / -DownsidePotential(R,MAR)}
#'
#' where \eqn{n} is the number of observations of the entire series
#'
@@ -17,9 +16,6 @@
#' asset returns
#' @param MAR Minimum Acceptable Return, in the same periodicity as your
#' returns
-#' @param method one of "full" or "subset", indicating whether to use the
-#' length of the full series or the length of the subset of the series below
-#' the MAR as the denominator, defaults to "subset"
#' @param \dots any other passthru parameters
#' @author Matthieu Lestel
#' @references Carl Bacon, \emph{Practical portfolio performance measurement
Modified: pkg/PerformanceAnalytics/R/PainIndex.R
===================================================================
--- pkg/PerformanceAnalytics/R/PainIndex.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/PainIndex.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -10,8 +10,7 @@
#' the horizontal line at zero percent and the drawdown line in the
#' Drawdown chart.
#'
-#' \deqn{Pain index = \sum^{n}_{i=1} \frac{\mid D'_i \mid}{n}}
-#' {Pain index = sum(|D'i|/n)}
+#' \deqn{Pain index = \sum^{n}_{i=1} \frac{\mid D'_i \mid}{n}}{Pain index = sum(|D'i|/n)}
#'
#' where \eqn{n} is the number of observations of the entire series, \eqn{D'_i} is
#' the drawdown since previous peak in period i
Modified: pkg/PerformanceAnalytics/R/PainRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/PainRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/PainRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -3,8 +3,7 @@
#' To calculate Pain ratio we divide the difference of the portfolio return
#' and the risk free rate by the Pain index
#'
-#' \deqn{Pain ratio = \frac{r_P - r_F}{\sum^{n}_{i=1} \frac{\mid D'_i \mid}{n}}}
-#' {Pain ratio = (rp - rf) / Pain index}
+#' \deqn{Pain ratio = \frac{r_P - r_F}{\sum^{n}_{i=1} \frac{\mid D'_i \mid}{n}}}{Pain ratio = (rp - rf) / Pain index}
#'
#' where \eqn{r_P} is the annualized portfolio return, \eqn{r_F} is the risk free
#' rate, \eqn{n} is the number of observations of the entire series, \eqn{D'_i} is
Modified: pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -5,12 +5,11 @@
#' It is used in conjunction with the Sharpe ratio to rank portfolios.
#' The higher the rate the better.
#'
-#' \deqn{ SkewnessKurtosisRatio(R , MAR) = \frac{S}{K}}
-#' {SkewnessKurtosisRatio(R, MAR) = S/K}
+#' \deqn{ SkewnessKurtosisRatio(R , MAR) = \frac{S}{K}}{SkewnessKurtosisRatio(R, MAR) = S/K}
#'
#' where \eqn{S} is the skewness and \eqn{K} is the Kurtosis
#'
-#' @aliases Skewness-Kurtosis ratio
+#' @aliases Skewness-KurtosisRatio
#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of
#' asset returns
#' @param \dots any other passthru parameters
Modified: pkg/PerformanceAnalytics/R/SystematicRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/SystematicRisk.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/SystematicRisk.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -5,8 +5,7 @@
#' Jensen. Market risk is the standard deviation of the benchmark. The systematic
#' risk is annualized
#'
-#' \deqn{\sigma_s = \beta * \sigma_m}
-#' {systematic risk = beta * market risk}
+#' \deqn{\sigma_s = \beta * \sigma_m}{systematic risk = beta * market risk}
#'
#' where \eqn{\sigma_s} is the systematic risk, \eqn{\beta} is the regression beta,
#' and \eqn{\sigma_m} is the market risk
Modified: pkg/PerformanceAnalytics/R/TotalRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/TotalRisk.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/TotalRisk.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -4,8 +4,7 @@
#' of specific risk. Specific risk is the standard deviation of the error term in the
#' regression equation. Both terms are annualized to calculate total risk.
#'
-#' \deqn{Total Risk = \sqrt{Systematic Risk^2 + Specific Risk^2}}
-#' {Total Risk^2 = Systematic Risk^2 + Specific Risk^2}
+#' \deqn{Total Risk = \sqrt{Systematic Risk^2 + Specific Risk^2}}{Total Risk^2 = Systematic Risk^2 + Specific Risk^2}
#'
#' @aliases TotalRisk
#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
Modified: pkg/PerformanceAnalytics/R/TreynorRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/TreynorRatio.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/TreynorRatio.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -8,8 +8,7 @@
#'
#' Equation:
#' \deqn{TreynorRatio = \frac{\overline{(R_{a}-R_{f})}}{\beta_{a,b}}}{(mean(Ra-Rf))/(Beta(Ra,Rb))}
-#' \deqn{ModifiedTreynorRatio = \frac{r_p - r_f}{\sigma_s}}
-#' {ModifiedTreynorRatio = (Rp - Rf)/sytematic risk}
+#' \deqn{ModifiedTreynorRatio = \frac{r_p - r_f}{\sigma_s}}{ModifiedTreynorRatio = (Rp - Rf)/sytematic risk}
#'
#' @aliases TreynorRatio
#' @param Ra an xts, vector, matrix, data frame, timeSeries or zoo object of
Modified: pkg/PerformanceAnalytics/R/UpsideFrequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideFrequency.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/UpsideFrequency.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -5,7 +5,7 @@
#' divide the length of this subset by the total number of returns.
#'
#' \deqn{ UpsideFrequency(R , MAR) = \sum^{n}_{t=1}\frac{max[(R_{t} - MAR),
-#' 0]}{R_{t}*n}} {UpsideFrequency(R, MAR) = length(subset of returns above MAR) /
+#' 0]}{R_{t}*n}}{UpsideFrequency(R, MAR) = length(subset of returns above MAR) /
#' length(total returns)}
#'
#' where \eqn{n} is the number of observations of the entire series
Modified: pkg/PerformanceAnalytics/R/UpsideRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideRisk.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/UpsideRisk.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -9,14 +9,12 @@
#' returns and return the square root.
#'
#' \deqn{ UpsideRisk(R , MAR) = \sqrt{\sum^{n}_{t=1}\frac{
-#' max[(R_{t} - MAR), 0]^2}{n}}} {UpsideRisk(R, MAR) = sqrt(1/n * sum(t=1..n)
+#' max[(R_{t} - MAR), 0]^2}{n}}}{UpsideRisk(R, MAR) = sqrt(1/n * sum(t=1..n)
#' ((max(R(t)-MAR, 0))^2))}
#'
-#' \deqn{ UpsideVariance(R, MAR) = \sum^{n}_{t=1}\frac{max[(R_{t} - MAR), 0]^2} {n}}
-#' {UpsideVariance(R, MAR) = 1/n * sum(t=1..n)((max(R(t)-MAR, 0))^2)}
+#' \deqn{ UpsideVariance(R, MAR) = \sum^{n}_{t=1}\frac{max[(R_{t} - MAR), 0]^2} {n}}{UpsideVariance(R, MAR) = 1/n * sum(t=1..n)((max(R(t)-MAR, 0))^2)}
#'
-#' \deqn{UpsidePotential(R, MAR) = \sum^{n}_{t=1}\frac{max[(R_{t} - MAR), 0]} {n}}
-#' {DownsidePotential(R, MAR) = 1/n * sum(t=1..n)(max(R(t)-MAR, 0))}
+#' \deqn{UpsidePotential(R, MAR) = \sum^{n}_{t=1}\frac{max[(R_{t} - MAR), 0]} {n}}{DownsidePotential(R, MAR) = 1/n * sum(t=1..n)(max(R(t)-MAR, 0))}
#'
#' where \eqn{n} is either the number of observations of the entire series or
#' the number of observations in the subset of the series falling below the
@@ -30,7 +28,7 @@
#' @param method one of "full" or "subset", indicating whether to use the
#' length of the full series or the length of the subset of the series below
#' the MAR as the denominator, defaults to "full"
-#' @param method one of "risk", "variance" or "potential" indicating whether
+#' @param stat one of "risk", "variance" or "potential" indicating whether
#' to return the Upside risk, variance or potential
#' @param \dots any other passthru parameters
#' @author Matthieu Lestel
Modified: pkg/PerformanceAnalytics/R/VolatilitySkewness.R
===================================================================
--- pkg/PerformanceAnalytics/R/VolatilitySkewness.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/VolatilitySkewness.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -5,11 +5,9 @@
#' downside variance. Variability skewness is the ratio of the upside risk
#' compared to the downside risk.
#'
-#' \deqn{ VolatilitySkewness(R , MAR) = \frac{\sigma_U^2}{\sigma_D^2}}
-#' {VolatilitySkewness(R, MAR) = UpsideVariance / DownsideVariance}
+#' \deqn{ VolatilitySkewness(R , MAR) = \frac{\sigma_U^2}{\sigma_D^2}}{VolatilitySkewness(R, MAR) = UpsideVariance / DownsideVariance}
#'
-#' \deqn{ VariabilitySkewness(R , MAR) = \frac{\sigma_U}{\sigma_D}}
-#' {VariabilitySkewness(R, MAR) = UpsideRisk / DownsideRisk}
+#' \deqn{ VariabilitySkewness(R , MAR) = \frac{\sigma_U}{\sigma_D}}{VariabilitySkewness(R, MAR) = UpsideRisk / DownsideRisk}
#'
#' where \eqn{\sigma_U} is the Upside risk and \eqn{\sigma_D} is the Downside Risk
#'
@@ -18,7 +16,7 @@
#' asset returns
#' @param MAR Minimum Acceptable Return, in the same periodicity as your
#' returns
-#' @param method one of "volatility", "variability" indicating whether
+#' @param stat one of "volatility", "variability" indicating whether
#' to return the volatility skewness or the variability skweness
#' @param \dots any other passthru parameters
#' @author Matthieu Lestel
Modified: pkg/PerformanceAnalytics/R/chart.Correlation.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.Correlation.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/chart.Correlation.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -11,8 +11,7 @@
#' @note based on plot at
#' \url{http://addictedtor.free.fr/graphiques/sources/source_137.R}
#' @author Peter Carl
-#' @seealso \code{\link{table.Correlation}} \cr %
-#' \code{\link{chart.Correlation.color}}
+#' @seealso \code{\link{table.Correlation}}
#' @keywords ts multivariate distribution models hplot
#' @examples
#'
Modified: pkg/PerformanceAnalytics/R/kurtosis.R
===================================================================
--- pkg/PerformanceAnalytics/R/kurtosis.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/kurtosis.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -6,16 +6,11 @@
#' dependency on fUtilties being loaded every time. This function is identical
#' except for the addition of \code{\link{checkData}} and additional labeling.
#'
-#' \deqn{Kurtosis(moment) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^4}
-#' {kurtosis(moment) = sum((x-mean(x))^4/var(x)^2)/length(x)}
-#' \deqn{Kurtosis(excess) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^4 - 3}
-#' {kurtosis(excess) = sum((x-mean(x))^4/var(x)^2)/length(x) - 3}
-#' \deqn{Kurtosis(sample) = \frac{n*(n+1)}{(n-1)*(n-2)*(n-3)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^4 }
-#' {kurtosis(sample) = sum(((x-mean(x))/var(x))^4)*n*(n+1)/((n-1)*(n-2)*(n-3))}
-#' \deqn{Kurtosis(fisher) = \frac{(n+1)*(n-1)}{(n-2)*(n-3)}*(\frac{\sum^{n}_{i=1}\frac{(r_i)^4}{n}}{(\sum^{n}_{i=1}(\frac{(r_i)^2}{n})^2} - \frac{3*(n-1)}{n+1})}
-#' {kurtosis (fisher) = ((n+1)*(n-1)*((sum(x^4)/n)/(sum(x^2)/n)^2 - (3*(n-1))/(n+1)))/((n-2)*(n-3))}
-#' \deqn{Kurtosis(sample excess) = \frac{n*(n+1)}{(n-1)*(n-2)*(n-3)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^4 - \frac{3*(n-1)^2}{(n-2)*(n-3)}}
-#' {kurtosis(sample excess) = sum(((x-mean(x))/var(x))^4)*n*(n+1)/((n-1)*(n-2)*(n-3)) - 3*(n-1)^2/((n-2)*(n-3))}
+#' \deqn{Kurtosis(moment) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^4}{kurtosis(moment) = sum((x-mean(x))^4/var(x)^2)/length(x)}
+#' \deqn{Kurtosis(excess) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^4 - 3}{kurtosis(excess) = sum((x-mean(x))^4/var(x)^2)/length(x) - 3}
+#' \deqn{Kurtosis(sample) = \frac{n*(n+1)}{(n-1)*(n-2)*(n-3)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^4 }{kurtosis(sample) = sum(((x-mean(x))/var(x))^4)*n*(n+1)/((n-1)*(n-2)*(n-3))}
+#' \deqn{Kurtosis(fisher) = \frac{(n+1)*(n-1)}{(n-2)*(n-3)}*(\frac{\sum^{n}_{i=1}\frac{(r_i)^4}{n}}{(\sum^{n}_{i=1}(\frac{(r_i)^2}{n})^2} - \frac{3*(n-1)}{n+1})}{kurtosis (fisher) = ((n+1)*(n-1)*((sum(x^4)/n)/(sum(x^2)/n)^2 - (3*(n-1))/(n+1)))/((n-2)*(n-3))}
+#' \deqn{Kurtosis(sample excess) = \frac{n*(n+1)}{(n-1)*(n-2)*(n-3)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^4 - \frac{3*(n-1)^2}{(n-2)*(n-3)}}{kurtosis(sample excess) = sum(((x-mean(x))/var(x))^4)*n*(n+1)/((n-1)*(n-2)*(n-3)) - 3*(n-1)^2/((n-2)*(n-3))}
#'
#'
#' where \eqn{n} is the number of return, \eqn{\overline{r}} is the mean of the return
Modified: pkg/PerformanceAnalytics/R/skewness.R
===================================================================
--- pkg/PerformanceAnalytics/R/skewness.R 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/R/skewness.R 2012-07-21 16:23:23 UTC (rev 2187)
@@ -6,12 +6,9 @@
#' dependency on fUtiltiies being loaded every time. The function is identical
#' except for the addition of \code{\link{checkData} and column support.}
#'
-#' \deqn{Skewness(moment) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^3}
-#' {Skewness(moment) = sum((x-mean(x))^3/var(x)^(3/2))/length(x)}
-#' \deqn{Skewness(sample) = \frac{n}{(n-1)*(n-2)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^3 }
-#' {skewness(sample) = sum(((x-mean(x))/var(x))^3)*n/((n-1)*(n-2))}
-#' \deqn{Skewness(fisher) = \frac{\frac{\sqrt{n*(n-1)}}{n-2}*\sum^{n}_{i=1}\frac{x^3}{n}}{\sum^{n}_{i=1}(\frac{x^2}{n})^{3/2}}}
-#' {Skewness(fisher)((sqrt(n*(n-1))/(n-2))*(sum(x^3)/n))/((sum(x^2)/n)^(3/2))}
+#' \deqn{Skewness(moment) = \frac{1}{n}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_P})^3}{Skewness(moment) = sum((x-mean(x))^3/var(x)^(3/2))/length(x)}
+#' \deqn{Skewness(sample) = \frac{n}{(n-1)*(n-2)}*\sum^{n}_{i=1}(\frac{r_i - \overline{r}}{\sigma_{S_P}})^3 }{skewness(sample) = sum(((x-mean(x))/var(x))^3)*n/((n-1)*(n-2))}
+#' \deqn{Skewness(fisher) = \frac{\frac{\sqrt{n*(n-1)}}{n-2}*\sum^{n}_{i=1}\frac{x^3}{n}}{\sum^{n}_{i=1}(\frac{x^2}{n})^{3/2}}}{Skewness(fisher)((sqrt(n*(n-1))/(n-2))*(sum(x^3)/n))/((sum(x^2)/n)^(3/2))}
#'
#' where \eqn{n} is the number of return, \eqn{\overline{r}} is the mean of the return
#' distribution, \eqn{\sigma_P} is its standard deviation and \eqn{\sigma_{S_P}} is its
Modified: pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd 2012-07-21 16:23:23 UTC (rev 2187)
@@ -1,8 +1,5 @@
\name{AdjustedSharpeRatio}
\alias{AdjustedSharpeRatio}
-\alias{Adusted}
-\alias{ratio}
-\alias{Sharpe}
\title{Adjusted Sharpe ratio of the return distribution}
\usage{
AdjustedSharpeRatio(R, Rf = 0, period = 12, ...)
@@ -26,7 +23,7 @@
}
\details{
\deqn{Adjusted Sharpe Ratio = SR * [1 + (\frac{S}{6}) *
- SR - (\frac{K - 3}{24}) * SR^2]} {Adjusted Sharpe ratio =
+ SR - (\frac{K - 3}{24}) * SR^2]}{Adjusted Sharpe ratio =
SR x [1 + (S/6) x SR - ((K-3) / 24) x SR^2]}
where \eqn{SR} is the sharpe ratio with data annualized,
Modified: pkg/PerformanceAnalytics/man/BurkeRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/BurkeRatio.Rd 2012-07-20 22:13:32 UTC (rev 2186)
+++ pkg/PerformanceAnalytics/man/BurkeRatio.Rd 2012-07-21 16:23:23 UTC (rev 2187)
@@ -1,7 +1,5 @@
\name{BurkeRatio}
-\alias{Burke}
\alias{BurkeRatio}
-\alias{ratio}
\title{Burke ratio of the return distribution}
\usage{
BurkeRatio(R, Rf = 0, modified = FALSE, period = 12, ...)
@@ -30,12 +28,12 @@
}
\details{
\deqn{Burke Ratio = \frac{r_P -
- r_F}{\sqrt{\sum^{d}_{t=1}{D_t}^2}}} {Burke Ratio = (Rp -
+ r_F}{\sqrt{\sum^{d}_{t=1}{D_t}^2}}}{Burke Ratio = (Rp -
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/returnanalytics -r 2187
More information about the Returnanalytics-commits
mailing list