calculates Standard Deviation for univariate and multivariate series, also calculates component contribution to standard deviation of a portfolio

StdDev(R, ..., clean = c("none", "boudt", "geltner"),
  portfolio_method = c("single", "component"), weights = NULL, mu = NULL,
  sigma = NULL, use = "everything", method = c("pearson", "kendall",
  "spearman"))

Arguments

R

a vector, matrix, data frame, timeSeries or zoo object of asset returns

any other passthru parameters

clean

method for data cleaning through Return.clean. Current options are "none", "boudt", or "geltner".

portfolio_method

one of "single","component" defining whether to do univariate/multivariate or component calc, see Details.

weights

portfolio weighting vector, default NULL, see Details

mu

If univariate, mu is the mean of the series. Otherwise mu is the vector of means of the return series , default NULL, , see Details

sigma

If univariate, sigma is the variance of the series. Otherwise sigma is the covariance matrix of the return series , default NULL, see Details

use

an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs".

method

a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman", can be abbreviated.

Details

TODO add more details

This wrapper function provides fast matrix calculations for univariate, multivariate, and component contributions to Standard Deviation.

It is likely that the only one that requires much description is the component decomposition. This provides a weighted decomposition of the contribution each portfolio element makes to the univariate standard deviation of the whole portfolio.

Formally, this is the partial derivative of each univariate standard deviation with respect to the weights.

As with VaR, this contribution is presented in two forms, both a scalar form that adds up to the univariate standard deviation of the portfolio, and a percentage contribution, which adds up to 100 as with any contribution calculation, contribution can be negative. This indicates that the asset in question is a diversified to the overall standard deviation of the portfolio, and increasing its weight in relation to the rest of the portfolio would decrease the overall portfolio standard deviation.

See also

Return.clean sd

Examples

data(edhec) # first do normal StdDev calc StdDev(edhec)
#> Convertible Arbitrage CTA Global Distressed Securities Emerging Markets #> StdDev 0.02004739 0.0251309 0.01834791 0.03857144 #> Equity Market Neutral Event Driven Fixed Income Arbitrage Global Macro #> StdDev 0.009005818 0.01835047 0.01417129 0.01701962 #> Long/Short Equity Merger Arbitrage Relative Value Short Selling #> StdDev 0.02217382 0.01116827 0.01319468 0.05509917 #> Funds of Funds #> StdDev 0.01821196
# or the equivalent StdDev(edhec, portfolio_method="single")
#> Convertible Arbitrage CTA Global Distressed Securities Emerging Markets #> StdDev 0.02004739 0.0251309 0.01834791 0.03857144 #> Equity Market Neutral Event Driven Fixed Income Arbitrage Global Macro #> StdDev 0.009005818 0.01835047 0.01417129 0.01701962 #> Long/Short Equity Merger Arbitrage Relative Value Short Selling #> StdDev 0.02217382 0.01116827 0.01319468 0.05509917 #> Funds of Funds #> StdDev 0.01821196
# now with outliers squished StdDev(edhec, clean="boudt")
#> Error: requireNamespace("robustbase", quietly = TRUE) is not TRUE
# add Component StdDev for the equal weighted portfolio StdDev(edhec, clean="boudt", portfolio_method="component")
#> no weights passed in, assuming equal weighted portfolio
#> Error: requireNamespace("robustbase", quietly = TRUE) is not TRUE