# Nearest Correlation Matrix

**URL:** https://discourse.julialang.org/t/nearest-correlation-matrix/14713
**Category:** General Usage
**Created:** [September 8, 2018, 8:09pm UTC](https://discourse.julialang.org/t/nearest-correlation-matrix/14713 "2018-09-08T20:09:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [September 8, 2018, 8:09pm UTC](https://discourse.julialang.org/t/nearest-correlation-matrix/14713/1 "2018-09-08T20:09:58Z")

</div>

Does anyone know if there’s a native Julia implementation of finding the [Nearest Correlation Matrix](https://nickhigham.wordpress.com/2013/02/13/the-nearest-correlation-matrix/)?

---

<div class="post-metadata">

### Author: ![migarstka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/migarstka/32/3828_2.png) [@migarstka](https://discourse.julialang.org/u/migarstka)
#### Post date: [January 14, 2019, 11:43am UTC](https://discourse.julialang.org/t/nearest-correlation-matrix/14713/2 "2019-01-14T11:43:27Z")

</div>

I am not aware of any.  
Essentially you have to solve a semidefinite program, which can be done using e.g. JuMP and an appropriate SDP solver.

I created a simple example as a test case for my solver here:  
[https://github.com/oxfordcontrol/COSMO.jl/blob/master/examples/closest\_correlation\_matrix.jl](https://github.com/oxfordcontrol/COSMO.jl/blob/master/examples/closest_correlation_matrix.jl)
