I am trying to locate where the kmeans function creates and assesses the covariance matrix from the input data set x. I want to override it and give it my own covariance matrix, because the unmodified one struggles with negative eigenvalues.
Another fix would be to find a function that does kmeans clustering with a modified covariance matrix as an inbuilt function, but I haven't found any such function yet.
Thanks in advance!
Function in question:
(stat:::kmeans)
KMeans uses neither a covariance matrix, nor a distance matrix, nor eigenvalues.
On a proper distance matrix, negative eigenvalues cannot occur.
You must be referring to some other algorithm. Reread kmeans - no covariance matrix, no eigenvalues.