[R] how do I make a correlation matrix positive definite?

Spencer Graves spencer.graves at structuremonitoring.com
Fri Oct 22 02:33:27 CEST 2010


       Using "complete.observations" could produce a correlation matrix 
based on zero data or on less than 1 percent of available data.


       Have you considered "missMDA: a new package to handle missing 
values in PCA or MCA with FactoMineR" (http://factominer.free.fr)?


       If the data are all multivariate normal and missing at random, 
it's straightforward to write a likelihood function for those data and 
estimate the mean and covariance matrix to maximize that likelihood.  
Moreover, one could further estimate a factor analysis model for said 
covariance matrix.  (If it's not reasonable to assume multivariate 
normal, then I don't know if it's reasonable to estimate a correlation 
matrix.)  I have not tried it, but I believe that "missMDA" should solve 
this problem assuming all the "uniquenesses" are equal.


       Hope this helps,
       Spencer Graves


On 10/21/2010 5:03 PM, Peter Langfelder wrote:
> On Thu, Oct 21, 2010 at 3:50 PM, HAKAN DEMIRTAS<demirtas at uic.edu>  wrote:
>> Hi,
>>
>> If a matrix is not positive definite, make.positive.definite() function in corpcor library finds the nearest positive definite matrix by the method proposed by Higham (1988).
>>
>> However, when I deal with correlation matrices whose diagonals have to be 1 by definition, how do I do it? The above-mentioned function seem to mess up the diagonal entries. [I haven't seen this complication, but obviously all entries must remain in (-1,1) range after conversion.]
>>
>> Any R tools to handle this?
>>
>> I'd appreciate any help.
> Well, I can't provide immediate help, but I'm curious where the
> correlation matrices are coming from. Autocorrelation matrices (i.e.,
> cor(x)) are always positive semi-definite (unless you have missing
> data and you specify use = "pairwise.complete.observations", in which
> case you may get some negative eigenvalues).
>
> The correlation matrix you provided seems to be inconsistent in the
> sense that cor (x[, 1], x[, 2]) is -0.95, cor(x[, 2], x[, 3]) is
> -0.81, but cor(x[, 1], x[, 3]) is only -0.25. Using basic geometry
> arguments one can show that given the 1,2 and 2,3 correlations, the
> 1,3 correlation must be at least 0.58. Again, you may get such an
> apparently inconsistent correlation matrix if you use
> "pairwise.complete.observations" and you have enough missing data.
>
> So one question is whether you do use "pairwise.complete.observations"
> when you calculate the matrix. If yes, you may want to try specifying
> "complete.observations" which will remove more observations but may
> solve your problem.
>
> Peter
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list