The covariance matrix has the property that it is positive semi definite. Occasionally when calculating the sample covariance matrix this is not the case. What can be done in these cases?
(My specific problem is that I have 2 stock prices containing 10 years of data. I wish to calculate the sample covariance matrix for the two stocks for a given window of data, e.g. 20 days, guaranteeing that it is always positive semi definite)