[Returnanalytics-commits] r3058 - in pkg/FactorAnalytics: sandbox sandbox/Man sandbox/R vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 11 19:20:10 CEST 2013


Author: chenyian
Date: 2013-09-11 19:20:09 +0200 (Wed, 11 Sep 2013)
New Revision: 3058

Added:
   pkg/FactorAnalytics/sandbox/Man/
   pkg/FactorAnalytics/sandbox/Man/Style.Rd
   pkg/FactorAnalytics/sandbox/Man/chart.Style.Rd
   pkg/FactorAnalytics/sandbox/Man/covEWMA.Rd
   pkg/FactorAnalytics/sandbox/Man/impliedFactorReturns.Rd
   pkg/FactorAnalytics/sandbox/Man/modifiedEsReport.Rd
   pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalES.Rd
   pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalVaR.Rd
   pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioEsDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioVaRDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/modifiedVaRReport.Rd
   pkg/FactorAnalytics/sandbox/Man/nonparametricEsReport.Rd
   pkg/FactorAnalytics/sandbox/Man/nonparametricIncrementalES.Rd
   pkg/FactorAnalytics/sandbox/Man/nonparametricIncrementalVaR.Rd
   pkg/FactorAnalytics/sandbox/Man/nonparametricPortfolioEsDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/nonparametricPortfolioVaRDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/nonparametricVaRReport.Rd
   pkg/FactorAnalytics/sandbox/Man/normalEsReport.Rd
   pkg/FactorAnalytics/sandbox/Man/normalIncrementalES.Rd
   pkg/FactorAnalytics/sandbox/Man/normalIncrementalVaR.Rd
   pkg/FactorAnalytics/sandbox/Man/normalPortfolioEsDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/normalPortfolioVaRDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/normalVaRReport.Rd
   pkg/FactorAnalytics/sandbox/Man/portfolioSdDecomposition.Rd
   pkg/FactorAnalytics/sandbox/Man/scenarioPredictions.Rd
   pkg/FactorAnalytics/sandbox/Man/scenarioPredictionsPortfolio.Rd
   pkg/FactorAnalytics/sandbox/R/
   pkg/FactorAnalytics/sandbox/R/FactorAnalytics-package.R
   pkg/FactorAnalytics/sandbox/R/bootstrapFactorESdecomposition.r
   pkg/FactorAnalytics/sandbox/R/bootstrapFactorVaRdecomposition.r
   pkg/FactorAnalytics/sandbox/R/chart.RollingStyle.R
   pkg/FactorAnalytics/sandbox/R/chart.Style.R
   pkg/FactorAnalytics/sandbox/R/covEWMA.R
   pkg/FactorAnalytics/sandbox/R/factorModelFactorRiskDecomposition.r
   pkg/FactorAnalytics/sandbox/R/factorModelGroupRiskDecomposition.r
   pkg/FactorAnalytics/sandbox/R/factorModelPortfolioRiskDecomposition.r
   pkg/FactorAnalytics/sandbox/R/factorModelRiskAttribution.r
   pkg/FactorAnalytics/sandbox/R/factorModelRiskDecomposition.r
   pkg/FactorAnalytics/sandbox/R/factorModelSimulation.r
   pkg/FactorAnalytics/sandbox/R/impliedFactorReturns.R
   pkg/FactorAnalytics/sandbox/R/modifiedEsReport.R
   pkg/FactorAnalytics/sandbox/R/modifiedIncrementalES.R
   pkg/FactorAnalytics/sandbox/R/modifiedIncrementalVaR.R
   pkg/FactorAnalytics/sandbox/R/modifiedPortfolioEsDecomposition.R
   pkg/FactorAnalytics/sandbox/R/modifiedPortfolioVaRDecomposition.R
   pkg/FactorAnalytics/sandbox/R/modifiedVaRReport.R
   pkg/FactorAnalytics/sandbox/R/nonparametricEsReport.R
   pkg/FactorAnalytics/sandbox/R/nonparametricIncrementalES.R
   pkg/FactorAnalytics/sandbox/R/nonparametricIncrementalVaR.R
   pkg/FactorAnalytics/sandbox/R/nonparametricPortfolioEsDecomposition.R
   pkg/FactorAnalytics/sandbox/R/nonparametricPortfolioVaRDecomposition.R
   pkg/FactorAnalytics/sandbox/R/nonparametricVaRReport.R
   pkg/FactorAnalytics/sandbox/R/normalEsReport.R
   pkg/FactorAnalytics/sandbox/R/normalIncrementalES.R
   pkg/FactorAnalytics/sandbox/R/normalIncrementalVaR.R
   pkg/FactorAnalytics/sandbox/R/normalPortfolioEsDecomposition.R
   pkg/FactorAnalytics/sandbox/R/normalPortfolioVaRDecomposition.R
   pkg/FactorAnalytics/sandbox/R/normalVaRReport.R
   pkg/FactorAnalytics/sandbox/R/portfolioSdDecomposition.R
   pkg/FactorAnalytics/sandbox/R/scenarioPredictions.r
   pkg/FactorAnalytics/sandbox/R/scenarioPredictionsPortfolio.r
   pkg/FactorAnalytics/sandbox/R/style.QPfit.R
   pkg/FactorAnalytics/sandbox/R/style.fit.R
   pkg/FactorAnalytics/sandbox/R/table.RollingStyle.R
   pkg/FactorAnalytics/sandbox/example.menu.plot.r
   pkg/FactorAnalytics/sandbox/getCommomFactor.r
   pkg/FactorAnalytics/sandbox/plotFactorModelFit.r
   pkg/FactorAnalytics/sandbox/test.vignette.r
   pkg/FactorAnalytics/sandbox/testfile.r
