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]

st: From: Matthew Baker <[email protected]>


From   [email protected]
To   [email protected]
Subject   st: From: Matthew Baker <[email protected]>
Date   Thu, 13 Feb 2014 11:35:32 -0500

Dear listers --

I am trying to draw a dendrogram using Stata's cluster dendrogram
command. The catch is I am trying to do this for data not generated by
a Stata clustering command. I.e., the data has a known grouping
structure and known information on the length of branches.

The data structure I have in mind is like the following example:

/* Begin example */
/* Fictional "clustered" data */
clear all
mata:
n=8
cvar=J(2^n,0,.)
for (i=0;i<=n;i++) cvar=((1::2^(n-i))#J(2^(i),1,1)),cvar
end
getmata (cvar*)=cvar

/* Make fictional branch lengths */

forvalues i=1/9 {
bysort cvar`i': gen last`i'=_n==_N
gen branchlength`i'=runiform() if last`i'
bysort cvar`i': egen dummyvar=mean(branchlength`i')
replace branchlength`i'=dummyvar
drop dummyvar
}
/* Normalize lengths */
egen sum=rowtotal(branchlength1-branchlength9)
forvalues i=1/9 {
replace branchlength`i'=branchlength`i'/sum
}

/* End example */

To reiterate, my question is how I would go about drawing a dendrogram
built to reflect the branches and clusters in this data.

All the best,

Matt Baker


-- 
Dr. Matthew J. Baker
Department of Economics
Hunter College and the Graduate Center, CUNY
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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