Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions R/table.Distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function (R, scale = NA, digits = 4)

#set up frequency
if(is.na(scale)) {
freq = periodicity(y)
freq = periodicity(R)
name <- paste0(freq$scale," Std Dev")
switch(freq$scale,
minute = {stop("Data periodicity too high")},
hourly = {stop("Data periodicity too high")},
Expand All @@ -52,13 +53,15 @@ function (R, scale = NA, digits = 4)
quarterly = {scale = 4},
yearly = {scale = 1}
)
} else {
name <- paste0("Std Dev")
}

# for each column, do the following:
for(column in 1:columns) {
z = c(StdDev.annualized(y[,column,drop=FALSE])/sqrt(scale), skewness(y[,column,drop=FALSE], method = "moment"), kurtosis(y[,column,drop=FALSE], method = "moment"), kurtosis(y[,column,drop=FALSE], method = "excess"), skewness(y[,column,drop=FALSE], method = "sample"), kurtosis(y[,column,drop=FALSE], method = "sample_excess"))

znames = c(paste(freq$scale," Std Dev"), "Skewness", "Kurtosis", "Excess kurtosis", "Sample skewness", "Sample excess kurtosis")
znames = c(name, "Skewness", "Kurtosis", "Excess kurtosis", "Sample skewness", "Sample excess kurtosis")


if(column == 1) {
Expand Down
5 changes: 4 additions & 1 deletion R/table.DownsideRiskRatio.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function (R, MAR = 0, scale = NA, digits = 4)
#set up frequency
if(is.na(scale)) {
freq = periodicity(R)
name <- paste0(freq$scale," downside risk")
switch(freq$scale,
minute = {stop("Data periodicity too high")},
hourly = {stop("Data periodicity too high")},
Expand All @@ -55,13 +56,15 @@ function (R, MAR = 0, scale = NA, digits = 4)
quarterly = {scale = 4},
yearly = {scale = 1}
)
} else {
name <- paste0("downside risk")
}

# for each column, do the following:
for(column in 1:columns) {
z = c(DownsideDeviation(y[,column,drop=FALSE], MAR = MAR), DownsideDeviation(y[,column,drop=FALSE], MAR = MAR)*sqrt(scale), DownsidePotential(y[,column,drop=FALSE], MAR = MAR), UpsideRisk(y[,column,drop=FALSE], MAR = MAR, stat = "potential")/DownsidePotential(y[,column,drop=FALSE], MAR = MAR), SortinoRatio(y[,column,drop=FALSE], MAR = MAR), UpsideRisk(y[,column,drop=FALSE], MAR = MAR, stat = "potential"), UpsidePotentialRatio(y[,column,drop=FALSE], MAR = MAR), OmegaSharpeRatio(y[,column,drop=FALSE], MAR = MAR))

znames = c(paste0(freq$scale," downside risk"), "Annualised downside risk", "Downside potential", "Omega", "Sortino ratio", "Upside potential", "Upside potential ratio", "Omega-sharpe ratio")
znames = c(name, "Annualised downside risk", "Downside potential", "Omega", "Sortino ratio", "Upside potential", "Upside potential ratio", "Omega-sharpe ratio")
if(column == 1) {
resultingtable = data.frame(Value = z, row.names = znames)
}
Expand Down
5 changes: 4 additions & 1 deletion R/table.Variability.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function (R, scale = NA, geometric = TRUE, digits = 4)
#set up frequency
if(is.na(scale)) {
freq = periodicity(R)
name <- paste0(freq$scale," Std Dev")
switch(freq$scale,
minute = {stop("Data periodicity too high")},
hourly = {stop("Data periodicity too high")},
Expand All @@ -55,13 +56,15 @@ function (R, scale = NA, geometric = TRUE, digits = 4)
quarterly = {scale = 4},
yearly = {scale = 1}
)
} else {
name <- paste0("Std Dev")
}

# for each column, do the following:
for(column in 1:columns) {
z = c(MeanAbsoluteDeviation(y[,column,drop=FALSE]), StdDev.annualized(y[,column,drop=FALSE], scale = scale)/sqrt(scale), StdDev.annualized(y[,column,drop=FALSE], scale = scale))

znames = c("Mean Absolute deviation", paste0(freq$scale," Std Dev"), "Annualized Std Dev")
znames = c("Mean Absolute deviation", name, "Annualized Std Dev")


if(column == 1) {
Expand Down