IfNote: Major edits vs. original version.
Per your comments, $C$ is a correlation matrix, then ${C}_{i,i}^{-1}$ and ${C}_{j,j}^{-1}$ both $= 1$. So, it's just downso it has diagonal elements all equal to ${C}_{i,j}^{-1}$1.
If you can compute the correlation coefficients more accurately, then do so. Use of higher precision might be a good idea. If that solves the problem, fine.
Otherwise, it's probably not a great harmyou need to usemake C as is, given smallest eigenvalue ofa positive definite correlation matrix in order of -1e-8that its inverse will have a positive diagonal.
However To do so, if you want to clean things upcan try to make Cfind a positive definite correlation matrix which is as close as possible to the original matrix in the Frobenius norm sense (square root of sum of squared differences of all elements), then proceed. Proceed per my solution method B at Generate normally distributed random numbers with non positive-definite covariance matrix , with the imposition of the extra constraint that all diagonal elements must be 1.
Let C = original n by n "correlation" matrix.
Solve for D, which will be the closest (per the in the Frobenius norm) correlation matrix to C having minimum eigenvalue of mineig.
So inHere is the grand schemeinverse of things, for this usage, I don't thinkC
1.0e+07 *
0.000000001185191 -0.001409651498643 0.000000012853632 -0.001409643028590
-0.001409651498643 -4.821534275445975 0.000735529929189 -4.822195310021794
0.000000012853632 0.000735529929189 0.000000139399859 0.000735621788386
-0.001409643028590 -4.822195310021794 0.000735621788386 -4.822856184065902
Note that 2 of the diagonal elements are negative: Ouch!!
Here is the inverse of D
1.0e+09 *
0.000000428103881 0.001450242932478 -0.000000223256533 0.001450443740640
0.001450242932478 4.960731035829519 -0.000756759768677 4.961411023839190
-0.000000223256533 -0.000756759768677 0.000000117959798 -0.000756863590705
0.001450443740640 4.961411023839190 -0.000756863590705 4.962091107569242
All the diagonal elements are positive. Yippee.
Wait a minute. Not so fast. What if we chose a different minimum eigenvalue for D, say 1e-6, instead of 1e-10.
Here is the partial correlation matrix using D (mineig = 1e-1e10)
1.000000000000000 0.995160970407181 -0.993487907487549 0.995162354269721
0.995160970407181 1.000000000000000 -0.989277623628771 0.999999999746921
-0.993487907487549 -0.989277623628771 1.000000000000000 -0.989277740783460
0.995162354269721 0.999999999746921 -0.989277740783460 1.000000000000000
Here is the partial correlation matrix using mineig = 1e-8 amo8unts6
1.000000000000000 0.100512651870996 -0.629191171229188 0.101907771942626
0.100512651870996 1.000000000000000 -0.067837697192938 0.999997491360146
-0.629191171229188 -0.067837697192938 1.000000000000000 -0.067917378792838
0.101907771942626 0.999997491360146 -0.067917378792838 1.000000000000000
Oh no, changing the minimum eigenvalue from 1e-10 to a hill of beans1e-6 totally changed the partial correlation matrix. But you can clean it up if And the D corresponding to mineig = 1e-6 has no element differing by more than 1e-6 from the D using mineig = 1e-10. If you wanthave a minimum eigenvalue close to 0, things are very sensitive, and I wouldn't put much stock in any of the results.