Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: extract values from kdensity graphic


From   [email protected] (Brendan Halpin)
To   [email protected]
Subject   Re: st: extract values from kdensity graphic
Date   Thu, 03 May 2012 19:11:11 +0100

To chime in with another observation: as mentioned above cluster
analysis may help automate this, but neither manipulating the density
estimates nor cluster analysis will necessarily identify groups that are
relatively close to each other.

The code below simulates four groups with scores with different mean and
standard deviation. The first two are relatively close, the latter two
are futher apart. As you will see the kernel plot shows two to three
groups, amalgamating the first two. Clustering seems to do at least as
well as manually dividing on the basis of the troughs of the density
plot, but neither clustering nor the density plot can recover the first
two groups.

Playing around with it, it seems to me that clustering works reasonably
well, at least compared with the kdensity default. A great deal depends
on the patterns in your data: given these are lab measurements, they
might have a simpler, clearer and more stable structure than most social
science data, so an automated way of grouping them may well be
effective. 


Brendan


Code: 

set obs 1000

gen type4 = 1+int(uniform()*4)

gen     x =  1 + rnormal()*0.4  if type4==1
replace x =  2 + rnormal()*0.2  if type4==2
replace x =  4 + rnormal()*0.4  if type4==3
replace x = 10 + rnormal()*1.25 if type4==4

histogram x

kdensity x

cluster wards x

cluster generate g = groups(3 4)

tab type4 g3
tab type4 g4

-- 
Brendan Halpin,   Department of Sociology,   University of Limerick,   Ireland
Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x 3147
mailto:[email protected]    ULSociology on Facebook: http://on.fb.me/fjIK9t
http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index