you could also have a look at function posdefify() from package `sfsmisc'.
I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: ""Jens Oehlschlägel"" <[EMAIL PROTECTED]> To: <r-help@stat.math.ethz.ch> Sent: Friday, July 13, 2007 2:25 PM Subject: [R] nearest correlation to polychoric Dear all, Has someone implemented in R (or any other language) Knol DL, ten Berge JMF. Least-squares approximation of an improper correlation matrix by a proper one. Psychometrika, 1989, 54, 53-61. or any other similar algorithm? Best regards Jens Oehlschlägel Background: I want to factanal() matrices of polychoric correlations which have negative eigenvalue. I coded Highham 2002 Computing the nearest correlation matrix - a problem from finance, IMA Journal of Numerical Analysis (2002), 22, 329-343. which basically works but still leaves very small negative eigenvalues which causes factanal() to fail with > factanal(cov=ncor$cor, factors=2) Fehler in optim(start, FAfn, FAgr, method = "L-BFGS-B", lower = lower, : L-BFGS-B benötigt endliche Werte von 'fn' Zusätzlich: Warning message: NaNs wurden erzeugt in: log(x) > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.1 year 2006 month 12 day 18 svn rev 40228 language R version.string R version 2.4.1 (2006-12-18) -- ______________________________________________ R-help@stat.math.ethz.ch 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ R-help@stat.math.ethz.ch 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.