getCorr {stockPortfolio} | R Documentation |
Determine the average correlation or average correlation by industry of a variance-covariance matrix.
getCorr(V, industry = NULL)
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. |
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
.
David Diez
#===> the covariance matrix of stock94 <===# data(stock94) data(stock94Info) V <- cov(stock94) #===> the average correlation <===# getCorr(V) getCorr(V, industry=stock94Info$industry)