wtdAvgVol: Compute the weighted average volatility of assets in a...

Description Usage Arguments Details Value See Also Examples

View source: R/wtdAvgVol.R

Description

Given a weight vector, w, and an xts object of returns, R this will return the weighted average volatility assuming all the assets are perfectly uncorrelated. (ie. all pairwise covariances are zero) If equal.wt=TRUE, then w is ignored. This is the default. Otherwise, w is used for the weight vector.

Usage

1
wtdAvgVol(w, R, equal.wt = TRUE, scale = 1)

Arguments

w

a weight vector equal in length to the numnber of columns of R.

R

an xts object of returns.

equal.wt

a flag indicating whether or not to apply equal weights. Defualt is TRUE.

scale

the annualization factor for the data. If supplied, this will scale the return volatilities to annualized volatilities. Default is 1.

Details

This function is useful for calculations like the Diversification Ratio where the weighted average volatility is in the numerator and the fully correlated volatility of the portfolio is in the denominator.

Value

a numeric value equal to the weighted average volatility of the assets.

See Also

portfolioVol, divRatio

Examples

1
2
3
4
dts <- seq(Sys.Date()-199, Sys.Date(), 1)
returns <- matrix(rnorm(1000),ncol = 5) / 100
ret.xts <- xts(returns, dts)
wtdAvgVol(R = ret.xts)

gtog/dMisc documentation built on May 17, 2019, 8:57 a.m.