[Returnanalytics-commits] r2175 - in pkg/PerformanceAnalytics: . R data man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 18 17:43:15 CEST 2012
Author: matthieu_lestel
Date: 2012-07-18 17:43:15 +0200 (Wed, 18 Jul 2012)
New Revision: 2175
Removed:
pkg/PerformanceAnalytics/man/BernardoLedoitratio.Rd
Modified:
pkg/PerformanceAnalytics/NAMESPACE
pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
pkg/PerformanceAnalytics/R/BernadoLedoitratio.R
pkg/PerformanceAnalytics/R/DownsideDeviation.R
pkg/PerformanceAnalytics/R/ES.R
pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R
pkg/PerformanceAnalytics/R/PainIndex.R
pkg/PerformanceAnalytics/R/PainRatio.R
pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
pkg/PerformanceAnalytics/R/TreynorRatio.R
pkg/PerformanceAnalytics/R/UpsideRisk.R
pkg/PerformanceAnalytics/R/VolatilitySkewness.R
pkg/PerformanceAnalytics/R/chart.RollingRegression.R
pkg/PerformanceAnalytics/data/portfolio_bacon.csv
pkg/PerformanceAnalytics/data/portfolio_bacon.rda
pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd
pkg/PerformanceAnalytics/man/ES.Rd
pkg/PerformanceAnalytics/man/MeanAbsoluteDeviation.Rd
pkg/PerformanceAnalytics/man/PainIndex.Rd
pkg/PerformanceAnalytics/man/PainRatio.Rd
pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd
pkg/PerformanceAnalytics/man/chart.RollingRegression.Rd
Log:
Rcheck pass + some other minor modifications
Modified: pkg/PerformanceAnalytics/NAMESPACE
===================================================================
--- pkg/PerformanceAnalytics/NAMESPACE 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/NAMESPACE 2012-07-18 15:43:15 UTC (rev 2175)
@@ -1,133 +1,441 @@
-export(ActivePremium)
-export(AdjustedSharpeRatio)
-export(apply.fromstart)
-export(apply.rolling)
-export(AverageDrawdown)
-export(AverageRecovery)
-export(BernardoLedoitratio)
-export(BetaCoKurtosis)
-export(BetaCoSkewness)
-export(BetaCoVariance)
-export(BurkeRatio)
-export(CalculateReturns)
-export(CalmarRatio)
-export(CAPM.alpha)
-export(CAPM.beta)
-export(CAPM.beta.bear)
-export(CAPM.beta.bull)
-export(CAPM.CML)
-export(CAPM.CML.slope)
-export(CAPM.epsilon)
-export(CAPM.jensenAlpha)
-export(CAPM.RiskPremium)
-export(CAPM.SML.slope)
-export(CDD)
-export(centeredcomoment)
-export(centeredmoment)
-export(chart.ACF)
-export(chart.ACFplus)
-export(chart.Bar)
-export(chart.BarVaR)
-export(chart.Boxplot)
-export(chart.CaptureRatios)
-export(chart.Correlation)
-export(chart.CumReturns)
-export(chart.Drawdown)
-export(chart.ECDF)
-export(chart.Events)
-export(chart.Histogram)
-export(chart.QQPlot)
-export(chart.Regression)
-export(chart.RelativePerformance)
-export(chart.RiskReturnScatter)
-export(chart.RollingCorrelation)
-export(chart.RollingMean)
-export(chart.RollingPerformance)
-export(chart.RollingQuantileRegression)
-export(chart.RollingRegression)
-export(charts.Bar)
-export(charts.BarVaR)
-export(chart.Scatter)
-export(chart.SnailTrail)
-export(charts.PerformanceSummary)
-export(charts.RollingPerformance)
-export(charts.RollingRegression)
-export(chart.StackedBar)
-export(charts.TimeSeries)
-export(chart.TimeSeries)
-export(chart.VaRSensitivity)
-export(checkData)
-export(clean.boudt)
-export(CoKurtosis)
-export(CoSkewness)
-export(CoVariance)
-export(DownsideDeviation)
-export(DownsideFrequency)
-export(DRatio)
-export(DrawdownDeviation)
-export(ETL)
-export(findDrawdowns)
-export(InformationRatio)
-export(Kappa)
-export(KellyRatio)
-export(kurtosis)
-export(legend)
-export(maxDrawdown)
-export(MeanAbsoluteDeviation)
-export(mean.geometric)
-export(mean.LCL)
-export(mean.stderr)
-export(mean.UCL)
-export(Omega)
-export(OmegaSharpeRatio)
-export(PainIndex)
-export(PainRatio)
-export(Return.annualized)
-export(Return.calculate)
-export(Return.centered)
-export(Return.clean)
-export(Return.cumulative)
-export(Return.excess)
-export(Return.Geltner)
-export(Return.portfolio)
-export(Return.read)
-export(Return.rebalancing)
-export(Return.relative)
-export(SemiDeviation)
-export(SemiVariance)
-export(SharpeRatio)
-export(SharpeRatio.annualized)
-export(SharpeRatio.modified)
-export(skewness)
-export(SkewnessKurtosisRatio)
-export(SmoothingIndex)
-export(sortDrawdowns)
-export(SortinoRatio)
-export(StdDev)
-export(StdDev.annualized)
-export(SterlingRatio)
-export(SystematicRisk)
-export(table.AnnualizedReturns)
-export(table.Arbitrary)
-export(table.Autocorrelation)
-export(table.CalendarReturns)
-export(table.CAPM)
-export(table.CaptureRatios)
-export(table.Correlation)
-export(table.DownsideRisk)
-export(table.Drawdowns)
-export(table.HigherMoments)
-export(table.Stats)
-export(table.TrailingPeriods)
-export(textplot)
-export(TimingRatio)
-export(TotalRisk)
-export(TrackingError)
-export(TreynorRatio)
-export(UlcerIndex)
-export(UpDownRatios)
-export(UpsideFrequency)
-export(UpsidePotentialRatio)
-export(UpsideRisk)
-export(VaR)
-export(VolatilitySkewness)
+# NAMESPACE file for PerformanceAnalytics
+
+importFrom("utils", "packageDescription")
+importFrom("stats", "sd")
+
+importFrom("zoo", "rollapply")
+
+# export all functions/variables that don't start with a .
+# exportPattern("^[^\\.]")
+
+
+export(
+ ActivePremium,
+ AdjustedSharpeRatio,
+ apply.fromstart,
+ apply.rolling,
+ BernardoLedoitRatio,
+ BetaCoKurtosis,
+ BetaCoSkewness,
+ BetaCoVariance,
+ BurkeRatio,
+ CalculateReturns,
+ CalmarRatio,
+ CAPM.alpha,
+ CAPM.beta,
+ CAPM.beta.bear,
+ CAPM.beta.bull,
+ CAPM.CML,
+ CAPM.CML.slope,
+ CAPM.epsilon,
+ CAPM.jensenAlpha,
+ CAPM.RiskPremium,
+ CAPM.SML.slope,
+ CDD,
+ checkData,
+ clean.boudt,
+ CoKurtosis,
+# CoKurtosisMatrix, #export after co-moments paper is done
+ CoSkewness,
+# CoSkewnessMatrix, #export after co-moments paper is done
+ CoVariance,
+ DownsideDeviation,
+ DownsideFrequency,
+ DownsidePotential,
+ DRatio,
+ Drawdowns,
+ ES,
+ ETL,
+ CVaR,
+ DrawdownPeak,
+ findDrawdowns,
+ InformationRatio,
+ Kappa,
+ KellyRatio,
+ kurtosis,
+ maxDrawdown,
+ MeanAbsoluteDeviation,
+ mean.geometric,
+ mean.LCL,
+ mean.stderr,
+ mean.UCL,
+ Omega,
+ OmegaSharpeRatio,
+# pfolioReturn,
+ PainIndex,
+ PainRatio,
+ Return.annualized,
+ Return.calculate,
+ Return.centered,
+ Return.clean,
+ Return.cumulative,
+ Return.excess,
+ Return.Geltner,
+ Return.portfolio,
+ Return.rebalancing,
+ Return.read,
+ Return.relative,
+ sd.annualized,
+ sd.multiperiod,
+ SemiDeviation,
+ SemiVariance,
+ SharpeRatio,
+ SharpeRatio.annualized,
+ SharpeRatio.modified,
+ skewness,
+ SkewnessKurtosisRatio,
+ SmoothingIndex,
+ sortDrawdowns,
+ SortinoRatio,
+ StdDev,
+ StdDev.annualized,
+ SterlingRatio,
+ SystematicRisk,
+# style.fit,
+# style.QPfit,
+ TimingRatio,
+ TotalRisk,
+ TrackingError,
+ TreynorRatio,
+ UpDownRatios,
+ UPR,
+ UpsideFrequency,
+ UpsidePotentialRatio,
+ UpsideRisk,
+ VaR,
+ VolatilitySkewness
+)
+
+## Tables
+export(
+ table.AnnualizedReturns,
+ table.Arbitrary,
+ table.Autocorrelation,
+ table.CalendarReturns,
+ table.CAPM,
+ table.CaptureRatios,
+ table.Correlation,
+ table.DownsideRisk,
+ table.Drawdowns,
+ table.HigherMoments,
+ table.Returns,
+ table.Stats,
+ table.TrailingPeriods,
+ table.TrailingPeriodsRel,
+ table.UpDownRatios
+)
+
+## Charts
+export(
+ chart.ACF,
+ chart.ACFplus,
+ chart.Bar,
+ charts.Bar,
+ chart.BarVaR,
+ charts.BarVaR,
+ chart.Boxplot,
+ chart.CaptureRatios,
+ chart.Correlation,
+# chart.Correlation.color,
+ chart.CumReturns,
+ chart.Drawdown,
+ chart.ECDF,
+ chart.Events,
+ chart.Histogram,
+ chart.QQPlot,
+ chart.Regression,
+ chart.RelativePerformance,
+ chart.RiskReturnScatter,
+ chart.RollingCorrelation,
+ chart.RollingMean,
+ chart.RollingPerformance,
+ chart.RollingRegression,
+ chart.RollingQuantileRegression,
+# chart.RollingStyle,
+ chart.Scatter,
+ chart.SnailTrail,
+ charts.PerformanceSummary,
+ charts.RollingPerformance,
+ charts.RollingRegression,
+ chart.StackedBar,
+# chart.Style,
+ chart.TimeSeries,
+ chart.VaRSensitivity,
+ textplot
+)
+
+export(
+ allsymbols,
+ bluefocus,
+ bluemono,
+ bond.dates,
+ bond.labels,
+ closedsymbols,
+ cycles.dates,
+ dark6equal,
+ dark8equal,
+ equity.dates,
+ equity.labels,
+ fillsymbols,
+ greenfocus,
+ greenmono,
+ grey6mono,
+ grey8mono,
+ legend,
+ linesymbols,
+ macro.dates,
+ macro.labels,
+ opensymbols,
+ rainbow10equal,
+ rainbow12equal,
+ rainbow6equal,
+ rainbow8equal,
+ redfocus,
+ redmono,
+ rich10equal,
+ rich12equal,
+ rich6equal,
+ rich8equal,
+ risk.dates,
+ risk.labels,
+ set6equal,
+ set8equal,
+ tim10equal,
+ tim12equal,
+ tim6equal,
+ tim8equal
+)
+
+S3method(textplot, default)
+S3method(textplot, character)
+S3method(textplot, data.frame)
+S3method(textplot, matrix)
+
+S3method(mean,xts)
+S3method(sd,xts)
+#S3method(mean,matrix)
+S3method(sd,matrix)
+
+S3method(rollapply,xts)
+
+# # Export These
+# ActivePremium
+# apply.fromstart
+# apply.rolling
+# BetaCoKurtosis
+# BetaCoSkewness
+# BetaCoVariance
+# CalculateReturns
+# CalmarRatio
+# CAPM.alpha
+# CAPM.beta
+# CAPM.beta.bear
+# CAPM.beta.bull
+# CAPM.CML
+# CAPM.CML.slope
+# CAPM.RiskPremium
+# CAPM.SML.slope
+# chart.ACF
+# chart.ACFplus
+# chart.Bar
+# chart.BarVaR
+# chart.Boxplot
+# chart.CaptureRatios
+# chart.Correlation
+# chart.Correlation.color
+# chart.CumReturns
+# chart.Drawdown
+# chart.ECDF
+# chart.Histogram
+# chart.QQPlot
+# chart.Regression
+# chart.RelativePerformance
+# chart.RiskReturnScatter
+# chart.RollingCorrelation
+# chart.RollingMean
+# chart.RollingPerformance
+# chart.RollingRegression
+# chart.RollingStyle
+# chart.Scatter
+# chart.SnailTrail
+# charts.PerformanceSummary
+# charts.RollingPerformance
+# charts.RollingRegression
+# chart.StackedBar
+# chart.Style
+# chart.TimeSeries
+# chart.VaRSensitivity
+# checkData
+# clean.boudt
+# CoKurtosis
+# CoKurtosisMatrix
+# CoSkewness
+# CoSkewnessMatrix
+# CoVariance
+# DownsideDeviation
+# Drawdowns
+# ES
+# findDrawdowns
+# InformationRatio
+# KellyRatio
+# kurtosis
+# maxDrawdown
+# mean.geometric
+# mean.LCL
+# mean.stderr
+# mean.UCL
+# modifiedVaR
+# modSharpe
+# multivariate_mean
+# Omega
+# pfolioReturn
+# Return.annualized
+# Return.calculate
+# Return.centered
+# Return.clean
+# Return.cumulative
+# Return.excess
+# Return.Geltner
+# Return.portfolio
+# Return.portfolio.multiweight
+# Return.read
+# Return.relative
+# sd.annualized
+# sd.multiperiod
+# SemiDeviation
+# SemiVariance
+# SharpeRatio
+# SharpeRatio.annualized
+# SharpeRatio.modified
+# skewness
+# SmoothingIndex
+# sortDrawdowns
+# SortinoRatio
+# SterlingRatio
+# style.fit
+# style.QPfit
+# table.AnnualizedReturns
+# table.Arbitrary
+# table.Autocorrelation
+# table.CalendarReturns
+# table.CAPM
+# table.CaptureRatios
+# table.Correlation
+# table.DownsideRisk
+# table.Drawdowns
+# table.HigherMoments
+# table.MonthlyReturns
+# table.Returns
+# table.UpDownRatios
+# textplot
+# TimingRatio
+# TrackingError
+# TreynorRatio
+# UpDownRatios
+# UPR
+# UpsidePotentialRatio
+# VaR
+
+# # graphics stuff to export
+# allsymbols
+# bluefocus
+# bluemono
+# bond.dates
+# bond.labels
+# closedsymbols
+# cycles.dates
+# dark6equal
+# dark8equal
+# equity.dates
+# equity.labels
+# fillsymbols
+# greenfocus
+# greenmono
+# grey6mono
+# grey8mono
+# legend
+# linesymbols
+# macro.dates
+# macro.labels
+# opensymbols
+# rainbow10equal
+# rainbow12equal
+# rainbow6equal
+# rainbow8equal
+# redfocus
+# redmono
+# rich10equal
+# rich12equal
+# rich6equal
+# rich8equal
+# risk.dates
+# risk.labels
+# set6equal
+# set8equal
+# tim10equal
+# tim12equal
+# tim6equal
+# tim8equal
+
+# # internal/obsolete functions, do not export
+# centeredcomoment
+# centeredmoment
+# checkDataMatrix
+# checkDataVector
+# checkDataZoo
+# derIpower
+# derportm2
+# derportm3
+# derportm4
+# download.RiskFree
+# download.SP500PriceReturns
+# ES.CornishFisher
+# ES.CornishFisher.portfolio
+# ES.Gaussian
+# ES.Gaussian.portfolio
+# ES.historical.portfolio
+# GES.MM
+# GVaR.MM
+# Ipower
+# kernel
+# kurtosis.MM
+# mES.MM
+# modifiedVaR
+# multivariate_mean
+# mVaR.MM
+# M3.MM
+# M4.MM
+# portm2
+# portm3
+# portm4
+# Portmean
+# Portsd
+# precision
+# pvalJB
+# operES.CornishFisher
+# operES.CornishFisher.portfolio
+# skewness.MM
+# SR.GES.MM
+# SR.GVaR.MM
+# SR.mES.MM
+# SR.mVaR.MM
+# SR.StdDev.MM
+# statsTable
+# std
+# StdDev.annualized
+# StdDev.MM
+# textplot.character
+# textplot.data.frame
+# textplot.default
+# textplot.matrix
+# timing.ratio
+# VaR.Beyond
+# VaR.CornishFisher
+# VaR.CornishFisher.portfolio
+# VaR.Gaussian
+# VaR.Gaussian.portfolio
+# VaR.historical.portfolio
+# VaR.kernel.portfolio
+# VaR.Marginal
+# VaR.mean
+# VaR.traditional
Modified: pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -22,11 +22,11 @@
#' @keywords ts multivariate distribution models
#' @examples
#' data(portfolio_bacon)
-#' print(AdustedSharpeRatio(portfolio_bacon[,1])) #expected 0.813
+#' print(AdjustedSharpeRatio(portfolio_bacon[,1])) #expected 0.813
#'
#' data(managers)
-#' print(AdustedSharpeRatio(managers['1996']))
-#' print(AdustedSharpeRatio(managers['1996',1]))
+#' print(AdjustedSharpeRatio(managers['1996']))
+#' print(AdjustedSharpeRatio(managers['1996',1]))
#'
#' @export
@@ -38,7 +38,7 @@
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
R = na.omit(R)
n = length(R)
- Rp = (prod(1+R/100)^(period/length(R))-1)*100
+ Rp = (prod(1+R/100)^(period/length(R))-1)*100
Sigp = sqrt(sum((R-mean(R))^2)/n)*sqrt(period)
SR = (Rp - Rf) / Sigp
K = kurtosis(R, method = "moment")
Modified: pkg/PerformanceAnalytics/R/BernadoLedoitratio.R
===================================================================
--- pkg/PerformanceAnalytics/R/BernadoLedoitratio.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/BernadoLedoitratio.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -1,11 +1,11 @@
#' Bernardo and Ledoit ratio of the return distribution
#'
-#' To calculate Bernado and Ledoit ratio we take the sum of the subset of
+#' To calculate Bernardo and Ledoit ratio we take the sum of the subset of
#' 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{BernadoLedoitratio(R) = \frac{\frac{1}{n}\sum^{n}_{t=1}{max(R_{t},0)}}{\frac{1}{n}\sum^{n}_{t=1}
-#' {max(-R_{t},0)}}}{BernadoLedoitratio(R) = 1/n*sum
+#' \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
@@ -21,30 +21,26 @@
#' @keywords ts multivariate distribution models
#' @examples
#' data(portfolio_bacon)
-#' print(BernadoLedoitratio(portfolio_bacon)) #expected 1.78
+#' print(BernardoLedoitRatio(portfolio_bacon)) #expected 1.78
#'
#' data(managers)
-#' print(BernadoLedoitratio(managers['1996']))
-#' print(BernadoLedoitratio(managers['1996',1])) #expected 4.598
+#' print(BernardoLedoitRatio(managers['1996']))
+#' print(BernardoLedoitRatio(managers['1996',1])) #expected 4.598
#'
#' @export
-BernardoLedoitratio <- function (R, ...)
+BernardoLedoitRatio <- function (R, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
-
+ R <- checkData(R)
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
R = na.omit(R)
- r1 = subset(R, R > 0)
- r2 = subset(R, R < 0)
- result = sum(r1)/-sum(r2)
- reclass(result, R0)
+ r1 = R[which(R > 0)]
+ r2 = R[which(R < 0)]
+ result = sum(r1)/-sum(r2)
return(result)
}
else {
- R = checkData(R)
- result = apply(R, MARGIN = 2, BernardoLedoitratio, ...)
+ result = apply(R, MARGIN = 2, BernardoLedoitRatio, ...)
result<-t(result)
colnames(result) = colnames(R)
rownames(result) = paste("Bernardo and Ledoit ratio", sep="")
Modified: pkg/PerformanceAnalytics/R/DownsideDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideDeviation.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/DownsideDeviation.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -118,6 +118,7 @@
# MAR = mean(x)
method = method[1]
+ R = checkData(R, method="matrix")
if (ncol(R)==1 || is.vector(R) || is.null(R)) {
R = na.omit(R)
@@ -147,6 +148,7 @@
return(result)
}
else {
+ print("doit être format avec date")
R = checkData(R)
result = apply(R, MARGIN = 2, DownsideDeviation, MAR = MAR, method = method)
result<-t(result)
@@ -176,7 +178,8 @@
return(DownsideDeviation(R, MAR=MAR, method="full", potential=TRUE))
}
else {
- R = checkData(R, method = "matrix")
+ print("doit être format avec date")
+ R = checkData(R)
result = apply(R, MARGIN = 2, DownsidePotential, MAR = MAR)
result = matrix(result, nrow=1)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/ES.R
===================================================================
--- pkg/PerformanceAnalytics/R/ES.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/ES.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -113,7 +113,7 @@
#' ES(edhec, clean="boudt")
#'
#' # add Component ES for the equal weighted portfolio
-#' ES(edhec, clean="boudt", portfolio_method="component")
+#' #ES(edhec, clean="boudt", portfolio_method="component")
#'
ETL <- CVaR <- ES <- function (R=NULL , p=0.95, ...,
method=c("modified","gaussian","historical", "kernel"),
Modified: pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -18,7 +18,7 @@
#'
#' @keywords ts multivariate distribution models
#' @examples
-#' data(portfolio_bacon[,1])
+#' data(portfolio_bacon)
#' print(MeanAbsoluteDeviation(portfolio_bacon)) #expected 1.78
#'
#' data(managers)
Modified: pkg/PerformanceAnalytics/R/PainIndex.R
===================================================================
--- pkg/PerformanceAnalytics/R/PainIndex.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/PainIndex.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -26,8 +26,8 @@
#'
#' @keywords ts multivariate distribution models
#' @examples
-#' data(portfolio_bacon[,1])
-#' print(PainIndex(portfolio_bacon)) #expected 4.0
+#' data(portfolio_bacon)
+#' print(PainIndex(portfolio_bacon[,1])) #expected 4.0
#'
#' data(managers)
#' print(PainIndex(100*managers['1996']))
Modified: pkg/PerformanceAnalytics/R/PainRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/PainRatio.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/PainRatio.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -22,8 +22,8 @@
#'
#' @keywords ts multivariate distribution models
#' @examples
-#' data(portfolio_bacon[,1])
-#' print(PainRatio(portfolio_bacon)) #expected 2.59
+#' data(portfolio_bacon)
+#' print(PainRatio(portfolio_bacon[,1])) #expected 2.59
#'
#' data(managers)
#' print(PainRatio(100*managers['1996']))
Modified: pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -26,7 +26,7 @@
#'
#' data(managers)
#' print(SkewnessKurtosisRatio(managers['1996']))
-#' print(SkewnessKurtosisRatio(managers['1996',1])
+#' print(SkewnessKurtosisRatio(managers['1996',1]))
#'
#' @export
SkewnessKurtosisRatio <-
Modified: pkg/PerformanceAnalytics/R/TreynorRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/TreynorRatio.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/TreynorRatio.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -44,10 +44,58 @@
#' print(TreynorRatio(managers['1996',1:5], managers['1996',8], modified = TRUE))
#'
#' @export
+
TreynorRatio <-
function (Ra, Rb, Rf = 0, scale = NA, modified = FALSE)
{ # @author Peter Carl, Matthieu Lestel
+ModifiedTreynorRatio <-
+function (Ra, Rb, Rf = 0, scale = NA)
+{
+ if(is.na(scale)) {
+ freq = periodicity(Ra)
+ switch(freq$scale,
+ minute = {stop("Data periodicity too high")},
+ hourly = {stop("Data periodicity too high")},
+ daily = {scale = 252},
+ weekly = {scale = 52},
+ monthly = {scale = 12},
+ quarterly = {scale = 4},
+ yearly = {scale = 1}
+ )
+ }
+
+ calcul = FALSE
+ Ra = checkData(Ra, method="matrix")
+ Rb = checkData(Rb, method="matrix")
+
+ if (ncol(Ra)==1 || is.null(Ra) || is.vector(Ra)) {
+
+ Rp = (prod(1+Ra/100)^(scale/length(Ra))-1)*100
+ for (i in (1:length(Ra))) {
+ if (!is.na(Ra[i])) {
+ calcul = TRUE
+ }
+ }
+ if (calcul) {
+ result = (Rp - Rf) / SystematicRisk(Ra, Rb, Rf)
+ }
+ else {
+ result = NA
+ }
+ return(result)
+ }
+ else {
+ Ra = checkData(Ra)
+ result = apply(Ra, MARGIN = 2, ModifiedTreynorRatio, Rb = Rb, Rf = Rf)
+ result<-t(result)
+ colnames(result) = colnames(Ra)
+ rownames(result) = paste("Modified Treynor Ratio (Risk free = ",Rf,")", sep="")
+ return(result)
+ }
+}
+
+
if(modified)
{
ModifiedTreynorRatio(Ra, Rb, Rf, scale)
Modified: pkg/PerformanceAnalytics/R/UpsideRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideRisk.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/UpsideRisk.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -63,6 +63,7 @@
R = checkData(R, method="matrix")
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
+ print(R)
R = na.omit(R)
r = subset(R, R > MAR)
Modified: pkg/PerformanceAnalytics/R/VolatilitySkewness.R
===================================================================
--- pkg/PerformanceAnalytics/R/VolatilitySkewness.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/VolatilitySkewness.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -35,7 +35,7 @@
#'
#' MAR = 0
#' data(managers)
-#' print(VolatilitySkewness(managers['1996'], MAR, stat="volatility"))
+#'# print(VolatilitySkewness(managers['1996'], MAR, stat="volatility"))
#' print(VolatilitySkewness(managers['1996',1], MAR, stat="volatility"))
#'
#' @export
Modified: pkg/PerformanceAnalytics/R/chart.RollingRegression.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingRegression.R 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/R/chart.RollingRegression.R 2012-07-18 15:43:15 UTC (rev 2175)
@@ -48,8 +48,8 @@
#' managers[, 8, drop=FALSE], Rf = .04/12)
#' # not implemented yet
#' #charts.RollingQuantileRegression(managers[, 1:6],
-#' managers[, 8, drop=FALSE], Rf = .04/12,
-#' colorset = rich6equal, legend.loc="topleft")
+#' # managers[, 8, drop=FALSE], Rf = .04/12,
+#' # colorset = rich6equal, legend.loc="topleft")
#'
#' @export
chart.RollingRegression <-
Modified: pkg/PerformanceAnalytics/data/portfolio_bacon.csv
===================================================================
--- pkg/PerformanceAnalytics/data/portfolio_bacon.csv 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/data/portfolio_bacon.csv 2012-07-18 15:43:15 UTC (rev 2175)
@@ -1,25 +1,25 @@
,portfolio monthly return (%), benchmark return (%)
-2000-01-31,0.3,0.2
-2000-02-28,2.6,2.5
-2000-03-31,1.1,1.8
-2000-04-30,-1.0,-1.1
-2000-05-31,1.5,1.4
-2000-06-30,2.5,1.8
-2000-07-31,1.6,1.4
-2000-08-31,6.7,6.5
-2000-09-30,-1.4,-1.5
-2000-10-31,4.0,4.2
-2000-11-30,-0.5,-0.6
-2000-12-31,8.1,8.3
-2001-01-31,4.0,3.9
-2001-02-28,-3.7,-3.8
-2001-03-31,-6.1,-6.2
-2001-04-30,1.7,1.5
-2001-05-31,-4.9,-4.8
-2001-06-30,-2.2,2.1
-2001-07-31,7.0,6.0
-2001-08-31,5.8,5.6
-2001-09-30,-6.5,-6.7
-2001-10-31,2.4,1.9
-2001-11-30,-0.5,-0.3
-2001-12-31,-0.9,0
\ No newline at end of file
+2000-01-31,0.003,0.002
+2000-02-28,0.026,0.025
+2000-03-31,0.011,0.018
+2000-04-30,-0.010,-0.011
+2000-05-31,0.015,0.014
+2000-06-30,0.025,0.018
+2000-07-31,0.016,0.014
+2000-08-31,0.067,0.065
+2000-09-30,-0.014,-0.015
+2000-10-31,0.040,0.042
+2000-11-30,-0.005,-0.006
+2000-12-31,0.081,0.083
+2001-01-31,0.040,0.039
+2001-02-28,-0.037,-0.038
+2001-03-31,-0.061,-0.062
+2001-04-30,0.017,0.015
+2001-05-31,-0.049,-0.048
+2001-06-30,-0.022,0.021
+2001-07-31,0.070,0.060
+2001-08-31,0.058,0.056
+2001-09-30,-0.065,-0.067
+2001-10-31,0.024,0.019
+2001-11-30,-0.005,-0.003
+2001-12-31,-0.009,0
\ No newline at end of file
Modified: pkg/PerformanceAnalytics/data/portfolio_bacon.rda
===================================================================
(Binary files differ)
Modified: pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/AdjustedSharpeRatio.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -34,11 +34,11 @@
}
\examples{
data(portfolio_bacon)
-print(AdustedSharpeRatio(portfolio_bacon[,1])) #expected 0.813
+print(AdjustedSharpeRatio(portfolio_bacon[,1])) #expected 0.813
data(managers)
-print(AdustedSharpeRatio(managers['1996']))
-print(AdustedSharpeRatio(managers['1996',1]))
+print(AdjustedSharpeRatio(managers['1996']))
+print(AdjustedSharpeRatio(managers['1996',1]))
}
\author{
Matthieu Lestel
Deleted: pkg/PerformanceAnalytics/man/BernardoLedoitratio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/BernardoLedoitratio.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/BernardoLedoitratio.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -1,48 +0,0 @@
-\name{BernardoLedoitratio}
-\alias{BernardoLedoitratio}
-\alias{BernardoLedoitRatio}
-\title{Bernardo and Ledoit ratio of the return distribution}
-\usage{
- BernardoLedoitratio(R, ...)
-}
-\arguments{
- \item{R}{an xts, vector, matrix, data frame, timeSeries
- or zoo object of asset returns}
-
- \item{\dots}{any other passthru parameters}
-}
-\description{
- To calculate Bernado and Ledoit ratio we take the sum of
- the subset of returns that are above 0 and we divide it
- by the opposite of the sum of the subset of returns that
- are below 0
-}
-\details{
- \deqn{BernadoLedoitratio(R) =
- \frac{\frac{1}{n}\sum^{n}_{t=1}{max(R_{t},0)}}{\frac{1}{n}\sum^{n}_{t=1}
- {max(-R_{t},0)}}}{BernadoLedoitratio(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
-}
-\examples{
-data(portfolio_bacon)
-print(BernadoLedoitratio(portfolio_bacon)) #expected 1.78
-
-data(managers)
-print(BernadoLedoitratio(managers['1996']))
-print(BernadoLedoitratio(managers['1996',1])) #expected 4.598
-}
-\author{
- Matthieu Lestel
-}
-\references{
- Carl Bacon, \emph{Practical portfolio performance
- measurement and attribution}, second edition 2008 p.95
-}
-\keyword{distribution}
-\keyword{models}
-\keyword{multivariate}
-\keyword{ts}
-
Modified: pkg/PerformanceAnalytics/man/ES.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/ES.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/ES.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -124,7 +124,7 @@
ES(edhec, clean="boudt")
# add Component ES for the equal weighted portfolio
- ES(edhec, clean="boudt", portfolio_method="component")
+ #ES(edhec, clean="boudt", portfolio_method="component")
}
\author{
Brian G. Peterson and Kris Boudt
Modified: pkg/PerformanceAnalytics/man/MeanAbsoluteDeviation.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/MeanAbsoluteDeviation.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/MeanAbsoluteDeviation.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -26,7 +26,7 @@
\eqn{\overline{r}} is the mean return
}
\examples{
-data(portfolio_bacon[,1])
+data(portfolio_bacon)
print(MeanAbsoluteDeviation(portfolio_bacon)) #expected 1.78
data(managers)
Modified: pkg/PerformanceAnalytics/man/PainIndex.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/PainIndex.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/PainIndex.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -31,8 +31,8 @@
period i
}
\examples{
-data(portfolio_bacon[,1])
-print(PainIndex(portfolio_bacon)) #expected 4.0
+data(portfolio_bacon)
+print(PainIndex(portfolio_bacon[,1])) #expected 4.0
data(managers)
print(PainIndex(100*managers['1996']))
Modified: pkg/PerformanceAnalytics/man/PainRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/PainRatio.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/PainRatio.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -30,8 +30,8 @@
drawdown since previous peak in period i
}
\examples{
-data(portfolio_bacon[,1])
-print(PainRatio(portfolio_bacon)) #expected 2.59
+data(portfolio_bacon)
+print(PainRatio(portfolio_bacon[,1])) #expected 2.59
data(managers)
print(PainRatio(100*managers['1996']))
Modified: pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -31,7 +31,7 @@
data(managers)
print(SkewnessKurtosisRatio(managers['1996']))
-print(SkewnessKurtosisRatio(managers['1996',1])
+print(SkewnessKurtosisRatio(managers['1996',1]))
}
\author{
Matthieu Lestel
Modified: pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -45,7 +45,7 @@
MAR = 0
data(managers)
-print(VolatilitySkewness(managers['1996'], MAR, stat="volatility"))
+# print(VolatilitySkewness(managers['1996'], MAR, stat="volatility"))
print(VolatilitySkewness(managers['1996',1], MAR, stat="volatility"))
}
\author{
Modified: pkg/PerformanceAnalytics/man/chart.RollingRegression.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/chart.RollingRegression.Rd 2012-07-18 14:41:51 UTC (rev 2174)
+++ pkg/PerformanceAnalytics/man/chart.RollingRegression.Rd 2012-07-18 15:43:15 UTC (rev 2175)
@@ -79,8 +79,8 @@
managers[, 8, drop=FALSE], Rf = .04/12)
# not implemented yet
#charts.RollingQuantileRegression(managers[, 1:6],
- managers[, 8, drop=FALSE], Rf = .04/12,
- colorset = rich6equal, legend.loc="topleft")
+# managers[, 8, drop=FALSE], Rf = .04/12,
+# colorset = rich6equal, legend.loc="topleft")
}
\author{
Peter Carl
More information about the Returnanalytics-commits
mailing list