[Returnanalytics-commits] r2182 - in pkg/PerformanceAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 19 18:43:02 CEST 2012
Author: matthieu_lestel
Date: 2012-07-19 18:43:01 +0200 (Thu, 19 Jul 2012)
New Revision: 2182
Modified:
pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
pkg/PerformanceAnalytics/R/BurkeRatio.R
pkg/PerformanceAnalytics/R/CAPM.epsilon.R
pkg/PerformanceAnalytics/R/DRatio.R
pkg/PerformanceAnalytics/R/DownsideFrequency.R
pkg/PerformanceAnalytics/R/Kappa.R
pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R
pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R
pkg/PerformanceAnalytics/R/PainRatio.R
pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
pkg/PerformanceAnalytics/R/UpsideFrequency.R
pkg/PerformanceAnalytics/R/UpsideRisk.R
pkg/PerformanceAnalytics/R/VolatilitySkewness.R
pkg/PerformanceAnalytics/man/DRatio.Rd
pkg/PerformanceAnalytics/man/DownsideDeviation.Rd
pkg/PerformanceAnalytics/man/DownsideFrequency.Rd
pkg/PerformanceAnalytics/man/Kappa.Rd
pkg/PerformanceAnalytics/man/OmegaSharpeRatio.Rd
pkg/PerformanceAnalytics/man/PainRatio.Rd
pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
pkg/PerformanceAnalytics/man/UpsideFrequency.Rd
pkg/PerformanceAnalytics/man/UpsideRisk.Rd
pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd
Log:
modification to use xts objects inside the functions
Modified: pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/AdjustedSharpeRatio.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -32,23 +32,31 @@
AdjustedSharpeRatio <- function (R, Rf = 0, period = 12, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ 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
+ }
+ }
R = na.omit(R)
n = length(R)
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")
- S = skewness(R)
- result = SR*(1+(S/6)*SR-((K-3)/24)*SR^2)
- reclass(result, R0)
+ if(!calcul) {
+ result = NA
+ }
+ else {
+ K = kurtosis(R, method = "moment")
+ S = skewness(R)
+ result = SR*(1+(S/6)*SR-((K-3)/24)*SR^2)
+ }
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, AdjustedSharpeRatio, Rf = Rf, period = period, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/BurkeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/BurkeRatio.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/BurkeRatio.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -43,7 +43,6 @@
drawdown = c()
R0 <- R
R = checkData(R, method="matrix")
-
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
calcul = FALSE
n = length(R)
@@ -111,11 +110,10 @@
result = result * sqrt(n)
}
}
- reclass(result, R0)
return(result)
}
else {
- R = checkData(R)
+ R = checkData(R)
result = apply(R, MARGIN = 2, BurkeRatio, Rf = Rf, modified = modified, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/CAPM.epsilon.R
===================================================================
--- pkg/PerformanceAnalytics/R/CAPM.epsilon.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/CAPM.epsilon.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -35,21 +35,30 @@
CAPM.epsilon <-
function (Ra, Rb, Rf = 0, period=12, ...)
{
- 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)^(period/length(Ra))-1)*100
- Rpb = (prod(1+Rb/100)^(period/length(Rb))-1)*100 #benchmark total return
+ calcul = FALSE
for (i in (1:length(Ra))) {
if (!is.na(Ra[i])) {
calcul = TRUE
}
}
+ Ra = na.omit(Ra)
+ Rb = na.omit(Rb)
+ print(Ra)
+ print(Rb)
+ Rp = (prod(1+Ra/100)^(period/length(Ra))-1)*100
+ Rpb = (prod(1+Rb/100)^(period/length(Rb))-1)*100 #benchmark total return
+ print(Rp)
+ print(Rpb)
if (calcul) {
+ print(Rf)
+ print(CAPM.alpha(Ra,Rb,Rf))
result = Rf + Rp - CAPM.alpha(Ra,Rb,Rf) - (Rpb - Rf) * CAPM.beta(Ra,Rb,Rf)
+ print(result)
}
else {
result = NA
@@ -57,7 +66,7 @@
return(result)
}
else {
- Ra = checkData(Ra)
+ Ra = checkData(Ra)
result = apply(Ra, MARGIN = 2, CAPM.epsilon, Rb = Rb, Rf = Rf, ...)
result<-t(result)
colnames(result) = colnames(Ra)
Modified: pkg/PerformanceAnalytics/R/DRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/DRatio.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/DRatio.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -27,7 +27,7 @@
#' @keywords ts multivariate distribution models
#' @examples
#' data(portfolio_bacon)
-#' print(DRatio(portfolio_bacon)) #expected 0.401
+#' print(DRatio(portfolio_bacon[,1])) #expected 0.401
#'
#' data(managers)
#' print(DRatio(managers['1996']))
@@ -37,21 +37,18 @@
DRatio <- 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)
+ r1 = R[which(R > 0)]
+ r2 = R[which(R < 0)]
nd = length(r2)
nu = length(r1)
result = (-nd*sum(r2))/(nu*sum(r1))
- reclass(result, R0)
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, DRatio, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/DownsideFrequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideFrequency.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/DownsideFrequency.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -23,8 +23,8 @@
#' @keywords ts multivariate distribution models
#' @examples
#' data(portfolio_bacon)
-#' MAR = 0.5
-#' print(DownsideFrequency(portfolio_bacon, MAR)) #expected 0.458
+#' MAR = 0.005
+#' print(DownsideFrequency(portfolio_bacon[,1], MAR)) #expected 0.458
#'
#' data(managers)
#' print(DownsideFrequency(managers['1996']))
@@ -34,12 +34,11 @@
DownsideFrequency <- function (R, MAR = 0, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ R = checkData(R)
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
R = na.omit(R)
- r = subset(R, R < MAR)
+ r = R[which(R < MAR)]
if(!is.null(dim(MAR))){
if(is.timeBased(index(MAR))){
@@ -51,15 +50,12 @@
}
}
result = length(r) / length(R)
- reclass(result, R0)
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, DownsideFrequency, MAR = MAR, ...)
result<-t(result)
colnames(result) = colnames(R)
- print(MAR)
rownames(result) = paste("Downside Frequency (MAR = ",MAR,"%)", sep="")
return(result)
}
Modified: pkg/PerformanceAnalytics/R/Kappa.R
===================================================================
--- pkg/PerformanceAnalytics/R/Kappa.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/Kappa.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -39,8 +39,8 @@
#' l = 2
#'
#' data(portfolio_bacon)
-#' MAR = 0.5
-#' print(Kappa(portfolio_bacon, MAR, l)) #expected 0.157
+#' MAR = 0.005
+#' print(Kappa(portfolio_bacon[,1], MAR, l)) #expected 0.157
#'
#' data(managers)
#' MAR = 0
@@ -51,20 +51,17 @@
Kappa <- function (R, MAR, l, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ R = checkData(R)
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
R = na.omit(R)
- r = subset(R, R<MAR)
+ r = R[which(R < MAR)]
n = length(R)
m = mean(R)
result = (m-MAR)/(((1/n)*sum((MAR - r)^l))^(1/l))
- reclass(result, R0)
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, Kappa, MAR=MAR, l=l, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/MeanAbsoluteDeviation.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -29,17 +29,14 @@
MeanAbsoluteDeviation <- 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)
result = sum(abs(R - mean(R)))/length(R)
- reclass(result, R0)
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, MeanAbsoluteDeviation, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/OmegaSharpeRatio.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -29,8 +29,8 @@
#' @examples
#'
#' data(portfolio_bacon)
-#' MAR = 0.5
-#' print(OmegaSharpeRatio(portfolio_bacon, MAR)) #expected 0.29
+#' MAR = 0.005
+#' print(OmegaSharpeRatio(portfolio_bacon[,1], MAR)) #expected 0.29
#'
#' MAR = 0
#' data(managers)
@@ -41,12 +41,17 @@
OmegaSharpeRatio <-
function (R, MAR = 0, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ 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
+ }
+ }
R = na.omit(R)
- r = subset(R, R > MAR)
+ r = R[which(R > MAR)]
if(!is.null(dim(MAR))){
if(is.timeBased(index(MAR))){
@@ -57,12 +62,15 @@
# we have to assume that Ra and a vector of Rf passed in for MAR both cover the same time period
}
}
- result = (UpsideRisk(R,MAR,stat="potential") - DownsidePotential(R,MAR))/(DownsidePotential(R,MAR))
- reclass(result, R0)
+ if(!calcul) {
+ result = NA
+ }
+ else {
+ result = (UpsideRisk(R,MAR,stat="potential") - DownsidePotential(R,MAR))/(DownsidePotential(R,MAR))
+ }
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, OmegaSharpeRatio, MAR = MAR, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/PainRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/PainRatio.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/PainRatio.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -26,28 +26,37 @@
#' print(PainRatio(portfolio_bacon[,1])) #expected 2.59
#'
#' data(managers)
-#' print(PainRatio(100*managers['1996']))
-#' print(PainRatio(100*managers['1996',1]))
+#' print(PainRatio(managers['1996']))
+#' print(PainRatio(managers['1996',1]))
#'
#' @export
PainRatio <- function (R, Rf = 0, period = 12, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ 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
+ }
+ }
PI = PainIndex(R)
R = na.omit(R)
n = length(R)
- Rp = (prod(1+R/100)^(period/length(R))-1)*100
- result = (Rp - Rf) / PI
- reclass(result, R0)
+ if(!calcul) {
+ result = NA
+ }
+ else {
+ Rp = Return.annualized(R)
+# Rp = (prod(1+R/100)^(period/length(R))-1)*100
+ result = (Rp - Rf) / PI
+ }
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, PainRatio, MAR = MAR, Rf = Rf, period = period, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R
===================================================================
--- pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/SkewnessKurtosisRatio.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -22,7 +22,7 @@
#' @examples
#'
#' data(portfolio_bacon)
-#' print(SkewnessKurtosisRatio(portfolio_bacon)) #expected -0.0347
+#' print(SkewnessKurtosisRatio(portfolio_bacon[,1])) #expected -0.0318
#'
#' data(managers)
#' print(SkewnessKurtosisRatio(managers['1996']))
@@ -32,17 +32,25 @@
SkewnessKurtosisRatio <-
function (R, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ 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
+ }
+ }
R = na.omit(R)
- result = skewness(R) / kurtosis(R, method = "moment")
- reclass(result, R0)
+ if(!calcul) {
+ result = NA
+ }
+ else {
+ result = skewness(R) / kurtosis(R, method = "moment")
+ }
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, SkewnessKurtosisRatio, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/R/UpsideFrequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideFrequency.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/UpsideFrequency.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -23,8 +23,8 @@
#' @keywords ts multivariate distribution models
#' @examples
#' data(portfolio_bacon)
-#' MAR = 0.5
-#' print(UpsideFrequency(portfolio_bacon, MAR)) #expected 0.542
+#' MAR = 0.005
+#' print(UpsideFrequency(portfolio_bacon[,1], MAR)) #expected 0.542
#'
#' data(managers)
#' print(UpsideFrequency(managers['1996']))
@@ -34,12 +34,11 @@
UpsideFrequency <- function (R, MAR = 0, ...)
{
- R0 <- R
- R = checkData(R, method="matrix")
+ R = checkData(R)
if (ncol(R)==1 || is.null(R) || is.vector(R)) {
R = na.omit(R)
- r = subset(R, R > MAR)
+ r = R[which(R > MAR)]
if(!is.null(dim(MAR))){
if(is.timeBased(index(MAR))){
@@ -51,15 +50,12 @@
}
}
result = length(r) / length(R)
- reclass(result, R0)
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, UpsideFrequency, MAR = MAR, ...)
result<-t(result)
colnames(result) = colnames(R)
- print(MAR)
rownames(result) = paste("Upside Frequency (MAR = ",MAR,"%)", sep="")
return(result)
}
Modified: pkg/PerformanceAnalytics/R/UpsideRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideRisk.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/UpsideRisk.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -41,10 +41,10 @@
#' @examples
#'
#' data(portfolio_bacon)
-#' MAR = 0.5
-#' print(UpsideRisk(portfolio_bacon, MAR, stat="risk")) #expected 2.937
-#' print(UpsideRisk(portfolio_bacon, MAR, stat="variance")) #expected 8.628
-#' print(UpsideRisk(portfolio_bacon, MAR, stat="potential")) #expected 1.771
+#' MAR = 0.005
+#' print(UpsideRisk(portfolio_bacon[,1], MAR, stat="risk")) #expected 2.937
+#' print(UpsideRisk(portfolio_bacon[,1], MAR, stat="variance")) #expected 8.628
+#' print(UpsideRisk(portfolio_bacon[,1], MAR, stat="potential")) #expected 1.771
#'
#' MAR = 0
#' data(managers)
@@ -59,13 +59,11 @@
method = method[1]
stat = stat[1]
- R0 <- R
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)
+ r = R[which(R > MAR)]
if(!is.null(dim(MAR))){
if(is.timeBased(index(MAR))){
@@ -87,7 +85,6 @@
variance = {result = sum((r - MAR)^2/len)},
potential = {result = sum((r - MAR)/len)}
)
- reclass(result, R0)
return(result)
}
else {
Modified: pkg/PerformanceAnalytics/R/VolatilitySkewness.R
===================================================================
--- pkg/PerformanceAnalytics/R/VolatilitySkewness.R 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/R/VolatilitySkewness.R 2012-07-19 16:43:01 UTC (rev 2182)
@@ -29,9 +29,9 @@
#' @examples
#'
#' data(portfolio_bacon)
-#' MAR = 0.5
-#' print(VolatilitySkewness(portfolio_bacon, MAR, stat="volatility")) #expected 1.32
-#' print(VolatilitySkewness(portfolio_bacon, MAR, stat="variability")) #expected 1.15
+#' MAR = 0.005
+#' print(VolatilitySkewness(portfolio_bacon[,1], MAR, stat="volatility")) #expected 1.32
+#' print(VolatilitySkewness(portfolio_bacon[,1], MAR, stat="variability")) #expected 1.15
#'
#' MAR = 0
#' data(managers)
@@ -45,10 +45,15 @@
{
stat = stat[1]
- R0 <- R
- R = checkData(R, method="matrix")
+ 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
+ }
+ }
R = na.omit(R)
if(!is.null(dim(MAR))){
@@ -60,16 +65,18 @@
# we have to assume that Ra and a vector of Rf passed in for MAR both cover the same time period
}
}
-
- switch(stat,
- volatility = {result = UpsideRisk(R, MAR, stat="variance")/DownsideDeviation(R,MAR)^2},
- variability = {result = UpsideRisk(R, MAR, stat="risk")/DownsideDeviation(R,MAR)},
- )
- reclass(result, R0)
+ if(!calcul) {
+ result = NA
+ }
+ else {
+ switch(stat,
+ volatility = {result = UpsideRisk(R, MAR, stat="variance")/DownsideDeviation(R,MAR)^2},
+ variability = {result = UpsideRisk(R, MAR, stat="risk")/DownsideDeviation(R,MAR)},
+ )
+ }
return(result)
}
else {
- R = checkData(R)
result = apply(R, MARGIN = 2, VolatilitySkewness, MAR = MAR, stat = stat, ...)
result<-t(result)
colnames(result) = colnames(R)
Modified: pkg/PerformanceAnalytics/man/DRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/DRatio.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/DRatio.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -35,7 +35,7 @@
}
\examples{
data(portfolio_bacon)
-print(DRatio(portfolio_bacon)) #expected 0.401
+print(DRatio(portfolio_bacon[,1])) #expected 0.401
data(managers)
print(DRatio(managers['1996']))
Modified: pkg/PerformanceAnalytics/man/DownsideDeviation.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/DownsideDeviation.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/DownsideDeviation.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -3,6 +3,9 @@
\alias{DownsidePotential}
\alias{SemiDeviation}
\alias{SemiVariance}
+\alias{UpsideDeviation,}
+\alias{UpsidePotential}
+\alias{UpsideVariance,}
\title{downside risk (deviation, variance) of the return distribution}
\usage{
DownsideDeviation(R, MAR = 0,
@@ -11,6 +14,9 @@
SemiDeviation(R)
SemiVariance(R)
+
+ DownsideDeviation(R, MAR = 0,
+ method = c("full", "subset"), ..., potential = FALSE)
}
\arguments{
\item{R}{an xts, vector, matrix, data frame, timeSeries
@@ -28,6 +34,25 @@
\item{potential}{if TRUE, calculate downside potential
instead, default FALSE}
+
+ \item{R}{an xts, vector, matrix, data frame, timeSeries
+ or zoo object of asset returns}
+
+ \item{MAR}{Minimum Acceptable Return, in the same
+ periodicity as your returns}
+
+ \item{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"}
+
+ \item{author}{one of "Bacon", "Sortino", indicating
+ whether to}
+
+ \item{\dots}{any other passthru parameters}
+
+ \item{potential}{if TRUE, calculate downside potential
+ instead, default FALSE}
}
\description{
Downside deviation, semideviation, and semivariance are
@@ -120,9 +145,29 @@
SemiDeviation(managers[,1:6])
SemiVariance (managers[,1,drop=FALSE])
SemiVariance (managers[,1:6]) #calculated using method="subset"
+#with data used in Bacon 2008
+
+portfolio_return <- c(0.3,2.6,1.1,-1.0,1.5,2.5,1.6,6.7,-1.4,4.0,-0.5,8.1,4.0,-3.7,
+-6.1,1.7,-4.9,-2.2,7.0,5.8,-6.5,2.4,-0.5,-0.9)
+MAR = 0.5
+DownsideDeviation(portfolio_return, MAR) #expected 2.55
+DownsidePotential(portfolio_return, MAR) #expected 1.37
+
+#with data of managers
+
+data(managers)
+apply(managers[,1:6], 2, sd, na.rm=TRUE)
+DownsideDeviation(managers[,1:6]) # MAR 0\%
+DownsideDeviation(managers[,1:6], MAR = .04/12) #MAR 4\%
+SemiDeviation(managers[,1,drop=FALSE])
+SemiDeviation(managers[,1:6])
+SemiVariance (managers[,1,drop=FALSE])
+SemiVariance (managers[,1:6]) #calculated using method="subset"
}
\author{
Peter Carl, Brian G. Peterson, Matthieu Lestel
+
+ Peter Carl, Brian G. Peterson, Matthieu Lestel
}
\references{
Sortino, F. and Price, L. Performance Measurement in a
@@ -141,6 +186,23 @@
especially end note 10
\url{http://en.wikipedia.org/wiki/Semivariance}
+
+ Sortino, F. and Price, L. Performance Measurement in a
+ Downside Risk Framework. \emph{Journal of Investing}.
+ Fall 1994, 59-65. \cr Carl Bacon, \emph{Practical
+ portfolio performance measurement and attribution},
+ second edition 2008
+
+ Plantinga, A., van der Meer, R. and Sortino, F. The
+ Impact of Downside Risk on Risk-Adjusted Performance of
+ Mutual Funds in the Euronext Markets. July 19, 2001.
+ Available at SSRN: \url{http://ssrn.com/abstract=277352}
+ \cr
+
+ \url{http://www.sortino.com/htm/performance.htm} see
+ especially end note 10
+
+ \url{http://en.wikipedia.org/wiki/Semivariance}
}
\keyword{distribution}
\keyword{models}
Modified: pkg/PerformanceAnalytics/man/DownsideFrequency.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/DownsideFrequency.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/DownsideFrequency.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -30,8 +30,8 @@
}
\examples{
data(portfolio_bacon)
-MAR = 0.5
-print(DownsideFrequency(portfolio_bacon, MAR)) #expected 0.458
+MAR = 0.005
+print(DownsideFrequency(portfolio_bacon[,1], MAR)) #expected 0.458
data(managers)
print(DownsideFrequency(managers['1996']))
Modified: pkg/PerformanceAnalytics/man/Kappa.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/Kappa.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/Kappa.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -44,8 +44,8 @@
l = 2
data(portfolio_bacon)
-MAR = 0.5
-print(Kappa(portfolio_bacon, MAR, l)) #expected 0.157
+MAR = 0.005
+print(Kappa(portfolio_bacon[,1], MAR, l)) #expected 0.157
data(managers)
MAR = 0
Modified: pkg/PerformanceAnalytics/man/OmegaSharpeRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/OmegaSharpeRatio.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/OmegaSharpeRatio.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -38,8 +38,8 @@
}
\examples{
data(portfolio_bacon)
-MAR = 0.5
-print(OmegaSharpeRatio(portfolio_bacon, MAR)) #expected 0.29
+MAR = 0.005
+print(OmegaSharpeRatio(portfolio_bacon[,1], MAR)) #expected 0.29
MAR = 0
data(managers)
Modified: pkg/PerformanceAnalytics/man/PainRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/PainRatio.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/PainRatio.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -34,8 +34,8 @@
print(PainRatio(portfolio_bacon[,1])) #expected 2.59
data(managers)
-print(PainRatio(100*managers['1996']))
-print(PainRatio(100*managers['1996',1]))
+print(PainRatio(managers['1996']))
+print(PainRatio(managers['1996',1]))
}
\author{
Matthieu Lestel
Modified: pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/SkewnessKurtosisRatio.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -27,7 +27,7 @@
}
\examples{
data(portfolio_bacon)
-print(SkewnessKurtosisRatio(portfolio_bacon)) #expected -0.0347
+print(SkewnessKurtosisRatio(portfolio_bacon[,1])) #expected -0.0318
data(managers)
print(SkewnessKurtosisRatio(managers['1996']))
Modified: pkg/PerformanceAnalytics/man/UpsideFrequency.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/UpsideFrequency.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/UpsideFrequency.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -30,8 +30,8 @@
}
\examples{
data(portfolio_bacon)
-MAR = 0.5
-print(UpsideFrequency(portfolio_bacon, MAR)) #expected 0.542
+MAR = 0.005
+print(UpsideFrequency(portfolio_bacon[,1], MAR)) #expected 0.542
data(managers)
print(UpsideFrequency(managers['1996']))
Modified: pkg/PerformanceAnalytics/man/UpsideRisk.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/UpsideRisk.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/UpsideRisk.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -54,10 +54,10 @@
}
\examples{
data(portfolio_bacon)
-MAR = 0.5
-print(UpsideRisk(portfolio_bacon, MAR, stat="risk")) #expected 2.937
-print(UpsideRisk(portfolio_bacon, MAR, stat="variance")) #expected 8.628
-print(UpsideRisk(portfolio_bacon, MAR, stat="potential")) #expected 1.771
+MAR = 0.005
+print(UpsideRisk(portfolio_bacon[,1], MAR, stat="risk")) #expected 2.937
+print(UpsideRisk(portfolio_bacon[,1], MAR, stat="variance")) #expected 8.628
+print(UpsideRisk(portfolio_bacon[,1], MAR, stat="potential")) #expected 1.771
MAR = 0
data(managers)
Modified: pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd 2012-07-19 15:06:06 UTC (rev 2181)
+++ pkg/PerformanceAnalytics/man/VolatilitySkewness.Rd 2012-07-19 16:43:01 UTC (rev 2182)
@@ -39,9 +39,9 @@
}
\examples{
data(portfolio_bacon)
-MAR = 0.5
-print(VolatilitySkewness(portfolio_bacon, MAR, stat="volatility")) #expected 1.32
-print(VolatilitySkewness(portfolio_bacon, MAR, stat="variability")) #expected 1.15
+MAR = 0.005
+print(VolatilitySkewness(portfolio_bacon[,1], MAR, stat="volatility")) #expected 1.32
+print(VolatilitySkewness(portfolio_bacon[,1], MAR, stat="variability")) #expected 1.15
MAR = 0
data(managers)
More information about the Returnanalytics-commits
mailing list