Learn R Programming

PerformanceAnalytics (version 2.0.4)

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

Description

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

Usage

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

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", "geltner", or "locScaleRob".

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.

SE

TRUE/FALSE whether to ouput the standard errors of the estimates of the risk measures, default FALSE.

SE.control

Control parameters for the computation of standard errors. Should be done using the RPESE.control function.

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

Run this code
# NOT RUN {
if(!( Sys.info()[['sysname']]=="Windows") ){
# if on Windows, cut and paste this example

    data(edhec)

    # first do normal StdDev calc
    StdDev(edhec)
    # or the equivalent
    StdDev(edhec, portfolio_method="single")

    # now with outliers squished
    StdDev(edhec, clean="boudt")

    # add Component StdDev for the equal weighted portfolio
    StdDev(edhec, clean="boudt", portfolio_method="component")

} # end CRAN Windows check

# }

Run the code above in your browser using DataLab