I am working on alternative ways for the estimation of variance-covariance matrices. For this I have already estimated the sample variance-covariance matrix, single index covariance matrix. I also want to estimate the covariance matrix by principal component analysis (PCA). As I have 5 different types of asset returns and factors which are assumed to drive these returns are 6 in numbers like (Inflation, interest rate etc).

Kindly guide me what is the procedure to estimate this covariance matrix by PCA.

  • 2
    $\begingroup$ PCA operates over the covariance matrix. You need to have the covariance matrix first. I don't think this is going to work out. $\endgroup$ Oct 10, 2015 at 16:22
  • $\begingroup$ Dear, I have one page pdf format file, I wana to share it with you/with this post. But I am not able to find the way how to post this image etc. But in that file He describe the ways to estimate the covariance matrix by PCA. and I am not able to understand it. $\endgroup$ Oct 11, 2015 at 9:13
  • $\begingroup$ Muhammad, please post your image on imgur.com and post a link here in a comment. If it is a pdf file, post in anywhere you want (dropbox? google drive? there are plenty of possibilities) and post a link here too. Alternatively, provide some quotes from this document. Currently your question is unclear and can be closed as such. $\endgroup$
    – amoeba
    Oct 11, 2015 at 12:22
  • $\begingroup$ Dear, thank, here is the link of the pdf file, jasonhsu.org/uploads/1/0/0/7/10075125/… In this file, there are four ways for estimation of VC matricx, On page 3, there is a way for the estimation of VC by PCA. Kindly guide how I can estimate this model. As i know other 3 ways described in that documnet for estimation of covariance matrix. A thousand thanks for this. $\endgroup$ Oct 11, 2015 at 16:43
  • $\begingroup$ I think what is meant there is to compute sample covariance matrix, then do PCA, and keep only few components, i.e. use a low-rank approximation to the sample covariance matrix. Cc to @gung. $\endgroup$
    – amoeba
    Oct 12, 2015 at 10:23

2 Answers 2


Quoting from the link in the above question, the methodology is as follow

principal component analysis (PCA) can be used to determine the underlying drivers of the stock returns. The PCA method transforms the vector space of N assets into another vector space of N factors by singular value decomposition (SVD) of the sample covariance matrix. Each factor, an eigenvector from the SVD, represents a linear combination of the original N assets, and the factors are uncorrelated by definition, with variances equal to the eigenvalues from the SVD.

Asset returns and sample covariance matrix can be written as

$$ R_i^e = \beta_{i,1}F_{1} + \beta_{i,2}F_{2} + \cdots + \beta_{i,N}F_{N} \\ \hat{\Sigma} = \beta D_{F} \beta^{T} $$

Where $\beta$ represents N columns of eigenvectors, and $D_F$ is the N by N diagonal matrix of eigenvalues.

PCA is often employed to reduce dimensionality of the data. If the first L factors govern most of the variability of the asset returns, i.e. if $\frac{\Sigma_{l=0}^{L} \sigma_{F,l}^2}{\Sigma_{l=0}^{N} \sigma_{F,l}^2}$ is very close to 1, then the last N-L factors shall be dropped,

$$ \hat{\Sigma} = \tilde{\beta}\tilde{D_F}\tilde{\beta}^T + D_{\epsilon} $$

Where $\tilde{\beta}$ is the N-asset by L-factor matrix of factor loadings (first L eigenvectors), $\tilde{D_F}$ is the L by L diagonal matrix of the first L eigenvalues, and $D_{\epsilon}$ is the N-asset by N-asset diagonal matrix of variances of idiosyncratic components not explained by the first L factors.

See Chapter 8 of Professor Jorion’s “Value At Risk” for more details.

This technique is often used when the number of assets N is close to the number samples T, leading to spurious correlations in the sample covariance and when N > T, a sample covariance matrix which is singular.


As a concrete example, here is an implementation in R for returns generated from the 1 factor model

$$ R_{t} = m_{t}\beta + \epsilon_{t} $$

where $R_{t}$ is an Nx1 vector of returns at time t, $m_t$ is the market return at time t, $\beta$ are the Nx1 betas of the assets to the market return and $\epsilon_{t}$ is Nx1 gaussian noise at time t

N <- 15
T <- 30
mvol <- 0.8

market.betas <- runif(N, 0, 2)
market.factor <- rnorm(T, 0, sd=mvol)
epsilon <- matrix(rnorm(N*T, 0, sd=1), ncol=N)

equity.rets <- market.factor %*% t(market.betas) + epsilon
sample.cov <- cov(equity.rets)
prs <- prcomp(equity.rets)

Keeping all the factors, we can reconstruct the sample variance exactly (modulo machine precision)

sum(abs(sample.cov - prs$rotation %*% diag(prs$sdev^2) %*% t(prs$rotation)))
[1] 8.925881e-13

Or we can drop PCs with less variance. A detailed answer discussing this is Relationship between SVD and PCA. Here we choose only the first PC, with the omniscience that this is a 1 factor model.

eigs <- prs$sdev^2
eigs[-1] <- 0

pca1.cov <- prs$rotation %*% diag(eigs) %*% t(prs$rotation)

Comparing the PCA covariance and sample covariance to the model covariance, $Var(m_{t}\beta)$, we can see improvements across a variety of distance metrics.

model.cov <- mvol^2 * market.betas %*% t(market.betas)

d1 <- function(m1, m2){sum(abs(m1 - m2))}
d2 <- function(m1, m2){sum((m1 - m2)^2)}
dinf <- function(m1, m2){max(abs(m1 - m2))}
dist <- data.frame(
          c(d1(model.cov, sample.cov), d1(model.cov, pca1.cov)),
          c(d2(model.cov, sample.cov), d2(model.cov, pca1.cov)),
          c(dinf(model.cov, sample.cov), dinf(model.cov, pca1.cov))
colnames(dist) <- c("d1", "d2", "dinf")
rownames(dist) <- c("sample cov", "pca1 cov")
                 d1       d2      dinf
sample cov 74.25255 42.26942 1.6620401
pca1 cov   52.13983 18.74075 0.8036362

By following mgilbert's excellent answer... If we decide to do the PCA not on the covariance matrix, but rather on the correlation matrix (by dividing asset returns by their standard deviation pre-PCA), will the final reconstructed matrix in the original dimensionality also be a correlation matrix?

If it is indeed then a correlation matrix, and if we want to use the full-dimensional matrix for simulations or Value at Risk with interpretable results, do we not have to transform the full-dimensional correlation matrix back into a covariance matrix by computing the following..?


  • $\begingroup$ This is not a complete answer because of the "ifs" you raise. $\endgroup$ Aug 20, 2019 at 21:00
  • $\begingroup$ Wasn't able to comment on the mgilbert's answer as I'm below the reputation limit - would there be a better way to ask? I'm basically alluding to full valid portfolio reconstruction in the situation where instead of using PCA(covMatrix(assets)) we use PCA(corrMatrix(Assets)) $\endgroup$ Aug 20, 2019 at 22:01
  • $\begingroup$ I don't accept that excuse. If you want to comment wait until you have enough reputation. $\endgroup$ Aug 20, 2019 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.