Modified:
   pkg/FactorAnalytics/vignettes/fundamentalFM.Rnw
Log:
add unused function to sandbox file and upload to r-forge. 

Added: pkg/FactorAnalytics/sandbox/Man/Style.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/Style.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/Style.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,104 @@
+\name{chart.Style}
+\alias{chart.Style}
+\alias{chart.RollingStyle}
+\alias{table.RollingStyle}
+\alias{style.fit}
+\alias{style.QPfit}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{ calculate and display effective style weights }
+\description{
+  Functions that calculate effective style weights and display the results in a bar chart.  \code{chart.Style} calculates and displays style weights calculated over a single period.  \code{chart.RollingStyle} calculates and displays those weights in rolling windows through time.  \code{style.fit} manages the calculation of the weights by method.  \code{style.QPfit} calculates the specific constraint case that requires quadratic programming. 
+}
+\usage{
+chart.Style(R.fund, R.style, method = c("constrained", "unconstrained", "normalized"), leverage = FALSE, main = NULL, ylim = NULL, unstacked=TRUE, ...)
+
+chart.RollingStyle(R.fund, R.style, method = c("constrained","unconstrained","normalized"), leverage = FALSE, width = 12, main = NULL, space = 0, ...)
+
+style.fit(R.fund, R.style, model=FALSE, method = c("constrained", "unconstrained", "normalized"), leverage = FALSE, selection = c("none", "AIC"), ...)
+
+style.QPfit(R.fund, R.style, model = FALSE, leverage = FALSE, ...)
+
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{R.fund}{ matrix, data frame, or zoo object with fund returns to be analyzed }
+  \item{R.style}{ matrix, data frame, or zoo object with style index returns.  Data object must be of the same length and time-aligned with R.fund }
+  \item{method}{ specify the method of calculation of style weights as "constrained", "unconstrained", or "normalized".  For more information, see \code{\link{style.fit}} }
+  \item{leverage}{ logical, defaults to 'FALSE'.  If 'TRUE', the calculation of weights assumes that leverage may be used.  For more information, see \code{\link{style.fit}} }
+  \item{model}{ logical. If 'model' = TRUE in \code{\link{style.QPfit}}, the full result set is shown from the output of \code{solve.QP}. }
+  \item{selection}{ either "none" (default) or "AIC".  If "AIC", then the function uses a stepwise regression to identify find the model with minimum AIC value.  See \code{\link{step}} for more detail.}
+  \item{unstacked}{ logical.  If set to 'TRUE' \emph{and} only one row of data is submitted in 'w', then the chart creates a normal column chart.  If more than one row is submitted, then this is ignored.  See examples below. }
+  \item{space}{ the amount of space (as a fraction of the average bar width) left before each bar, as in \code{\link{barplot}}. Default for \code{chart.RollingStyle} is 0; for \code{chart.Style} the default is 0.2. }
+  \item{main}{ set the chart title, same as in \code{\link{plot}} }
+  \item{width}{ number of periods or window to apply rolling style analysis over }
+  \item{ylim}{ set the y-axis limit, same as in \code{\link{plot}} }
+  \item{\dots}{ for the charting functions, these are arguments to be passed to \code{\link{barplot}}. These can include further arguments (such as 'axes', 'asp' and 'main') and graphical parameters (see 'par') which are passed to 'plot.window()', 'title()' and 'axis'. For the calculation functions, these are ignored. }
+}
+\details{
+These functions calculate style weights using an asset class style model as described in detail in Sharpe (1992).  The use of quadratic programming to determine a fund's exposures to the changes in returns of major asset classes is usually refered to as "style analysis".
+
+The "unconstrained" method implements a simple factor model for style analysis, as in:
+\deqn{Ri = bi1*F1+bi2*F2+...+bin*Fn+ei}{R_i = b_{i1}F_1+b_{i2}F_2+\dots+b_{in}F_n +e_i}
+where \eqn{Ri}{R_i} represents the return on asset i, \eqn{Fj}{F_j} represents each factor, and \eqn{ei}{e_i} represents the "non-factor" component of the return on i.  This is simply a multiple regression analysis with fund returns as the dependent variable and asset class returns as the independent variables.  The resulting slope coefficients are then interpreted as the fund's historic exposures to asset class returns.  In this case, coefficients do not sum to 1.
+
+The "normalized" method reports the results of a multiple regression analysis similar to the first, but with one constraint: the coefficients are required to add to 1.  Coefficients may be negative, indicating short exposures. To enforce the constraint, coefficients are normalized.
+
+The "constrained" method includes the constraint that the coefficients sum to 1, but adds 
+that the coefficients must lie between 0 and 1. These inequality constraints require a 
+quadratic programming algorithm using \code{\link[quadprog]{solve.QP}} from the 'quadprog' package, 
+and the implementation is discussed under \code{\link{style.QPfit}}.  If set to TRUE, 
+"leverage" allows the sum of the coefficients to exceed 1. 
+
+According to Sharpe (1992), the calculation for the constrained case is represented as:
+\deqn{min var(Rf - sum[wi * R.si]) = min var(F - w*S)}{min \sigma(R_f - \sum{w_i * R_s_i}) = min \sigma(F - w*S)}
+\deqn{s.t. sum[wi] = 1; wi > 0}{  s.t. \sum{w_i} = 1; w_i > 0}
+
+Remembering that:
+
+\deqn{\sigma(aX + bY) = a^2 \sigma(X) + b^2 \sigma(Y) + 2ab cov(X,Y) = \sigma(R.f) + w'*V*w - 2*w'*cov(R.f,R.s)}
+
+we can drop \eqn{var(Rf)}{\sigma(R_f)} as it isn't a function of weights, multiply both sides by 1/2:
+
+\deqn{= min (1/2) w'*V*w - C'w}{= min (1/2) w'*V*w - C'w}
+\deqn{  s.t. w'*e = 1, w_i > 0}{  s.t. w'*e = 1, w_i > 0}
+
+Which allows us to use \code{\link[quadprog]{solve.QP}}, which is specified as:
+\deqn{min(-d' b + 1/2 b' D b)}{min(-d' b + 1/2 b' D b)}
+and the constraints
+\deqn{ A' b >= b.0 }{ A' b >= b_0 }
+
+so:
+b is the weight vector,
+D is the variance-covariance matrix of the styles
+d is the covariance vector between the fund and the styles
+
+The chart functions then provide a graphical summary of the results.  The underlying 
+function, \code{\link{style.fit}}, provides the outputs of the analysis and more 
+information about fit, including an R-squared value.
+
+Styles identified in this analysis may be interpreted as an average of potentially 
+changing exposures over the period covered.  The function \code{\link{chart.RollingStyle}} 
+may be useful for examining the behavior of a manager's average exposures to asset classes over time, using a rolling-window analysis.
+
+  The chart functions plot a column chart or stacked column chart of the resulting style weights to the current device.  Both \code{style.fit} and \code{style.QPfit} produce a list of data frames containing 'weights' and 'R.squared' results.   If 'model' = TRUE in \code{style.QPfit}, the full result set is shown from the output of \code{solve.QP}.
+}
+\references{ 
+Sharpe, W. Asset Allocation: Management Style and Performance Measurement Journal of Portfolio Management, 1992, 7-19.  See \url{ http://www.stanford.edu/~wfsharpe/art/sa/sa.htm}
+ }
+\author{ Peter Carl }
+\note{ 
+  None of the functions \code{chart.Style}, \code{style.fit}, and \code{style.QPfit} make any attempt to align the two input data series. The \code{chart.RollingStyle}, on the other hand, does merge the two series and manages the calculation over common periods.  
+}
+\seealso{ \code{\link{barplot}}, \code{\link{par}} }
+\examples{
+data(edhec)
+data(managers)
+style.fit(managers[97:132,2,drop=FALSE],edhec[85:120,], method="constrained", leverage=FALSE)
+chart.Style(managers[97:132,2,drop=FALSE],edhec[85:120,], method="constrained", leverage=FALSE, unstack=TRUE, las=3)
+chart.RollingStyle(managers[,2,drop=FALSE],edhec[,1:11], method="constrained", leverage=FALSE, width=36, cex.legend = .7, colorset=rainbow12equal, las=1)
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ ts }
+\keyword{ multivariate }
+\keyword{ hplot }

Added: pkg/FactorAnalytics/sandbox/Man/chart.Style.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/chart.Style.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/chart.Style.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,191 @@
+\name{chart.Style}
+\alias{chart.RollingStyle}
+\alias{chart.Style}
+\alias{style.fit}
+\alias{style.QPfit}
+\alias{table.RollingStyle}
+\title{calculate and display effective style weights}
+\usage{
+  chart.Style(R.fund, R.style,
+    method = c("constrained", "unconstrained", "normalized"),
+    leverage = FALSE, main = NULL, ylim = NULL,
+    unstacked = TRUE, ...)
+}
+\arguments{
+  \item{R.fund}{matrix, data frame, or zoo object with fund
+  returns to be analyzed}
+
+  \item{R.style}{matrix, data frame, or zoo object with
+  style index returns. Data object must be of the same
+  length and time-aligned with R.fund}
+
+  \item{method}{specify the method of calculation of style
+  weights as "constrained", "unconstrained", or
+  "normalized".  For more information, see
+  \code{\link{style.fit}}}
+
+  \item{leverage}{logical, defaults to 'FALSE'.  If 'TRUE',
+  the calculation of weights assumes that leverage may be
+  used.  For more information, see \code{\link{style.fit}}}
+
+  \item{model}{logical. If 'model' = TRUE in
+  \code{\link{style.QPfit}}, the full result set is shown
+  from the output of \code{solve.QP}.}
+
+  \item{selection}{either "none" (default) or "AIC".  If
+  "AIC", then the function uses a stepwise regression to
+  identify find the model with minimum AIC value.  See
+  \code{\link{step}} for more detail.}
+
+  \item{unstacked}{logical.  If set to 'TRUE' \emph{and}
+  only one row of data is submitted in 'w', then the chart
+  creates a normal column chart.  If more than one row is
+  submitted, then this is ignored.  See examples below.}
+
+  \item{space}{the amount of space (as a fraction of the
+  average bar width) left before each bar, as in
+  \code{\link{barplot}}. Default for
+  \code{chart.RollingStyle} is 0; for \code{chart.Style}
+  the default is 0.2.}
+
+  \item{main}{set the chart title, same as in
+  \code{\link{plot}}}
+
+  \item{width}{number of periods or window to apply rolling
+  style analysis over}
+
+  \item{ylim}{set the y-axis limit, same as in
+  \code{\link{plot}}}
+
+  \item{\dots}{for the charting functions, these are
+  arguments to be passed to \code{\link{barplot}}. These
+  can include further arguments (such as 'axes', 'asp' and
+  'main') and graphical parameters (see 'par') which are
+  passed to 'plot.window()', 'title()' and 'axis'. For the
+  calculation functions, these are ignored.}
+}
+\description{
+  Functions that calculate effective style weights and
+  display the results in a bar chart.  \code{chart.Style}
+  calculates and displays style weights calculated over a
+  single period.  \code{chart.RollingStyle} calculates and
+  displays those weights in rolling windows through time.
+  \code{style.fit} manages the calculation of the weights
+  by method.  \code{style.QPfit} calculates the specific
+  constraint case that requires quadratic programming.
+}
+\details{
+  These functions calculate style weights using an asset
+  class style model as described in detail in Sharpe
+  (1992).  The use of quadratic programming to determine a
+  fund's exposures to the changes in returns of major asset
+  classes is usually refered to as "style analysis".
+
+  The "unconstrained" method implements a simple factor
+  model for style analysis, as in: \deqn{Ri =
+  bi1*F1+bi2*F2+...+bin*Fn+ei}{R_i =
+  b_{i1}F_1+b_{i2}F_2+\dots+b_{in}F_n +e_i} where
+  \eqn{Ri}{R_i} represents the return on asset i,
+  \eqn{Fj}{F_j} represents each factor, and \eqn{ei}{e_i}
+  represents the "non-factor" component of the return on i.
+  This is simply a multiple regression analysis with fund
+  returns as the dependent variable and asset class returns
+  as the independent variables.  The resulting slope
+  coefficients are then interpreted as the fund's historic
+  exposures to asset class returns.  In this case,
+  coefficients do not sum to 1.
+
+  The "normalized" method reports the results of a multiple
+  regression analysis similar to the first, but with one
+  constraint: the coefficients are required to add to 1.
+  Coefficients may be negative, indicating short exposures.
+  To enforce the constraint, coefficients are normalized.
+
+  The "constrained" method includes the constraint that the
+  coefficients sum to 1, but adds that the coefficients
+  must lie between 0 and 1. These inequality constraints
+  require a quadratic programming algorithm using
+  \code{\link[quadprog]{solve.QP}} from the 'quadprog'
+  package, and the implementation is discussed under
+  \code{\link{style.QPfit}}.  If set to TRUE, "leverage"
+  allows the sum of the coefficients to exceed 1.
+
+  According to Sharpe (1992), the calculation for the
+  constrained case is represented as: \deqn{min var(Rf -
+  sum[wi * R.si]) = min var(F - w*S)}{min \sigma(R_f -
+  \sum{w_i * R_s_i}) = min \sigma(F - w*S)} \deqn{s.t.
+  sum[wi] = 1; wi > 0}{ s.t. \sum{w_i} = 1; w_i > 0}
+
+  Remembering that:
+
+  \deqn{\sigma(aX + bY) = a^2 \sigma(X) + b^2 \sigma(Y) +
+  2ab cov(X,Y) = \sigma(R.f) + w'*V*w - 2*w'*cov(R.f,R.s)}
+
+  we can drop \eqn{var(Rf)}{\sigma(R_f)} as it isn't a
+  function of weights, multiply both sides by 1/2:
+
+  \deqn{= min (1/2) w'*V*w - C'w}{= min (1/2) w'*V*w - C'w}
+  \deqn{ s.t. w'*e = 1, w_i > 0}{ s.t. w'*e = 1, w_i > 0}
+
+  Which allows us to use \code{\link[quadprog]{solve.QP}},
+  which is specified as: \deqn{min(-d' b + 1/2 b' D
+  b)}{min(-d' b + 1/2 b' D b)} and the constraints \deqn{
+  A' b >= b.0 }{ A' b >= b_0 }
+
+  so: b is the weight vector, D is the variance-covariance
+  matrix of the styles d is the covariance vector between
+  the fund and the styles
+
+  The chart functions then provide a graphical summary of
+  the results.  The underlying function,
+  \code{\link{style.fit}}, provides the outputs of the
+  analysis and more information about fit, including an
+  R-squared value.
+
+  Styles identified in this analysis may be interpreted as
+  an average of potentially changing exposures over the
+  period covered.  The function
+  \code{\link{chart.RollingStyle}} may be useful for
+  examining the behavior of a manager's average exposures
+  to asset classes over time, using a rolling-window
+  analysis.
+
+  The chart functions plot a column chart or stacked column
+  chart of the resulting style weights to the current
+  device.  Both \code{style.fit} and \code{style.QPfit}
+  produce a list of data frames containing 'weights' and
+  'R.squared' results.  If 'model' = TRUE in
+  \code{style.QPfit}, the full result set is shown from the
+  output of \code{solve.QP}.
+}
+\note{
+  None of the functions \code{chart.Style},
+  \code{style.fit}, and \code{style.QPfit} make any attempt
+  to align the two input data series. The
+  \code{chart.RollingStyle}, on the other hand, does merge
+  the two series and manages the calculation over common
+  periods.
+}
+\examples{
+data(edhec)
+data(managers)
+style.fit(managers[97:132,2,drop=FALSE],edhec[85:120,], method="constrained", leverage=FALSE)
+chart.Style(managers[97:132,2,drop=FALSE],edhec[85:120,], method="constrained", leverage=FALSE, unstack=TRUE, las=3)
+chart.RollingStyle(managers[,2,drop=FALSE],edhec[,1:11], method="constrained", leverage=FALSE, width=36, cex.legend = .7, colorset=rainbow12equal, las=1)
+}
+\author{
+  Peter Carl
+}
+\references{
+  Sharpe, W. Asset Allocation: Management Style and
+  Performance Measurement Journal of Portfolio Management,
+  1992, 7-19.  See \url{
+  http://www.stanford.edu/~wfsharpe/art/sa/sa.htm}
+}
+\seealso{
+  \code{\link{barplot}}, \code{\link{par}}
+}
+\keyword{hplot}
+\keyword{multivariate}
+\keyword{ts}
+

Added: pkg/FactorAnalytics/sandbox/Man/covEWMA.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/covEWMA.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/covEWMA.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,49 @@
+\name{covEWMA}
+\alias{covEWMA}
+\title{Compute RiskMetrics-type EWMA Covariance Matrix}
+\usage{
+  covEWMA(factors, lambda = 0.96, return.cor = FALSE)
+}
+\arguments{
+  \item{factors}{\code{T x K} data.frame containing asset
+  returns, where \code{T} is the number of time periods and
+  \code{K} is the number of assets.}
+
+  \item{lambda}{Scalar exponential decay factor. Must lie
+  between between 0 and 1.}
+
+  \item{return.cor}{Logical, if TRUE then return EWMA
+  correlation matrices.}
+}
+\value{
+  \code{T x K x K} array giving the time series of EWMA
+  covariance matrices if \code{return.cor=FALSE} and EWMA
+  correlation matrices if \code{return.cor=TRUE}.
+}
+\description{
+  Compute time series of RiskMetrics-type EWMA covariance
+  matrices of returns. Initial covariance matrix is assumed
+  to be the unconditional covariance matrix.
+}
+\details{
+  The EWMA covariance matrix at time \code{t} is compute as
+  \cr \code{Sigma(t) = lambda*Sigma(t-1) +
+  (1-lambda)*R(t)t(R(t))} \cr where \code{R(t)} is the
+  \code{K x 1} vector of returns at time \code{t}.
+}
+\examples{
+# compute time vaying covariance of factors.
+data(managers.df)
+factors    = managers.df[,(7:9)]
+cov.f.ewma <- covEWMA(factors)
+cov.f.ewma[120,,]
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+\references{
+  Zivot, E. and J. Wang (2006), \emph{Modeling Financial
+  Time Series with S-PLUS, Second Edition},
+  Springer-Verlag.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/impliedFactorReturns.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/impliedFactorReturns.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/impliedFactorReturns.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,53 @@
+\name{impliedFactorReturns}
+\alias{impliedFactorReturns}
+\title{Compute Implied Factor Returns Using Covariance Matrix Approach}
+\usage{
+  impliedFactorReturns(factor.scenarios, mu.factors,
+    cov.factors)
+}
+\arguments{
+  \item{factor.scenarios}{m x 1 vector of scenario values
+  for a subset of the n > m risk factors}
+
+  \item{mu.factors}{\code{n x 1} vector of factor mean
+  returns.}
+
+  \item{cov.factors}{\code{n x n} factor covariance
+  matrix.}
+}
+\value{
+  \code{(n - m) x 1} vector of implied factor returns
+}
+\description{
+  Compute risk factor conditional mean returns for a one
+  group of risk factors given specified returns for another
+  group of risk factors based on the assumption that all
+  risk factor returns are multivariately normally
+  distributed.
+}
+\details{
+  Let \code{y} denote the \code{m x 1} vector of factor
+  scenarios and \code{x} denote the \code{(n-m) x 1} vector
+  of other factors. Assume that \code{(y', x')'} has a
+  multivariate normal distribution with mean \code{(mu.y',
+  mu.x')'} and covariance matrix partitioned as
+  \code{(cov.yy, cov.yx, cov.xy, cov.xx)}. Then the implied
+  factor scenarios are computed as \code{E[x|y] = mu.x +
+  cov.xy*cov.xx^-1 * (y - mu.y)}
+}
+\examples{
+# get data
+data(managers.df)
+factors    = managers.df[,(7:9)]
+# make up a factor mean returns scenario for factor SP500.TR
+factor.scenarios <- 0.1
+names(factor.scenarios) <- "SP500.TR"
+mu.factors <- mean(factors)
+cov.factors <- var(factors)
+# implied factor returns
+impliedFactorReturns(factor.scenarios,mu.factors,cov.factors)
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/modifiedEsReport.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/modifiedEsReport.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/modifiedEsReport.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,71 @@
+\name{modifiedEsReport}
+\alias{modifiedEsReport}
+\title{compute ES report via Cornish-Fisher expansion for collection of assets in a
+portfolio given simulated (bootstrapped) return data.}
+\usage{
+  modifiedEsReport(bootData, w, delta.w = 0.001,
+    tail.prob = 0.01, method = c("derivative", "average"),
+    nav, nav.p, fundStrategy, i1, i2)
+}
+\arguments{
+  \item{bootData}{B x n matrix of B bootstrap returns on
+  assets in portfolio.}
+
+  \item{w}{n x 1 vector of portfolio weights.}
+
+  \item{delta.w}{scalar, change in portfolio weight for
+  computing numerical derivative. Default value is 0.010.}
+
+  \item{tail.prob}{scalar tail probability.}
+
+  \item{method}{character, method for computing marginal
+  ES. Valid choices are "derivative" for numerical
+  computation of the derivative of portfolio ES wrt fund
+  portfolio weight; "average" for approximating E[Ri |
+  Rp<=VaR]}
+
+  \item{nav}{n x 1 vector of net asset values in each
+  fund.}
+
+  \item{nav.p}{scalar, net asset value of portfolio
+  percentage.}
+
+  \item{fundStrategy}{n x 1 vector of fund strategies.}
+
+  \item{i1,i2}{if ff object is used, the ffapply functions
+  do apply an EXPRession and provide two indices FROM="i1"
+  and TO="i2", which mark beginning and end of the batch
+  and can be used in the applied expression.}
+}
+\value{
+  dataframe with the following columns: Strategy n x 1
+  strategy. Net.Asset.value n x 1 net asset values.
+  Allocation n x 1 vector of asset weights. Mean n x 1 mean
+  of each funds. Std.Dev n x 1 standard deviation of each
+  funds.  Assets.ES n x 1 vector of asset specific ES
+  values. cES n x 1 vector of asset specific component ES
+  values. cES.dollar n x 1 vector of asset specific
+  component ES values in dollar terms. pcES n x 1 vector of
+  asset specific percent contribution to ES values. iES n x
+  1 vector of asset specific incremental ES values.
+  iES.dollar n x 1 vector of asset specific component ES
+  values in dollar terms. mES n x 1 vector of asset
+  specific marginal ES values. mES.dollar n x 1 vector of
+  asset specific marginal ES values in dollar terms.
+}
+\description{
+  compute ES report via Cornish-Fisher expansion for
+  collection of assets in a portfolio given simulated
+  (bootstrapped) return data. Report format follows that of
+  Excel VaR report.
+}
+\examples{
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
+modifiedEsReport (bootData= ret.assets[,1:3], w=c(1/3,1/3,1/3), delta.w = 0.001, tail.prob = 0.01,
+                 method="derivative",nav=c(100,200,100), nav.p=500, fundStrategy=c("S1","S2","S3"))
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalES.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalES.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalES.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,44 @@
+\name{modifiedIncrementalES}
+\alias{modifiedIncrementalES}
+\title{Compute incremental ES given bootstrap data and portfolio weights.}
+\usage{
+  modifiedIncrementalES(bootData, w, tail.prob = 0.01, i1,
+    i2)
+}
+\arguments{
+  \item{bootData}{B x N matrix of B bootstrap returns on n
+  assets in portfolio.}
+
+  \item{w}{N x 1 vector of portfolio weights}
+
+  \item{tail.prob}{scalar tail probability.}
+
+  \item{i1,i2}{if ff object is used, the ffapply functions
+  do apply an EXPRession and provide two indices FROM="i1"
+  and TO="i2", which mark beginning and end of the batch
+  and can be used in the applied expression.}
+}
+\value{
+  n x 1 matrix of incremental ES values for each asset.
+}
+\description{
+  Compute incremental ES given bootstrap data and portfolio
+  weights. Incremental ES is defined as the change in
+  portfolio ES that occurs when an asset is removed from
+  the portfolio and allocation is spread equally among
+  remaining assets. VaR used in ES computation is computed
+  as an estimated quantile using the Cornish-Fisher
+  expansion.
+}
+\examples{
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
+modifiedIncrementalES(ret.assets[,1:3],w=c(1/3,1/3,1/3),tail.prob = 0.05)
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+\references{
+  Jorian, P. (2007). Value-at-Risk, pg. 168.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalVaR.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalVaR.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/modifiedIncrementalVaR.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,43 @@
+\name{modifiedIncrementalVaR}
+\alias{modifiedIncrementalVaR}
+\title{Compute incremental VaR given bootstrap data and portfolio weights.}
+\usage{
+  modifiedIncrementalVaR(bootData, w, tail.prob = 0.01, i1,
+    i2)
+}
+\arguments{
+  \item{bootData}{B x N matrix of B bootstrap returns on n
+  assets in portfolio.}
+
+  \item{w}{N x 1 vector of portfolio weights}
+
+  \item{tail.prob}{scalar tail probability.}
+
+  \item{i1,i2}{if ff object is used, the ffapply functions
+  do apply an EXPRession and provide two indices FROM="i1"
+  and TO="i2", which mark beginning and end of the batch
+  and can be used in the applied expression.}
+}
+\value{
+  n x 1 matrix of incremental VaR values for each asset.
+}
+\description{
+  Compute incremental VaR given bootstrap data and
+  portfolio weights. Incremental VaR is defined as the
+  change in portfolio VaR that occurs when an asset is
+  removed from the portfolio and allocation is spread
+  equally among remaining assets. VaR is computed as an
+  estimated quantile using the Cornish-Fisher expansion.
+}
+\examples{
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
+modifiedIncrementalVaR(ret.assets[,1:3],w=c(1/3,1/3,1/3),tail.prob = 0.05)
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+\references{
+  Jorian, P. (2007). Value-at-Risk, pg. 168.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioEsDecomposition.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioEsDecomposition.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioEsDecomposition.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,54 @@
+\name{modifiedPortfolioEsDecomposition}
+\alias{modifiedPortfolioEsDecomposition}
+\title{Compute portfolio ES (risk) decomposition by assets.}
+\usage{
+  modifiedPortfolioEsDecomposition(bootData, w,
+    delta.w = 0.001, tail.prob = 0.01,
+    method = c("derivative", "average"))
+}
+\arguments{
+  \item{bootData}{B x N matrix of B bootstrap returns on
+  assets in portfolio.}
+
+  \item{w}{N x 1 vector of portfolio weights}
+
+  \item{delta.w}{Scalar, change in portfolio weight for
+  computing numerical derivative.}
+
+  \item{tail.prob}{Scalar, tail probability.}
+
+  \item{method}{Character, method for computing marginal
+  ES. Valid choices are "derivative" for numerical
+  computation of the derivative of portfolio ES with
+  respect to fund portfolio weight; "average" for
+  approximating E[R_i | R_p<=VaR].}
+}
+\value{
+  an S3 list containing
+}
+\description{
+  Compute portfolio ES decomposition given historical or
+  simulated data and portfolio weights. Marginal ES is
+  computed either as the numerical derivative of ES with
+  respect to portfolio weight or as the expected fund
+  return given portfolio return is less than or equal to
+  portfolio VaR VaR is compute as an estimated quantile
+  using the Cornish-Fisher expansion.
+}
+\examples{
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
+modifiedPortfolioEsDecomposition(ret.assets[,1:3], w=c(1/3,1/3,1/3), delta.w = 0.001,
+                                  tail.prob = 0.01, method=c("derivative"))
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+\references{
+  1. Hallerback (2003), "Decomposing Portfolio
+  Value-at-Risk: A General Analysis", The Journal of Risk
+  5/2. 2. Yamai and Yoshiba (2002). "Comparative Analyses
+  of Expected Shortfall and Value-at-Risk: Their Estimation
+  Error, Decomposition, and Optimization Bank of Japan.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioVaRDecomposition.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioVaRDecomposition.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/modifiedPortfolioVaRDecomposition.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,57 @@
+\name{modifiedPortfolioVaRDecomposition}
+\alias{modifiedPortfolioVaRDecomposition}
+\title{Compute portfolio VaR decomposition given historical or simulated data and
+portfolio weights.}
+\usage{
+  modifiedPortfolioVaRDecomposition(bootData, w,
+    delta.w = 0.001, tail.prob = 0.01,
+    method = c("derivative", "average"))
+}
+\arguments{
+  \item{bootData}{B x N matrix of B bootstrap returns on
+  assets in portfolio.}
+
+  \item{w}{N x 1 vector of portfolio weights}
+
+  \item{delta.w}{Scalar, change in portfolio weight for
+  computing numerical derivative.}
+
+  \item{tail.prob}{Scalar, tail probability.}
+
+  \item{method}{Character, method for computing marginal
+  ES. Valid choices are "derivative" for numerical
+  computation of the derivative of portfolio ES with
+  respect to fund portfolio weight; "average" for
+  approximating E[R_i | R_p =VaR].}
+}
+\value{
+  an S3 list containing
+}
+\description{
+  Compute portfolio VaR decomposition given historical or
+  simulated data and portfolio weights. 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 kernel estimator. VaR is compute
+  as an estimated quantile using the Cornish-Fisher
+  expansion.
+}
+\examples{
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
+modifiedPortfolioVaRDecomposition(ret.assets[,1:3], w=c(1/3,1/3,1/3), delta.w = 0.001,
+                                  tail.prob = 0.01, method=c("average"))
+}
+\author{
+  Eric Zivot and Yi-An Chen.
+}
+\references{
+  1. Hallerback (2003), "Decomposing Portfolio
+  Value-at-Risk: A General Analysis", The Journal of Risk
+  5/2. 2. Yamai and Yoshiba (2002). "Comparative Analyses
+  of Expected Shortfall and Value-at-Risk: Their Estimation
+  Error, Decomposition, and Optimization Bank of Japan. 3.
+  Epperlein and Smillie (2006) "Cracking VAR with Kernels,"
+  Risk.
+}
+

Added: pkg/FactorAnalytics/sandbox/Man/modifiedVaRReport.Rd
===================================================================
--- pkg/FactorAnalytics/sandbox/Man/modifiedVaRReport.Rd	                        (rev 0)
+++ pkg/FactorAnalytics/sandbox/Man/modifiedVaRReport.Rd	2013-09-11 17:20:09 UTC (rev 3058)
@@ -0,0 +1,73 @@
+\name{modifiedVaRReport}
+\alias{modifiedVaRReport}
+\title{compute VaR report via Cornish-Fisher expansion for collection of assets in
+a portfolio given simulated (bootstrapped) return data.}
+\usage{
+  modifiedVaRReport(bootData, w, delta.w = 0.001,
+    tail.prob = 0.01, method = c("derivative", "average"),
+    nav, nav.p, fundStrategy, i1, i2)
+}
+\arguments{
+  \item{bootData}{B x n matrix of B bootstrap returns on
+  assets in portfolio.}
+
+  \item{w}{n x 1 vector of portfolio weights.}
+
+  \item{delta.w}{scalar, change in portfolio weight for
+  computing numerical derivative. Default value is 0.010.}
+
+  \item{tail.prob}{scalar tail probability.}
+
+  \item{method}{character, method for computing marginal
+  VaR Valid choices are "derivative" for numerical
+  computation of the derivative of portfolio VaR wrt fund
+  portfolio weight; "average" for approximating E[Ri | Rp
+  =VaR]}
+
+  \item{nav}{n x 1 vector of net asset values in each
+  fund.}
+
+  \item{nav.p}{scalar, net asset value of portfolio
+  percentage.}
+
+  \item{fundStrategy}{n x 1 vector of fund strategies.}
+
+  \item{i1,i2}{if ff object is used, the ffapply functions
+  do apply an EXPRession and provide two indices FROM="i1"
+  and TO="i2", which mark beginning and end of the batch
+  and can be used in the applied expression.}
+}
+\value{
+  dataframe with the following columns: Strategy n x 1
+  strategy. Net.Asset.value n x 1 net asset values.
+  Allocation n x 1 vector of asset weights. Mean n x 1 mean
+  of each funds. Std.Dev n x 1 standard deviation of each
+  funds.  Assets.VaR n x 1 vector of asset specific VaR
+  values. cVaR n x 1 vector of asset specific component VaR
+  values. cVaR.dollar n x 1 vector of asset specific
+  component VaR values in dollar terms. pcVaR n x 1 vector
+  of asset specific percent contribution to VaR values.
+  iVaR n x 1 vector of asset specific incremental VaR
+  values. iVaR.dollar n x 1 vector of asset specific
+  component VaR values in dollar terms. mVaR n x 1 vector
+  of asset specific marginal VaR values. mVaR.dollar n x 1
+  vector of asset specific marginal VaR values in dollar
+  terms.
+}
+\description{
+  compute VaR report via Cornish-Fisher expansion for
+  collection of assets in a portfolio given simulated
+  (bootstrapped) return data. Report format follows that of
+  Excel VaR report.
+}
+\examples{
+data(managers.df)
+ret.assets = managers.df[,(1:6)]
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 3058


More information about the Returnanalytics-commits mailing list