Determine the average correlation or average correlation by industry of a variance-covariance matrix.
Usage
getCorr(V, industry = NULL)
Arguments
V
Variance-covariance matrix.
industry
A vector specifying the industry of the stocks in their order given in the columns (and rows) of V. This argument is optional.
Value
If industry is not provided, then the average correlation in V in the matrix is returned but ignoring the diagonal. If industry is provided, then the output is a matrix with dimension k-by-k, where k is the number of unique values in industry.
#===> the covariance matrix of stock94 <===#data(stock94)
data(stock94Info)
V <- cov(stock94)
#===> the average correlation <===#getCorr(V)
getCorr(V, industry=stock94Info$industry)