[Returnanalytics-commits] r3049 - pkg/PerformanceAnalytics/sandbox/pulkit/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 11 00:14:53 CEST 2013
Author: pulkit
Date: 2013-09-11 00:14:53 +0200 (Wed, 11 Sep 2013)
New Revision: 3049
Modified:
pkg/PerformanceAnalytics/sandbox/pulkit/R/MaxDD.R
pkg/PerformanceAnalytics/sandbox/pulkit/R/TriplePenance.R
pkg/PerformanceAnalytics/sandbox/pulkit/R/TuW.R
pkg/PerformanceAnalytics/sandbox/pulkit/R/table.Penance.R
Log:
na handling in Triple penance
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/MaxDD.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/MaxDD.R 2013-09-10 20:23:51 UTC (rev 3048)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/MaxDD.R 2013-09-10 22:14:53 UTC (rev 3049)
@@ -65,7 +65,6 @@
# FUNCTION:
x = checkData(R)
- x = na.omit(x)
if(ncol(x)==1 || is.null(R) || is.vector(R)){
calcul = FALSE
for(i in (1:length(x))){
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/TriplePenance.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/TriplePenance.R 2013-09-10 20:23:51 UTC (rev 3048)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/TriplePenance.R 2013-09-10 22:14:53 UTC (rev 3049)
@@ -58,6 +58,7 @@
#
# confidence: The confidence interval.
x = checkData(R)
+ x = na.omit(x)
mu = mean(x, na.rm = TRUE)
sigma_infinity = StdDev(x)
phi = cov(x[-1],x[-length(x)])/(cov(x[-length(x)]))
@@ -79,6 +80,7 @@
}
if(mu<0){
warning(paste("NaN produced because mu < 0 ",colnames(x)))
+
}
minQ = list(value=NaN,x=NaN)
}
@@ -124,6 +126,7 @@
x = checkData(R)
+ x = na.omit(x)
mu = mean(x, na.rm = TRUE)
sigma_infinity = StdDev(x)
phi = cov(x[-1],x[-length(x)])/(cov(x[-length(x)]))
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/TuW.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/TuW.R 2013-09-10 20:23:51 UTC (rev 3048)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/TuW.R 2013-09-10 22:14:53 UTC (rev 3049)
@@ -39,7 +39,6 @@
TuW<-function(R,confidence=0.95,type=c("ar","normal"),...){
x = checkData(R)
- x = na.omit(x)
if(ncol(x)==1 || is.null(R) || is.vector(R)){
calcul = FALSE
for(i in (1:length(x))){
Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/table.Penance.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/table.Penance.R 2013-09-10 20:23:51 UTC (rev 3048)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/table.Penance.R 2013-09-10 22:14:53 UTC (rev 3049)
@@ -14,7 +14,7 @@
#' @references Bailey, David H. and Lopez de Prado, Marcos, Drawdown-Based Stop-Outs and the "Triple Penance" Rule(January 1, 2013).
#' @export
-table.Penance<-function(R,confidence){
+table.Penance<-function(R,confidence=0.95){
# DESCRIPTION:
# Maximum Drawdown and Time under Water considering first-order serial correlation
#
@@ -26,15 +26,15 @@
#
# Function:
x = checkData(R)
- x = na.omit(x)
columns = ncol(x)
columnnames = colnames(x)
rownames = c("mean","stdDev","phi","sigma","MaxDD(in %)","t*","MaxTuW","Penance")
for(column in 1:columns){
- phi = cov(x[,column][-1],x[,column][-length(x[,column])])/(cov(x[,column][-length(x[,column])]))
- sigma_infinity = StdDev(x[,column])
+ col_val = na.omit(x[,column])
+ phi = cov(col_val[-1],col_val[-length(col_val)])/(cov(col_val[-length(col_val)]))
+ sigma_infinity = StdDev(col_val)
sigma = sigma_infinity*((1-phi^2)^0.5)
- column_MinQ<-c(mean(x[,column]),sigma_infinity,phi,sigma)
+ column_MinQ<-c(mean(col_val),sigma_infinity,phi,sigma)
column_MinQ <- c(column_MinQ,get_minq(x[,column],confidence))
column_TuW = get_TuW(x[,column],confidence)
v = c(column_MinQ,column_TuW,column_MinQ[5]/column_TuW)
More information about the Returnanalytics-commits
mailing list