Codes in Matlab and others
Codes for nearest (covariance) correlation matrix problems
- Codes for the Nearest Correlation Matrix problem (the problem was initially introduced by Prof. Nick Higham): CorrelationMatrix.m is a Matlab code written for computing the nearest correlation matrix problem (first uploaded in August 2006; last updated on August 30, 2019). This code should be good enough for most Matlab users. If your Matlab version is very low and you really need a faster code, you can download mexeig.mexw64 (for win64 operating system) and if use win32 or Linux system, you need to download the installmex file installmex.m and the c-file mexeig.c by running the installmex.m first. For a randomly generated 3,000 by 3,000 pseudo correlation matrix (the code is insensitive to input data), the code needs 24 seconds to reach a solution with the relative duality gap less than 1.0e-3 after 3 iterations and 43 seconds with the relative duality gap less than 1.0e-10 after 6 iterations in my Dell Desktop with Intel (R) Core i7 processor and for an invalid 10,000 by 10,000 pseudo correlation matrix, the code needs 15 minutes to reach a solution with the relative duality gap less than 1.0e-4 after 4 iterations and 24 minutes with the relative duality gap less than 1.0e-12 after 7 iterations. For practitioners, you may set the stopping criterion (relative duality gap) to stay between 1.0e-1 and 1.0e-3 to run the code (typically, 1 to 3 iterations). If you need a C/C++ code, download main.c and main.h, which were written by Pawel Zaczkowski under a summer research project. If you are a client to The Numerical Algorithms Group (NAG), you may also enjoy their commercialized implementations. The code in R CorrelationMatrix.R was written by Ying Cui (last updated on August 31, 2019; for efficiency, please use Microsoft R open) and the code in Python CorrelationMatrix.py was written by Yancheng Yuan (last updated on May 11, 2017), respectively.
- CorNewton3.m Computing the Nearest Correlation Matrix with fixed diagonal and off diagonal elements (uploaded on September 14, 2009). The code in R CorNewton3.R was provided by Professor Luca Passalacqua (luca.passalacqua@uniroma1.it) (uploaded on October 7, 2016; for efficiency, please use Microsoft R open).
- CorNewton3_Wnorm.m Computing the W-norm Nearest Correlation Matrix with fixed diagonal and off diagonal elements Testing example: testCorMatWnorm.m(uploaded on September 14, 2009).
- CorMatHdm.m Calibrating the H-weighted Nearest Correlation Matrix Testing example: testCorMatHdm.m (uploaded in June 2008; last updated on September 10, 2009).
- CorMatHdm_general.m Computing the H-weighted Nearest Correlation Matrix with fixed elements and lower and upper bounds [H should not have too many zero elements for better numerical performance; otherwise, see CaliMatHdm] Testing example: testCorMatHdm_general.m (uploaded on September 14, 2009).
- LagDualNewton.m (this is superseded by CorNewton3.m) Testing example: testLagDualNewton.m (LagDualNewton method for the Band Correlation Stress Testing, “CorNewton1.m” will be called).
- CorNewtonSchur.m Testing example: testCorNewtonSchur.m (Schur decomposition based method for the Local Correlation Stress Testing, “CorNewton1.m” will be called).
- AugLagNewton.m (this is superseded by CorMatHdm_general.m) Testing example: testAugLagNewton.m (AugLagNewton method for the Band Correlation Stress Testing, “CorNewton1.m” will be called). (uploaded in March 2007).
- CaliMat1Mex.zip (Codes and testing example for) Calibrating Covariance Matrix Problems with Inequality and/or Equality Constraints (uploaded in April 2010).
- CaliMatHdm.zip Calibrating the H-weighted Nearest Covariance Matrix [H is allowed to have a large number of zero elements] (uploaded in April 2010).
- Rank_CaliMat.zip Calibrating the Nearest Correlation Matrix with Rank Constraints (uploaded in April 2010).
- Rank_CaliMatHdm.zip Calibrating the H-weighted Nearest Correlation Matrix with Rank Constraints (uploaded in April 2010; last updated in October 2010 by including the refined Major codes).
Codes under the Matrix Optimization (MatOpt) Project
QSDPNAL (version 1.0): a MATLAB software for solving convex quadratic semidefinite programming (QSDP) (click here for an introduction on how to use the package) [CAUTION: this software is for research purpose. It is neither intended nor designed to be a general purpose software at the moment.] For the details of the software, please check the following papers:
[Xudong Li, Defeng Sun, and Kim Chuan Toh, “QSDPNAL: A two-phase augmented Lagrangian method for convex quadratic semidefinite programming”, Mathematical Programming Computation, 10 (2018) 703–743.]
[Xudong Li, Defeng Sun, and Kim Chuan Toh, “A block symmetric Gauss-Seidel decomposition theorem for convex composite quadratic programming and its applications”, Mathematical Programming 175 (2019) 395–418. arXiv:1703.06629]
SDPNAL+: a MATLAB software for solving large scale semidefinite programming with bound constraints (click here for an introduction on how to use the package) [awarded the triennial Beale–Orchard-Hays Prize for Excellence in Computational Mathematical Programming by the Mathematical Optimization Society at Bordeaux, France, July 2-6, 2018. See Picture 1, Picture 2, and Picture 3.] [CAUTION: this software is NOT designed for solving small to medium sized SDP problems, for which interior point methods based software such as SDPT3 is a better option.] For the details of the software, please check the following papers:
[Defeng Sun, Kim Chuan Toh, Y.C. Yuan, Xinyuan Zhao, SDPNAL+: A Matlab software for semidefinite programming with bound constraints (version 1.0), to appear in Optimization Methods and Software (2019).]
[Liuqin Yang, Defeng Sun, and Kim Chuan Toh, SDPNAL+: a majorized semismooth Newton-CG augmented Lagrangian method for semidefinite programming with nonnegative constraints, Mathematical Programming Computation, 7 (2015), pp. 331-366.]
[Defeng Sun, Kim Chuan Toh, and Liuqin Yang, “A convergent 3-block semi-proximal alternating direction method of multipliers for conic programming with 4-type constraints”, SIAM Journal on Optimization Vol. 25, No. 2 (2015) 882–915. Detailed computational results for over 400 problems tested in the paper. You may also find a supplementary note here on more detailed comparisons between the performance of our proposed algorithm and various variants of ADMMs.]
[Xinyuan Zhao, D.F. Sun, and Kim Chuan Toh, A Newton-CG augmented Lagrangian method for semidefinite programming, SIAM Journal on Optimization, 20 (2010), pp. 1737–1765.]
“Solving log-determinant optimization problems by a Newton-CG proximal point algorithm”. See the brief user’s guide logdet-0-guide.pdf.
CorMatHdm_general.m Computing the H-weighted Nearest Correlation Matrix with fixed elements and lower and upper bounds [H should not have too many zero elements for better numerical performance; otherwise, see CaliMatHdm] Testing example: testCorMatHdm_general.m (uploaded on September 14, 2009).
CaliMatHdm.zip Calibrating the H-weighted Nearest Covariance Matrix [H is allowed to have a large number of zero elements] (uploaded in April 2010).
Codes under the Statistical Optimization (StaOpt) Project
SuiteLasso: a MATLAB suite for regression problems with generalized Lasso regularizers (GitHub) [last updated in April 2021 with all source codes available]. See the introduction on how to use it.
Square_Root_PMM: A MATLAB software for square-root regression problems (GitHub) [Last updated in January 2021]. Copyright (c) 2021 by Peipei Tang, Chengjing Wang, Defeng Sun, and Kim-Chuan Toh. This is a software package for solving the square-root regression problem: min{ |X \beta - b |_2+\lambda p(\beta) - q(\beta)}. For the details of the software, please check the following paper:
[Peipei Tang, Chengjing Wang, Defeng Sun, and Kim Chuan Toh, “A sparse semismooth Newton based proximal majorization-minimization algorithm for nonconvex square-root-loss regression problems”, Journal of Machine Learning Research 21(226):1–38, 2020.]
ConvexClustering: a MATLAB package for convex clustering [last updated in June 2021]. See the introduction on how to use it.
Codes for rank constrained problems
Rank_CaliMat.zip Calibrating the Nearest Correlation Matrix with Rank Constraints (uploaded in April 2010).
Rank_CaliMatHdm.zip Calibrating the H-weighted Nearest Correlation Matrix with Rank Constraints (uploaded in April 2010; last updated in October 2010 by including the refined Major codes).
Codes for other problems
- IQEP_Newton.m Computing the Inverse Quadratic Eigenvalue Problems Testing example: testIQEP_Newton.m (uploaded in March 2008; last updated on July 15, 2016 by Ying Cui (cuiying@u.nus.edu)).