[Returnanalytics-commits] r3994 - in pkg/FactorAnalytics: . R man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 15 08:23:49 CEST 2015
Author: pragnya
Date: 2015-09-15 08:23:49 +0200 (Tue, 15 Sep 2015)
New Revision: 3994
Modified:
pkg/FactorAnalytics/DESCRIPTION
pkg/FactorAnalytics/NAMESPACE
pkg/FactorAnalytics/R/fmEsDecomp.R
pkg/FactorAnalytics/R/fmVaRDecomp.R
pkg/FactorAnalytics/R/plot.sfm.r
pkg/FactorAnalytics/R/plot.tsfm.r
pkg/FactorAnalytics/R/zzz.R
pkg/FactorAnalytics/man/fmEsDecomp.Rd
pkg/FactorAnalytics/man/fmVaRDecomp.Rd
pkg/FactorAnalytics/man/plot.sfm.Rd
pkg/FactorAnalytics/man/plot.tsfm.Rd
pkg/FactorAnalytics/vignettes/fitSfm_vignette.R
pkg/FactorAnalytics/vignettes/fitSfm_vignette.Rnw
pkg/FactorAnalytics/vignettes/fitSfm_vignette.pdf
pkg/FactorAnalytics/vignettes/fitTsfm_vignette.R
pkg/FactorAnalytics/vignettes/fitTsfm_vignette.Rnw
pkg/FactorAnalytics/vignettes/fitTsfm_vignette.pdf
Log:
VaR calculated as a sample quantile.
Modified: pkg/FactorAnalytics/DESCRIPTION
===================================================================
--- pkg/FactorAnalytics/DESCRIPTION 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/DESCRIPTION 2015-09-15 06:23:49 UTC (rev 3994)
@@ -1,7 +1,7 @@
Package: factorAnalytics
Type: Package
Title: Factor Analytics
-Version: 2.0.25
+Version: 2.0.26
Date: 2015-09-14
Author: Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
Maintainer: Sangeetha Srinivasan <sangee at uw.edu>
Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/NAMESPACE 2015-09-15 06:23:49 UTC (rev 3994)
@@ -54,7 +54,6 @@
import(zoo)
importFrom(MASS,ginv)
importFrom(PerformanceAnalytics,Return.cumulative)
-importFrom(PerformanceAnalytics,VaR)
importFrom(PerformanceAnalytics,chart.ACFplus)
importFrom(PerformanceAnalytics,chart.Correlation)
importFrom(PerformanceAnalytics,chart.Histogram)
Modified: pkg/FactorAnalytics/R/fmEsDecomp.R
===================================================================
--- pkg/FactorAnalytics/R/fmEsDecomp.R 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/R/fmEsDecomp.R 2015-09-15 06:23:49 UTC (rev 3994)
@@ -4,8 +4,8 @@
#' Expected Shortfall (ES) of assets' returns based on Euler's theorem, given
#' the fitted factor model. The partial derivative of ES with respect to factor
#' beta is computed as the expected factor return given fund return is less
-#' than or equal to its value-at-risk (VaR). VaR is computed as the sample quantile of the historic or
-#' simulated data.
+#' than or equal to its value-at-risk (VaR). VaR is computed as the sample
+#' quantile.
#'
#' @details The factor model for an asset's return at time \code{t} has the
#' form \cr \cr \code{R(t) = beta'f(t) + e(t) = beta.star'f.star(t)} \cr \cr
@@ -19,20 +19,9 @@
#' being less than or equal to \code{VaR.fm}. This is estimated as a sample
#' average of the observations in that data window.
#'
-#' Computation of the VaR measure is done using
-#' \code{\link[PerformanceAnalytics]{VaR}}. Arguments \code{p}, \code{method}
-#' and \code{invert} are passed to this function. Refer to their help file for
-#' details and other options. \code{invert} consistently affects the sign for
-#' all VaR and ES measures.
-#'
#' @param object fit object of class \code{tsfm}, \code{sfm} or \code{ffm}.
#' @param p confidence level for calculation. Default is 0.95.
-#' @param method method for computing VaR, one of "modified","gaussian",
-#' "historical", "kernel". Default is "modified". See details.
-#' @param invert logical; whether to invert the VaR measure. Default is
-#' \code{FALSE}.
-#' @param ... other optional arguments passed to
-#' \code{\link[PerformanceAnalytics]{VaR}}.
+#' @param ... other optional arguments passed to \code{\link[stats]{quantile}}.
#'
#' @return A list containing
#' \item{ES.fm}{length-N vector of factor model ES of N-asset returns.}
@@ -63,7 +52,6 @@
#' @seealso \code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
#' for the different factor model fitting functions.
#'
-#' \code{\link[PerformanceAnalytics]{VaR}} for VaR computation.
#' \code{\link{fmSdDecomp}} for factor model SD decomposition.
#' \code{\link{fmVaRDecomp}} for factor model VaR decomposition.
#'
@@ -96,18 +84,8 @@
#' @method fmEsDecomp tsfm
#' @export
-fmEsDecomp.tsfm <- function(object, p=0.95,
- method=c("modified","gaussian","historical",
- "kernel"), invert=FALSE, ...) {
+fmEsDecomp.tsfm <- function(object, p=0.95, ...) {
- # set defaults and check input vailidity
- method = method[1]
-
- if (!(method %in% c("modified", "gaussian", "historical", "kernel"))) {
- stop("Invalid argument: method must be 'modified', 'gaussian',
- 'historical' or 'kernel'")
- }
-
# get beta.star
beta <- object$beta
beta[is.na(beta)] <- 0
@@ -137,7 +115,7 @@
# return data for asset i
R.xts <- object$data[,i]
# get VaR for asset i
- VaR.fm[i] <- VaR(R.xts, p=p, method=method, invert=invert, ...)
+ VaR.fm[i] <- quantile(R.xts, probs=1-p, na.rm=TRUE, ...)
# index of VaR exceedances
idx.exceed[[i]] <- which(R.xts <= VaR.fm[i])
# number of VaR exceedances
@@ -147,18 +125,16 @@
factor.star <- merge(factors.xts, resid.xts[,i])
colnames(factor.star)[dim(factor.star)[2]] <- "residual"
- if (!invert) {inv=-1} else {inv=1}
-
# compute ES as expected value of asset return, such that the given asset
# return is less than or equal to its value-at-risk (VaR) and approximated
# by a kernel estimator.
- idx <- which(R.xts <= inv*VaR.fm[i])
- ES.fm[i] <- inv * mean(R.xts[idx], na.rm =TRUE)
+ idx <- which(R.xts <= VaR.fm[i])
+ ES.fm[i] <- mean(R.xts[idx], na.rm =TRUE)
# compute marginal ES as expected value of factor returns, such that the
# given asset return is less than or equal to its value-at-risk (VaR) and
# approximated by a kernel estimator.
- mES[i,] <- inv * colMeans(factor.star[idx,], na.rm =TRUE)
+ mES[i,] <- colMeans(factor.star[idx,], na.rm =TRUE)
# correction factor to ensure that sum(cES) = portfolio ES
cf <- as.numeric( ES.fm[i] / sum(mES[i,]*beta.star[i,], na.rm=TRUE) )
@@ -180,18 +156,8 @@
#' @method fmEsDecomp sfm
#' @export
-fmEsDecomp.sfm <- function(object, p=0.95,
- method=c("modified","gaussian","historical",
- "kernel"), invert=FALSE, ...) {
+fmEsDecomp.sfm <- function(object, p=0.95, ...) {
- # set defaults and check input vailidity
- method = method[1]
-
- if (!(method %in% c("modified", "gaussian", "historical", "kernel"))) {
- stop("Invalid argument: method must be 'modified', 'gaussian',
- 'historical' or 'kernel'")
- }
-
# get beta.star
beta <- object$loadings
beta[is.na(beta)] <- 0
@@ -222,7 +188,7 @@
# return data for asset i
R.xts <- object$data[,i]
# get VaR for asset i
- VaR.fm[i] <- VaR(R.xts, p=p, method=method, invert=invert, ...)
+ VaR.fm[i] <- quantile(R.xts, probs=1-p, na.rm=TRUE, ...)
# index of VaR exceedances
idx.exceed[[i]] <- which(R.xts <= VaR.fm[i])
# number of VaR exceedances
@@ -232,18 +198,16 @@
factor.star <- merge(factors.xts, resid.xts[,i])
colnames(factor.star)[dim(factor.star)[2]] <- "residual"
- if (!invert) {inv=-1} else {inv=1}
-
# compute ES as expected value of asset return, such that the given asset
# return is less than or equal to its value-at-risk (VaR) and approximated
# by a kernel estimator.
- idx <- which(R.xts <= inv*VaR.fm[i])
- ES.fm[i] <- inv * mean(R.xts[idx], na.rm =TRUE)
+ idx <- which(R.xts <= VaR.fm[i])
+ ES.fm[i] <- mean(R.xts[idx], na.rm =TRUE)
# compute marginal ES as expected value of factor returns, such that the
# given asset return is less than or equal to its value-at-risk (VaR) and
# approximated by a kernel estimator.
- mES[i,] <- inv * colMeans(factor.star[idx,], na.rm =TRUE)
+ mES[i,] <- colMeans(factor.star[idx,], na.rm =TRUE)
# correction factor to ensure that sum(cES) = portfolio ES
cf <- as.numeric( ES.fm[i] / sum(mES[i,]*beta.star[i,], na.rm=TRUE) )
Modified: pkg/FactorAnalytics/R/fmVaRDecomp.R
===================================================================
--- pkg/FactorAnalytics/R/fmVaRDecomp.R 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/R/fmVaRDecomp.R 2015-09-15 06:23:49 UTC (rev 3994)
@@ -4,8 +4,7 @@
#' assets' returns based on Euler's theorem, given the fitted factor model.
#' The partial derivative of VaR wrt factor beta is computed as the expected
#' factor return given fund return is equal to its VaR and approximated by a
-#' kernel estimator. VaR is computed either as the sample quantile or as an
-#' estimated quantile using the Cornish-Fisher expansion.
+#' kernel estimator. VaR is computed as the sample quantile.
#'
#' @details The factor model for an asset's return at time \code{t} has the
#' form \cr \cr \code{R(t) = beta'f(t) + e(t) = beta.star'f.star(t)} \cr \cr
@@ -19,19 +18,9 @@
#' being equal to \code{VaR.fm}. This is approximated as described in
#' Epperlein & Smillie (2006); a triangular smoothing kernel is used here.
#'
-#' Computation of the risk measure is done using
-#' \code{\link[PerformanceAnalytics]{VaR}}. Arguments \code{p}, \code{method}
-#' and \code{invert} are passed to this function. Refer to their help file for
-#' details and other options.
-#'
#' @param object fit object of class \code{tsfm}, \code{sfm} or \code{ffm}.
#' @param p confidence level for calculation. Default is 0.95.
-#' @param method method for computing VaR, one of "modified","gaussian",
-#' "historical", "kernel". Default is "modified". See details.
-#' @param invert logical; whether to invert the VaR measure. Default is
-#' \code{FALSE}.
-#' @param ... other optional arguments passed to
-#' \code{\link[PerformanceAnalytics]{VaR}}.
+#' @param ... other optional arguments passed to \code{\link[stats]{quantile}}.
#'
#' @return A list containing
#' \item{VaR.fm}{length-N vector of factor model VaRs of N-asset returns.}
@@ -59,7 +48,6 @@
#' @seealso \code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
#' for the different factor model fitting functions.
#'
-#' \code{\link[PerformanceAnalytics]{VaR}} for VaR computation.
#' \code{\link{fmSdDecomp}} for factor model SD decomposition.
#' \code{\link{fmEsDecomp}} for factor model ES decomposition.
#'
@@ -93,18 +81,8 @@
#' @method fmVaRDecomp tsfm
#' @export
-fmVaRDecomp.tsfm <- function(object, p=0.95,
- method=c("modified","gaussian","historical",
- "kernel"), invert=FALSE, ...) {
+fmVaRDecomp.tsfm <- function(object, p=0.95, ...) {
- # set defaults and check input vailidity
- method = method[1]
-
- if (!(method %in% c("modified", "gaussian", "historical", "kernel"))) {
- stop("Invalid argument: method must be 'modified', 'gaussian',
- 'historical' or 'kernel'")
- }
-
# get beta.star
beta <- object$beta
beta[is.na(beta)] <- 0
@@ -134,7 +112,7 @@
# return data for asset i
R.xts <- object$data[,i]
# get VaR for asset i
- VaR.fm[i] <- VaR(R.xts, p=p, method=method, invert=invert, ...)
+ VaR.fm[i] <- quantile(R.xts, probs=1-p, na.rm=TRUE, ...)
# index of VaR exceedances
idx.exceed[[i]] <- which(R.xts <= VaR.fm[i])
# number of VaR exceedances
@@ -151,8 +129,6 @@
factor.star <- merge(factors.xts, resid.xts[,i])
colnames(factor.star)[dim(factor.star)[2]] <- "residual"
- if (!invert) {inv=-1} else {inv=1}
-
# epsilon is apprx. using Silverman's rule of thumb (bandwidth selection)
# the constant 2.575 corresponds to a triangular kernel
eps <- 2.575*sd(R.xts, na.rm =TRUE) * (nrow(R.xts)^(-1/5))
@@ -161,7 +137,7 @@
# VaR value and bandwidth = epsilon.
k.weight <- as.vector(1 - abs(R.xts - VaR.fm[i]) / eps)
k.weight[k.weight<0] <- 0
- mVaR[i,] <- inv * colMeans(factor.star*k.weight, na.rm =TRUE)
+ mVaR[i,] <- colMeans(factor.star*k.weight, na.rm =TRUE)
# correction factor to ensure that sum(cVaR) = portfolio VaR
cf <- as.numeric( VaR.fm[i] / sum(mVaR[i,]*beta.star[i,], na.rm=TRUE) )
@@ -183,18 +159,8 @@
#' @method fmVaRDecomp sfm
#' @export
-fmVaRDecomp.sfm <- function(object, p=0.95,
- method=c("modified","gaussian","historical",
- "kernel"), invert=FALSE, ...) {
+fmVaRDecomp.sfm <- function(object, p=0.95, ...) {
- # set defaults and check input vailidity
- method = method[1]
-
- if (!(method %in% c("modified", "gaussian", "historical", "kernel"))) {
- stop("Invalid argument: method must be 'modified', 'gaussian',
- 'historical' or 'kernel'")
- }
-
# get beta.star
beta <- object$loadings
beta[is.na(beta)] <- 0
@@ -224,7 +190,7 @@
# return data for asset i
R.xts <- object$data[,i]
# get VaR for asset i
- VaR.fm[i] <- VaR(R.xts, p=p, method=method, invert=invert, ...)
+ VaR.fm[i] <- quantile(R.xts, probs=1-p, na.rm=TRUE, ...)
# index of VaR exceedances
idx.exceed[[i]] <- which(R.xts <= VaR.fm[i])
# number of VaR exceedances
@@ -241,8 +207,6 @@
factor.star <- merge(factors.xts, resid.xts[,i])
colnames(factor.star)[dim(factor.star)[2]] <- "residual"
- if (!invert) {inv=-1} else {inv=1}
-
# epsilon is apprx. using Silverman's rule of thumb (bandwidth selection)
# the constant 2.575 corresponds to a triangular kernel
eps <- 2.575*sd(R.xts, na.rm =TRUE) * (nrow(R.xts)^(-1/5))
@@ -251,7 +215,7 @@
# VaR value and bandwidth = epsilon.
k.weight <- as.vector(1 - abs(R.xts - VaR.fm[i]) / eps)
k.weight[k.weight<0] <- 0
- mVaR[i,] <- inv * colMeans(factor.star*k.weight, na.rm =TRUE)
+ mVaR[i,] <- colMeans(factor.star*k.weight, na.rm =TRUE)
# correction factor to ensure that sum(cVaR) = portfolio VaR
cf <- as.numeric( VaR.fm[i] / sum(mVaR[i,]*beta.star[i,], na.rm=TRUE) )
Modified: pkg/FactorAnalytics/R/plot.sfm.r
===================================================================
--- pkg/FactorAnalytics/R/plot.sfm.r 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/R/plot.sfm.r 2015-09-15 06:23:49 UTC (rev 3994)
@@ -82,9 +82,6 @@
#' in \code{plot}. Default is 1.
#' @param lwd set the line width, same as in \code{\link{plot}}. Default is 2.
#' @param maxlag optional number of lags to be calculated for ACF. Default is 15.
-#' @param VaR.method a method for computing VaR; one of "modified", "gaussian",
-#' "historical" or "kernel". VaR is computed using
-#' \code{\link[PerformanceAnalytics]{VaR}}. Default is "historical".
#' @param eig.max scalar in (0,1] for limiting the screeplot to factors that
#' explain a given percent of the variance. Default is 0.9.
#' @param cum.var logical; If \code{TRUE}, the cumulative fraction of the
@@ -149,7 +146,7 @@
"goldenrod","mediumorchid","deepskyblue",
"chocolate","darkslategray"),
legend.loc="topleft", las=1, lwd=2, maxlag=15,
- VaR.method="historical", eig.max=0.9, cum.var=TRUE, ...) {
+ eig.max=0.9, cum.var=TRUE, ...) {
which.vec <- which
which <- which[1]
@@ -458,7 +455,7 @@
},
"10L" = {
## Factor Percentage Contribution to ES
- pcES.fm <- fmEsDecomp(x, method=VaR.method)$pcES[a.sub,c(f.sub,k+1)]
+ pcES.fm <- fmEsDecomp(x)$pcES[a.sub,c(f.sub,k+1)]
plot(
barchart(pcES.fm, main="Factor % Contribution to ES", xlab="",
auto.key=list(space="bottom",columns=3, points=FALSE,rectangles=TRUE),
@@ -469,7 +466,7 @@
},
"11L" = {
## Factor Percentage Contribution to VaR
- pcVaR.fm <- fmVaRDecomp(x, method=VaR.method)$pcVaR[a.sub,c(f.sub,k+1)]
+ pcVaR.fm <- fmVaRDecomp(x)$pcVaR[a.sub,c(f.sub,k+1)]
plot(
barchart(pcVaR.fm, main="Factor % Contribution to VaR", xlab="",
auto.key=list(space="bottom",columns=3, points=FALSE,rectangles=TRUE),
Modified: pkg/FactorAnalytics/R/plot.tsfm.r
===================================================================
--- pkg/FactorAnalytics/R/plot.tsfm.r 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/R/plot.tsfm.r 2015-09-15 06:23:49 UTC (rev 3994)
@@ -92,9 +92,6 @@
#' in \code{plot}. Default is 1.
#' @param lwd set the line width, same as in \code{\link{plot}}. Default is 2.
#' @param maxlag optional number of lags to be calculated for ACF. Default is 15.
-#' @param VaR.method a method for computing VaR; one of "modified", "gaussian",
-#' "historical" or "kernel". VaR is computed using
-#' \code{\link[PerformanceAnalytics]{VaR}}. Default is "historical".
#' @param ... further arguments to be passed to other plotting functions.
#'
#' @author Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
@@ -151,8 +148,7 @@
colorset=c("royalblue","dimgray","olivedrab","firebrick",
"goldenrod","mediumorchid","deepskyblue",
"chocolate","darkslategray"),
- legend.loc="topleft", las=1, lwd=2, maxlag=15,
- VaR.method="historical", ...) {
+ legend.loc="topleft", las=1, lwd=2, maxlag=15, ...) {
which.vec <- which
which <- which[1]
@@ -508,7 +504,7 @@
},
"10L"={
## Factor percentage contribution to ES
- pcES.fm <- fmEsDecomp(x, method=VaR.method)$pcES[a.sub,c(f.sub,k+1)]
+ pcES.fm <- fmEsDecomp(x)$pcES[a.sub,c(f.sub,k+1)]
plot(
barchart(pcES.fm, main="Factor % Contribution to ES", xlab="",
auto.key=list(space="bottom",columns=3,points=FALSE,rectangles=TRUE),
@@ -518,7 +514,7 @@
},
"11L" ={
## Factor percentage contribution to VaR
- pcVaR.fm <- fmVaRDecomp(x, method=VaR.method)$pcVaR[a.sub,c(f.sub,k+1)]
+ pcVaR.fm <- fmVaRDecomp(x)$pcVaR[a.sub,c(f.sub,k+1)]
plot(
barchart(pcVaR.fm, main="Factor % Contribution to VaR", xlab="",
auto.key=list(space="bottom",columns=3,points=FALSE,rectangles=TRUE),
Modified: pkg/FactorAnalytics/R/zzz.R
===================================================================
--- pkg/FactorAnalytics/R/zzz.R 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/R/zzz.R 2015-09-15 06:23:49 UTC (rev 3994)
@@ -2,7 +2,7 @@
#' @import zoo
#' @import foreach
-#' @importFrom PerformanceAnalytics checkData VaR Return.cumulative
+#' @importFrom PerformanceAnalytics checkData Return.cumulative
#' @importFrom robust lmRob step.lmRob
#' @importFrom leaps regsubsets
#' @importFrom lars lars cv.lars
Modified: pkg/FactorAnalytics/man/fmEsDecomp.Rd
===================================================================
--- pkg/FactorAnalytics/man/fmEsDecomp.Rd 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/man/fmEsDecomp.Rd 2015-09-15 06:23:49 UTC (rev 3994)
@@ -8,25 +8,16 @@
\usage{
fmEsDecomp(object, ...)
-\method{fmEsDecomp}{tsfm}(object, p = 0.95, method = c("modified",
- "gaussian", "historical", "kernel"), invert = FALSE, ...)
+\method{fmEsDecomp}{tsfm}(object, p = 0.95, ...)
-\method{fmEsDecomp}{sfm}(object, p = 0.95, method = c("modified",
- "gaussian", "historical", "kernel"), invert = FALSE, ...)
+\method{fmEsDecomp}{sfm}(object, p = 0.95, ...)
}
\arguments{
\item{object}{fit object of class \code{tsfm}, \code{sfm} or \code{ffm}.}
-\item{...}{other optional arguments passed to
-\code{\link[PerformanceAnalytics]{VaR}}.}
+\item{...}{other optional arguments passed to \code{\link[stats]{quantile}}.}
\item{p}{confidence level for calculation. Default is 0.95.}
-
-\item{method}{method for computing VaR, one of "modified","gaussian",
-"historical", "kernel". Default is "modified". See details.}
-
-\item{invert}{logical; whether to invert the VaR measure. Default is
-\code{FALSE}.}
}
\value{
A list containing
@@ -44,8 +35,8 @@
Expected Shortfall (ES) of assets' returns based on Euler's theorem, given
the fitted factor model. The partial derivative of ES with respect to factor
beta is computed as the expected factor return given fund return is less
-than or equal to its value-at-risk (VaR). VaR is computed as the sample quantile of the historic or
-simulated data.
+than or equal to its value-at-risk (VaR). VaR is computed as the sample
+quantile.
}
\details{
The factor model for an asset's return at time \code{t} has the
@@ -59,12 +50,6 @@
defined as the expected value of \code{F.star}, conditional on the loss
being less than or equal to \code{VaR.fm}. This is estimated as a sample
average of the observations in that data window.
-
-Computation of the VaR measure is done using
-\code{\link[PerformanceAnalytics]{VaR}}. Arguments \code{p}, \code{method}
-and \code{invert} are passed to this function. Refer to their help file for
-details and other options. \code{invert} consistently affects the sign for
-all VaR and ES measures.
}
\examples{
# Time Series Factor Model
@@ -102,7 +87,6 @@
\code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
for the different factor model fitting functions.
-\code{\link[PerformanceAnalytics]{VaR}} for VaR computation.
\code{\link{fmSdDecomp}} for factor model SD decomposition.
\code{\link{fmVaRDecomp}} for factor model VaR decomposition.
}
Modified: pkg/FactorAnalytics/man/fmVaRDecomp.Rd
===================================================================
--- pkg/FactorAnalytics/man/fmVaRDecomp.Rd 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/man/fmVaRDecomp.Rd 2015-09-15 06:23:49 UTC (rev 3994)
@@ -8,25 +8,16 @@
\usage{
fmVaRDecomp(object, ...)
-\method{fmVaRDecomp}{tsfm}(object, p = 0.95, method = c("modified",
- "gaussian", "historical", "kernel"), invert = FALSE, ...)
+\method{fmVaRDecomp}{tsfm}(object, p = 0.95, ...)
-\method{fmVaRDecomp}{sfm}(object, p = 0.95, method = c("modified",
- "gaussian", "historical", "kernel"), invert = FALSE, ...)
+\method{fmVaRDecomp}{sfm}(object, p = 0.95, ...)
}
\arguments{
\item{object}{fit object of class \code{tsfm}, \code{sfm} or \code{ffm}.}
-\item{...}{other optional arguments passed to
-\code{\link[PerformanceAnalytics]{VaR}}.}
+\item{...}{other optional arguments passed to \code{\link[stats]{quantile}}.}
\item{p}{confidence level for calculation. Default is 0.95.}
-
-\item{method}{method for computing VaR, one of "modified","gaussian",
-"historical", "kernel". Default is "modified". See details.}
-
-\item{invert}{logical; whether to invert the VaR measure. Default is
-\code{FALSE}.}
}
\value{
A list containing
@@ -44,8 +35,7 @@
assets' returns based on Euler's theorem, given the fitted factor model.
The partial derivative of VaR wrt factor beta is computed as the expected
factor return given fund return is equal to its VaR and approximated by a
-kernel estimator. VaR is computed either as the sample quantile or as an
-estimated quantile using the Cornish-Fisher expansion.
+kernel estimator. VaR is computed as the sample quantile.
}
\details{
The factor model for an asset's return at time \code{t} has the
@@ -59,11 +49,6 @@
is defined as the expectation of \code{F.star}, conditional on the loss
being equal to \code{VaR.fm}. This is approximated as described in
Epperlein & Smillie (2006); a triangular smoothing kernel is used here.
-
-Computation of the risk measure is done using
-\code{\link[PerformanceAnalytics]{VaR}}. Arguments \code{p}, \code{method}
-and \code{invert} are passed to this function. Refer to their help file for
-details and other options.
}
\examples{
# Time Series Factor Model
@@ -99,7 +84,6 @@
\code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
for the different factor model fitting functions.
-\code{\link[PerformanceAnalytics]{VaR}} for VaR computation.
\code{\link{fmSdDecomp}} for factor model SD decomposition.
\code{\link{fmEsDecomp}} for factor model ES decomposition.
}
Modified: pkg/FactorAnalytics/man/plot.sfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/plot.sfm.Rd 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/man/plot.sfm.Rd 2015-09-15 06:23:49 UTC (rev 3994)
@@ -8,8 +8,7 @@
plot.single = FALSE, asset.name, colorset = c("royalblue", "dimgray",
"olivedrab", "firebrick", "goldenrod", "mediumorchid", "deepskyblue",
"chocolate", "darkslategray"), legend.loc = "topleft", las = 1, lwd = 2,
- maxlag = 15, VaR.method = "historical", eig.max = 0.9, cum.var = TRUE,
- ...)
+ maxlag = 15, eig.max = 0.9, cum.var = TRUE, ...)
}
\arguments{
\item{x}{an object of class \code{sfm} produced by \code{fitSfm}.}
@@ -84,10 +83,6 @@
\item{maxlag}{optional number of lags to be calculated for ACF. Default is 15.}
-\item{VaR.method}{a method for computing VaR; one of "modified", "gaussian",
-"historical" or "kernel". VaR is computed using
-\code{\link[PerformanceAnalytics]{VaR}}. Default is "historical".}
-
\item{eig.max}{scalar in (0,1] for limiting the screeplot to factors that
explain a given percent of the variance. Default is 0.9.}
Modified: pkg/FactorAnalytics/man/plot.tsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/plot.tsfm.Rd 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/man/plot.tsfm.Rd 2015-09-15 06:23:49 UTC (rev 3994)
@@ -8,7 +8,7 @@
plot.single = FALSE, asset.name, colorset = c("royalblue", "dimgray",
"olivedrab", "firebrick", "goldenrod", "mediumorchid", "deepskyblue",
"chocolate", "darkslategray"), legend.loc = "topleft", las = 1, lwd = 2,
- maxlag = 15, VaR.method = "historical", ...)
+ maxlag = 15, ...)
}
\arguments{
\item{x}{an object of class \code{tsfm} produced by \code{fitTsfm}.}
@@ -80,10 +80,6 @@
\item{maxlag}{optional number of lags to be calculated for ACF. Default is 15.}
-\item{VaR.method}{a method for computing VaR; one of "modified", "gaussian",
-"historical" or "kernel". VaR is computed using
-\code{\link[PerformanceAnalytics]{VaR}}. Default is "historical".}
-
\item{...}{further arguments to be passed to other plotting functions.}
}
\description{
Modified: pkg/FactorAnalytics/vignettes/fitSfm_vignette.R
===================================================================
--- pkg/FactorAnalytics/vignettes/fitSfm_vignette.R 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/vignettes/fitSfm_vignette.R 2015-09-15 06:23:49 UTC (rev 3994)
@@ -170,7 +170,7 @@
plot(fit.pca, which=9, f.sub=1:2, a.sub=1:15)
## ----fig.cap="Percentage factor contribution to VaR", fig.width=7, fig.height=5----
-decomp1 <- fmVaRDecomp(fit.apca, method="historical")
+decomp1 <- fmVaRDecomp(fit.apca)
names(decomp1)
# factor model Value-at-Risk; print first 6 assets
head(decomp1$VaR.fm)
@@ -180,7 +180,7 @@
plot(fit.apca, which=11, f.sub=1:4, a.sub=1:6)
## ----fig.cap="Percentage factor contribution to ES", fig.width=7, fig.height=5----
-decomp2 <- fmEsDecomp(fit.apca, method="historical")
+decomp2 <- fmEsDecomp(fit.apca)
names(decomp2)
# factor model Expected Shortfall; print first 6 assets
head(decomp2$ES.fm)
@@ -195,8 +195,8 @@
## plot.single=FALSE, asset.name,
## colorset=c("royalblue","firebrick","olivedrab","firebrick","goldenrod",
## "mediumorchid","deepskyblue","chocolate","darkslategray"),
-## legend.loc="topleft", las=1, lwd=2, maxlag=15,
-## VaR.method="historical", eig.max=0.9, cum.var=TRUE, ...)
+## legend.loc="topleft", las=1, lwd=2, maxlag=15, eig.max=0.9,
+## cum.var=TRUE, ...)
## ----eval=FALSE, results='hide'------------------------------------------
## plot(fit.pca)
Modified: pkg/FactorAnalytics/vignettes/fitSfm_vignette.Rnw
===================================================================
--- pkg/FactorAnalytics/vignettes/fitSfm_vignette.Rnw 2015-09-14 23:00:02 UTC (rev 3993)
+++ pkg/FactorAnalytics/vignettes/fitSfm_vignette.Rnw 2015-09-15 06:23:49 UTC (rev 3994)
@@ -65,9 +65,9 @@
\item \verb"fmSdDecomp(object, use, ...)": Returns a list containing the standard deviation of asset returns based on the fitted factor model and the marginal, component and percentage component factor contributions estimated from the given sample. \code{"use"} specifies how missing values are to be handled.
-\item \verb"fmVaRDecomp(object, p, method, invert, ...)": Returns a list containing the value-at-risk for asset returns based on the fitted factor model and the marginal, component and percentage component factor contributions estimated from the given sample. \code{"p"} and \code{"method"} specify the confidence level and method (one of "modified","gaussian", "historical" or "kernel") to calculate VaR. VaR is by default a positive quantity and specifying \code{"invert=TRUE"} allows the VaR value to be expressed as a negative quantity. These 3 arguments, \code{"p"}, \code{"method"} and \code{"invert"} are passed on to the \code{VaR} function in the \code{PerformanceAnalytics} package to calculate VaR.
+\item \verb"fmVaRDecomp(object, p, ...)": Returns a list containing the value-at-risk for asset returns based on the fitted factor model and the marginal, component and percentage component factor contributions estimated from the given sample. VaR is computed as the sample quantile and \code{"p"} specifies the confidence level.
-\item \verb"fmEsDecomp(object, p, method, invert, ...)": Returns a list containing the expected shortfall for asset returns based on the fitted factor model and the marginal, component and percentage component factor contributions estimated from the given sample. Arguments \code{"p"}, \code{"method"} and \code{invert} are the same as above.
+\item \verb"fmEsDecomp(object, p, ...)": Returns a list containing the expected shortfall for asset returns based on the fitted factor model and the marginal, component and percentage component factor contributions estimated from the given sample.
\item \verb"plot(x)": The \code{plot} method for class "sfm" can be used for plotting factor model characteristics of a group of assets (default) or an individual asset. The user can select the type of plot either from the menu prompt or directly via argument \code{which}. In case multiple plots are needed, the menu is repeated after each plot (enter 0 to exit). User can also input a numeric vector of plot options via \code{which}.
@@ -415,12 +415,12 @@
VaR.fm_i = \sum_{k=1}^{K+1} cVaR_{i,k} = \sum_{k=1}^{K+1} \beta^*_{i,k} \: mVaR_{i,k}
\end{equation}
-The marginal contribution to $VaR.fm$ is defined as the expectation of $F.star$, conditional on the loss being equal to $VaR.fm$. This is approximated as described in \citet{epperlein2006portfolio} using a triangular smoothing kernel. $VaR.fm$ calculation is performed using the function \code{VaR} from the \verb"PerformanceAnalytics" package. Refer to their help file for details and more options.
+The marginal contribution to $VaR.fm$ is defined as the expectation of $F.star$, conditional on the loss being equal to $VaR.fm$. This is approximated as described in \citet{epperlein2006portfolio} using a triangular smoothing kernel. $VaR.fm$ is calculated as the sample quantile.
\code{fmVaRDecomp} performs this decomposition for all assets in the given factor model fit object as shown below. The total VaR and component, marginal and percentage component contributions for each asset are returned.
<<fig.cap="Percentage factor contribution to VaR", fig.width=7, fig.height=5>>=
-decomp1 <- fmVaRDecomp(fit.apca, method="historical")
+decomp1 <- fmVaRDecomp(fit.apca)
names(decomp1)
# factor model Value-at-Risk; print first 6 assets
head(decomp1$VaR.fm)
@@ -437,12 +437,12 @@
ES.fm_i = \sum_{k=1}^{K+1} cES_{i,k} = \sum_{k=1}^{K+1} \beta^*_{i,k} \: mES_{i,k}
\end{equation}
-The marginal contribution to $ES.fm$ is defined as the expectation of $F.star$, conditional on the loss being less than or equal to $VaR.fm$. This is estimated as a sample average of the observations in that data window. Once again, $VaR.fm$ calculation is performed using the function \code{VaR} from the \verb"PerformanceAnalytics" package. Refer to their help file for details and more options.
+The marginal contribution to $ES.fm$ is defined as the expectation of $F.star$, conditional on the loss being less than or equal to $VaR.fm$. This is estimated as a sample average of the observations in that data window. Once again, $VaR.fm$ is the sample quantile.
-\code{fmEsDecomp} performs this decomposition for all assets in the given factor model fit object as shown below. In this example, \code{method} to calculate VaR is "historical" instead of the default "modified". The total ES and component, marginal and percentage component contributions for each asset are returned.
+\code{fmEsDecomp} performs this decomposition for all assets in the given factor model fit object as shown below. The total ES and component, marginal and percentage component contributions for each asset are returned.
<<fig.cap="Percentage factor contribution to ES", fig.width=7, fig.height=5>>=
-decomp2 <- fmEsDecomp(fit.apca, method="historical")
+decomp2 <- fmEsDecomp(fit.apca)
names(decomp2)
# factor model Expected Shortfall; print first 6 assets
head(decomp2$ES.fm)
@@ -462,8 +462,8 @@
plot.single=FALSE, asset.name,
colorset=c("royalblue","firebrick","olivedrab","firebrick","goldenrod",
"mediumorchid","deepskyblue","chocolate","darkslategray"),
- legend.loc="topleft", las=1, lwd=2, maxlag=15,
- VaR.method="historical", eig.max=0.9, cum.var=TRUE, ...)
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/returnanalytics -r 3994
More information about the Returnanalytics-commits
mailing list