Negative eigenvalues in covariance matrix

  • Thread starter BWV
  • Start date
  • #1
BWV
1,003
1,028
Trying to run the factoran function in MATLAB on a large matrix of daily stock returns. The function requires the data to have a positive definite covariance matrix, but this data has many very small negative eigenvalues (< 10^-17), which I understand to be a floating point issue as 'real' covariance matrices are positive semi-definite. Does not make a difference whether or not I subtract the market return (which reduces the correlation). Any thoughts, I can find options to 'fix' the cov matrix, but nothing to tweak the data prior to calculating the cov matrix
 

Answers and Replies

  • #2
marcusl
Science Advisor
Gold Member
2,774
432
Add a small constant value σ2 to the diagonal elements of your covariance matrix. This has the effect of increasing the noise floor in your data, eliminating the negative values arising from numerical errors. The smallest eigenvalues will now take the value σ2 (approximately--but that's a topic for another thread). Choose σ2 large compared to 1e-17 but small compared to the eigenvalues of interest. If your eigenvalues of interest are of order >=1, for instance, then σ2=1e-10 will suffice without affecting the validity of your data. This is known in the statistical signal processing literature as diagonal loading and in the mathematics literature as Tikhonov regularization.
 
  • Like
Likes sysprog, FactChecker and BWV
  • #3
BWV
1,003
1,028
Thanks, afraid of that, will have to hack the matlab function to do this, surprised there is not an option on the cov function or another built-in function to do this. Its just something I am playing around with, so not sure if I will invest the time
 
  • #4
marcusl
Science Advisor
Gold Member
2,774
432
Let us know how it turns out!
 

Related Threads on Negative eigenvalues in covariance matrix

  • Last Post
Replies
4
Views
8K
Replies
1
Views
685
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
1
Views
6K
Replies
2
Views
28K
  • Last Post
Replies
1
Views
5K
  • Last Post
Replies
4
Views
3K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
0
Views
4K
Top