portfolioVol: Compute portfolio volatility from a set of returns.

Description Usage Arguments Details Value See Also Examples

View source: R/portfolioVol.R

Description

This function just calculates the portfolio volatility given a set of asset returns, R, a weight vector, w, and a covariance matrix, sigma. A scale value can be supplied which is the annualization factor for the returns if annualized volatility is desired. The default is 1 (ie. no annualization). Supply 12 for monthly data, 252 for daily, and so on.

Usage

1
portfolioVol(w = NULL, R, sigma, scale = 1)

Arguments

w

a vector of weights. If not supplied, function will assign equal weights. Default value is NULL. (ie. equal weights)

R

an xts or matrix of asset returns.

sigma

a covariance matrix for the asset returns.

scale

an annualization factor for the returns if desired. Default = 1.

Details

If no weight vector is supplied, the function will calculate equal weights for the portfolio assets.

Value

a numeric value representing the portfolio volatility.

See Also

wtdAvgVol, divRatio

Examples

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

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