From 1c30c7dd64d1ac6db989a5701ffebbb11501aeb2 Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Sun, 24 Jul 2016 22:56:10 -0600 Subject: [PATCH] Added printSE() function for formatted result output --- NAMESPACE | 1 + R/ES_SE.R | 2 +- R/EstimatorES.R | 1 + R/GLM_EN.R | 1 + R/InfluenceFunctions.R | 1 + R/SE_ES.R | 1 + R/printSE.R | 26 ++++++++++++++++++++++++++ man/ES.SE.Rd | 2 +- man/EstimatorSE.Rd | 3 +++ man/SE.ES.Rd | 3 +++ man/mu.IF.Rd | 3 +++ man/myperiodogram.Rd | 3 +++ man/printSE.Rd | 25 +++++++++++++++++++++++++ 13 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 R/printSE.R create mode 100644 man/printSE.Rd diff --git a/NAMESPACE b/NAMESPACE index b0334c1..6b2f8e6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -54,6 +54,7 @@ export(VaR.hist) export(mu.IF) export(myperiodogram) export(nse.nw) +export(printSE) import(sandwich) import(xts) import(zoo) diff --git a/R/ES_SE.R b/R/ES_SE.R index 2758e1d..1dfcebd 100644 --- a/R/ES_SE.R +++ b/R/ES_SE.R @@ -70,7 +70,7 @@ #' decompose total portfolio ES into the risk contributions of each of the #' portfolio components. For the above mentioned ES estimators, such a #' decomposition is possible in a financially meaningful way. -#' @author Brian G. Peterson and Kris Boudt +#' @author Brian G. Peterson, Kris Boudt and Xin Chen #' @seealso \code{\link{VaR}} \cr \code{\link{SharpeRatio.modified}} \cr #' \code{\link{chart.VaRSensitivity}} \cr \code{\link{Return.clean}} #' diff --git a/R/EstimatorES.R b/R/EstimatorES.R index 2dffa31..2c70a8a 100644 --- a/R/EstimatorES.R +++ b/R/EstimatorES.R @@ -12,6 +12,7 @@ #' #' @return the standard error of the specified risk/performance measure using the specified method #' @export +#' @author Xin Chen #' #' @examples #' data(edhec) diff --git a/R/GLM_EN.R b/R/GLM_EN.R index 2ead2ac..edfb307 100644 --- a/R/GLM_EN.R +++ b/R/GLM_EN.R @@ -2,6 +2,7 @@ #' #' @param data Vector of data #' @param max.freq Maximum frequency to be computed +#' @author Xin Chen #' #' @return list of frequencies and corresponding periodograms #' @export diff --git a/R/InfluenceFunctions.R b/R/InfluenceFunctions.R index 30f0bd1..58a27d6 100644 --- a/R/InfluenceFunctions.R +++ b/R/InfluenceFunctions.R @@ -6,6 +6,7 @@ #' #' @return IF of Mean #' @export +#' @author Xin Chen #' #' @examples #' mu.IF(rnorm(10)) diff --git a/R/SE_ES.R b/R/SE_ES.R index f8b683f..83a5fc8 100644 --- a/R/SE_ES.R +++ b/R/SE_ES.R @@ -8,6 +8,7 @@ #' is implemented. #' #' @return SE of ES +#' @author Xin Chen #' @export #' #' @examples diff --git a/R/printSE.R b/R/printSE.R new file mode 100644 index 0000000..3947393 --- /dev/null +++ b/R/printSE.R @@ -0,0 +1,26 @@ +#' Formatted output of the results from xxx.SE() functions +#' +#' @param res the results from the xx.SE() functions +#' @param round.digit the number of digits to round to +#' +#' @return No return values +#' @export +#' +#' @examples +#' data(edhec) +#' res = ES.SE(edhec, p=.95, method="historical",se.method = "IFiid") +#' printSE(res, round.digit = 4) +printSE = function(res , round.digit = 3){ + N = length(res) + if(N != 2) { + cat("the results do not contain standard errors!\n") + return() + } + list.names = names(res) + res.df = data.frame(as.vector(res[[1]]), as.vector(res[[2]])) + colnames(res.df) = list.names + rownames(res.df) = colnames(res[[1]]) + res.df = round(res.df, digits = round.digit) + res.df[2] = paste("(",res.df[,2],")") + print(res.df) +} diff --git a/man/ES.SE.Rd b/man/ES.SE.Rd index eb0fd95..7e7007e 100644 --- a/man/ES.SE.Rd +++ b/man/ES.SE.Rd @@ -133,7 +133,7 @@ decomposition is possible in a financially meaningful way. ES.SE(edhec, clean="boudt", portfolio_method="component") } \author{ -Brian G. Peterson and Kris Boudt +Brian G. Peterson, Kris Boudt and Xin Chen } \references{ Boudt, Kris, Peterson, Brian, and Christophe Croux. 2008. diff --git a/man/EstimatorSE.Rd b/man/EstimatorSE.Rd index 567924a..a4d9508 100644 --- a/man/EstimatorSE.Rd +++ b/man/EstimatorSE.Rd @@ -32,4 +32,7 @@ Wrapper function for computing the standard error of risk/performance measure es data(edhec) EstimatorSE(edhec,estimator.fun="SD",se.method="IFiid") } +\author{ +Xin Chen +} diff --git a/man/SE.ES.Rd b/man/SE.ES.Rd index c4fdcb2..408c903 100644 --- a/man/SE.ES.Rd +++ b/man/SE.ES.Rd @@ -27,4 +27,7 @@ Wrapper function to compute the standard error for ES estimator data(edhec) SE.ES(edhec,se.method="IFiid") } +\author{ +Xin Chen +} diff --git a/man/mu.IF.Rd b/man/mu.IF.Rd index db4e50d..cfbf13a 100644 --- a/man/mu.IF.Rd +++ b/man/mu.IF.Rd @@ -18,4 +18,7 @@ Influence Function of Mean \examples{ mu.IF(rnorm(10)) } +\author{ +Xin Chen +} diff --git a/man/myperiodogram.Rd b/man/myperiodogram.Rd index c2aba80..b410331 100644 --- a/man/myperiodogram.Rd +++ b/man/myperiodogram.Rd @@ -20,4 +20,7 @@ Compute the periodogram as defined in H&W 1981 \examples{ myperiodogram(rnorm(10)) } +\author{ +Xin Chen +} diff --git a/man/printSE.Rd b/man/printSE.Rd new file mode 100644 index 0000000..d5f66a5 --- /dev/null +++ b/man/printSE.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/printSE.R +\name{printSE} +\alias{printSE} +\title{Formatted output of the results from xxx.SE() functions} +\usage{ +printSE(res, round.digit = 3) +} +\arguments{ +\item{res}{the results from the xx.SE() functions} + +\item{round.digit}{the number of digits to round to} +} +\value{ +No return values +} +\description{ +Formatted output of the results from xxx.SE() functions +} +\examples{ +data(edhec) +res = ES.SE(edhec, p=.95, method="historical",se.method = "IFiid") +printSE(res) +} +