portfolio-riskPfolio | R Documentation |
Computes Value-at-Risk and related measures for a portfolio of assets.
The functions are:
pfolioVaR | computes Value-at-Risk for a portfolio of assets, |
pfolioCVaRplus | computes Value-at-Risk+ for a portfolio of assets, |
pfolioCVaR | computes Conditional Value-at-Risk for a PF of assets, |
lambdaCVaR | computes CVaR's atomic split value lambda, |
pfolioCVaRoptim | computes Conditional VaR from mean-CVaR optimization, |
pfolioMaxLoss | computes Maximum Loss for a portfolio of assets, |
pfolioReturn | computes return values of a portfolio, |
pfolioTargetReturn | computes the target return of a portfolio, |
pfolioTargetRisk | computes the target risk of a portfolio, |
pfolioHist | plots a histogram of the returns of a portfolio. |
pfolioVaR(x, weights = NULL, alpha = 0.05)
pfolioCVaRplus(x, weights = NULL, alpha = 0.05)
pfolioCVaR(x, weights = NULL, alpha = 0.05)
lambdaCVaR(n, alpha = 0.05)
pfolioCVaRoptim(x, weights = NULL, alpha = 0.05)
pfolioMaxLoss(x, weights = NULL)
pfolioReturn(x, weights = NULL, geometric = FALSE)
pfolioTargetReturn(x, weights = NULL)
pfolioTargetRisk(x, weights = NULL)
pfolioHist(x, weights = NULL, alpha = 0.05, range = NULL, details = TRUE, ...)
x |
a 'timeSeries' object, data frame or any other rectangular
object which can be expressed as a matrix. The first
dimension is the number of observations, we call it |
weights |
usually a numeric vector which has the length of the number of
assets. The weights measures the normalized weights of the
individual assets. By default |
geometric |
a logical flag, should geometric returns be used, by default FALSE |
alpha |
a numeric value, the confidence interval, by default 0.05. |
details |
a logical value, should details be printed? |
n |
the number of observation from which the CVaR's atomic split
value |
range |
a numeric vector of two elements limiting the plot range of
the histogram. This is quite useful if one likes to compare
several plots on the same scale. If |
... |
optional arguments to be passet to the function |
The percentile measures of loss (or reward) are defined in the
following way: Let f(x ,y)
be a loss functions depending
upon a decision vector x = (x_1, ..., x_n )
and a random
vector y = (y_1, ..., y_m)
, then
pfolioVaR is the alpha-percentile of the loss distribution, a smallest value such that the probability that losses exceed or are equal to this value is greater or equal to alpha.
pfolioCVaRplus or "CVaR+" or the "upper CVaR" are the expected losses strictly exceeding VaR. This is also also called "Mean Excess Loss" and "Expected Shortfall".
pfolioCVaR is a weighted average of VaR and CVaRplus defined as
CVaR = lambda*VaR + (1-lambda)
CVaRplus, for
0 <= lambda <= 1
.
Note, CVaR is convex, but VaR and CVaRplus may be non-convex. The
following inequalities are valid: VaR <= CVaR <= CVaRplus
.
pfolioVaR
returns the value of risk, VaR, for a portfolio of assets, a
numeric value.
pfolioCVaRplus
returns the conditional value of risk plus, CVaRplus, for a
portfolio of assets, a numeric value.
pfolioCVaR
returns the conditional value of risk, CVaR, for a portfolio
of assets, a numeric value.
lambdaCVaR
returns CVaR's atomic split value lambda
, a numeric value.
pfolioMaxLoss
returns the maximum loss value of the portfolio, a numeric value.
pfolioReturn
returns the total portfolio return computed from the set of
assets x
, a numeric vector.
pfolioTargetReturn
returns the total return or target return computed from the set of
assets x
and weights weights
, a numeric value.
pfolioTargetRisk
returns the total risk (Sigma) or target risk computed from the set
of assets x
and weights
via the formual
sqrt(weights %*% cov(x) %*% weights)
, a numeric value.
pfolioHist
plots a histogram of portfolio returns and adds the values
for the VaR (blue), for the CVaRplus (red), and for the
maximum loss (green) to the histogram plot. The function
invisibly returns a list with the following elements: VaR,
VaRplus, maxLoss, mean, and sd. If details
is TRUE
,
then the result is printed.
Uryasev S. (2000); Conditional Value-at-Risk (CVaR): Algorithms and Applications, Risk Management and Financial Engineering Lab, University of Florida
Wuertz, D., Chalabi, Y., Chen W., Ellis A. (2009); Portfolio Optimization with R/Rmetrics, Rmetrics eBook, Rmetrics Association and Finance Online, Zurich.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.