Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • After cluster analysis: return distance from cluster center or data point closest to center

    Hi,
    I am wondering if there is an easy way to obtain the data points that are closest to the centroid of each cluster after running cluster kmeans?
    If it was possible to calculate each observation's (Euclidean) distance from the centroid of the cluster this would of course suffice.
    Thanks for any suggestions,
    Jerg

  • #2
    Did you try the -keepcenters- option?
    You should:

    1. Read the FAQ carefully.

    2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

    3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

    4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

    Comment


    • #3
      Roberto: Thanks for the suggestion. As I understand it, -keepcenters- gives me the centroids of each cluster. I would then still have to calculate the Eucledian distance of each observation within each cluster to the respective centroid. I was hoping for a way around that. But it seems there is none.

      Comment


      • #4
        Originally posted by Jerg Gutmann View Post
        Hi,
        I am wondering if there is an easy way to obtain the data points that are closest to the centroid of each cluster after running cluster kmeans?
        If it was possible to calculate each observation's (Euclidean) distance from the centroid of the cluster this would of course suffice.
        Thanks for any suggestions,
        Jerg
        Hi Jerg, did you find a way to get that? Or at least to make keepcenters work. Thanks!

        Comment

        Working...
        X