{"id":415,"date":"2010-03-16T19:43:07","date_gmt":"2010-03-17T00:43:07","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=415"},"modified":"2010-03-16T19:46:41","modified_gmt":"2010-03-17T00:46:41","slug":"cluster-analysis-finding-groups-in-data","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/cluster-analysis-finding-groups-in-data\/","title":{"rendered":"Cluster Analysis: Finding Groups in Data"},"content":{"rendered":"<p>Cluster analysis is one of those techniques I don&#8217;t get to use very often. About once every couple of years someone will be doing a study of types of companies, patients or clients and have a need for a cluster analysis. The best description I read of cluster analysis came from a book many years ago, by Kaufman &amp; Rousseuw that began,<\/p>\n<p><em>&#8220;Cluster analysis is the art of finding groups in data.&#8221;<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-416\" title=\"twizzler_full_prod\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2010\/03\/twizzler_full_prod.jpg\" alt=\"twizzler_full_prod\" width=\"240\" height=\"220\" \/>It falls into that gray area between descriptive statistics, that asks how many people like programming and twizzlers and inferential statistics, which question the daily consumption of twizzlers by programmers and non-programmers and whether any difference between the two groups is greater than would be predicted by chance 95% of the time.<\/p>\n<p>Cluster analysis is an exploratory method, usually, and is incorporated in what the young &#8216;uns now call data mining.<\/p>\n<p>However, it can also be confirmatory in a hypothesis-testing sort of way. Say, I hypothesize that there are three groups of people who have eating disorders, anorexia, bulimia and anorexic-bulemics and they differ in their treatment. I can classify people in those three groups using a cluster analysis, then do an ANOVA or MANOVA on the clusters to see if there are in fact significant differences among clusters in days hospitalized, total inpatient costs, total outpatient costs or other variables of interest.<\/p>\n<p>Personally, when I think of cluster analysis the first type that always comes to mind is the partition, k-means clustering method. I suppose that says a little about my level of weirdness that there actually IS a type that comes to mind. The second type, unless you were dying to know, is fuzzy clusters, because it is something I have been pondering lately. Fuzzy clusters are NOT, contrary to the vicious rumors spread by my enemies, what can be found under my bed because I last cleaned sometime during the Mesozic era, but rather, a method where observations are allowed to fall into two clusters at once. Can people be only anorexic or bulimic or can they fall in both groups? Fuzzy clustering says yes. Kmeans partitions says, no. You can perhaps, though, have a third group of people who are anorexic-bulimic.<\/p>\n<p>Rambling note: When <a href=\"http:\/\/search.espn.go.com\/maria-burns-ortiz\/\">Maria<\/a> came home for Christmas after having gotten her first job as a sportswriter, someone asked her if she had a favorite sport, she responded:<\/p>\n<p><em>&#8220;Well, since Sports Illustrated is paying me to write about football, this week my favorite sport is football.&#8221;<\/em><\/p>\n<p>Similarly, since I am meeting with someone tomorrow on how to do a cluster analysis with Stata, it has now become my favorite software for cluster analysis.<\/p>\n<p>How to do it:<\/p>\n<p>Either from the STATISTICS menu select MULTIVARIATE ANALYSIS &gt; CLUSTER ANALYSIS &gt; CLUSTER DATA &gt; KMEANS<\/p>\n<p>and then from the pop-up window select the number of groups and the variables<\/p>\n<p>OR type the following in the command window<\/p>\n<p><strong>cluster kmeans<\/strong> <em> list-of-variables<\/em> , <strong>k<\/strong>(#) <strong>measure<\/strong>(type) <strong>start<\/strong>(seed)<\/p>\n<p>FOR EXAMPLE, if I wanted to use data on anorexia and bulimia looking for two groups I would do this<\/p>\n<p>cluster kmeans fast binge vomit purge hyper mens weight, k(2) measure(L2) start(krandom)<\/p>\n<p>The default similarity\/dissimilarity measure is Euclidean and you started with a random seed. The output of cluster analysis in Stata might be disconcerting to some people by virtue of the fact that there really isn&#8217;t any. It will come back and say something singularly unenlightening like &#8220;cluster name: _clus_1 &#8221; and that&#8217;s it .<\/p>\n<p>The first thing I recommend adding to your cluster analysis command is the keepcenters option, so my command looks like this:<\/p>\n<p>cluster kmeans fast binge vomit purge hyper mens weight, k(2) measure(L2) start(krandom) keepcen<br \/>\nI am assuming you have a relatively modest number of observations, like I do, so you can open up your Stata data file in the Data editor and take a look at it. When I scroll down to the bottom I find that the last two observations are the means for each of the variables for the two clusters. My first cluster has very low values for body weight,\u00a0 moderate values for absence of menses, and high values for fasting, binging, vomiting, purging and hyperactivity. My second cluster has medium body weight, medium scores on hyperactivity, low values for amenorrhea and fasting, and high values for binging, vomiting and purging.<\/p>\n<p>It is starting to appear that I have two groups, anorexics and bulimics. My next step in this exploration would be to use the tabstat command, by cluster to see if other expected (or unexpected) differences emerge.<br \/>\nCurrently, there has been an unexpected emergence of my daughter, Jenn, who is neither anorexic nor bulimic, in the lobby downstairs, so we are off to conduct our own experiment to explore whether Chardonnay is best grouped with angel hair pasta primavera or does Pinot Noir fit better in this cluster.<\/p>\n<p>I&#8217;ll let you know.<\/p>\n<p><a href=\"http:\/\/www.amazon.com\/s\/ref=rdr_ext_aut?_encoding=UTF8&amp;index=books&amp;field-author=Leonard%20Kaufman\"><br \/>\n<\/a><a href=\"http:\/\/www.amazon.com\/s\/ref=rdr_ext_aut?_encoding=UTF8&amp;index=books&amp;field-author=Peter%20J.%20Rousseeuw\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cluster analysis is one of those techniques I don&#8217;t get to use very often. About once every couple of years someone will be doing a study of types of companies, patients or clients and have a need for a cluster analysis. The best description I read of cluster analysis came from a book many years&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-415","post","type-post","status-publish","format-standard","hentry","category-statistics"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/comments?post=415"}],"version-history":[{"count":4,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/415\/revisions"}],"predecessor-version":[{"id":420,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/415\/revisions\/420"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}