UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Textbook Examples
Computer-Aided Multivariate Analysis by Afifi and Clark
Chapter 16: Cluster Analysis

Please note that this page contains the code and the output for use with Stata version 8. For the Stata 7 code and output, please click here.
Table 16.2, page 386.
use http://www.ats.ucla.edu/stat/stata/examples/cama3/companies.dta, clear

egen st1 = std(ror5)
egen st2 = std(de)
egen st3 = std(salesgr5)
egen st4 = std(eps5)
egen st5 = std(npm1)
egen st6 = std(pe)
egen st7 = std(payoutr1)
save compstd, replace
clist st1 - st7

           st1        st2        st3        st4        st5        st6        st7
  1.  .9629321  -.0073596    .429067   .2774933    1.28929  -.2373285   .1505716
  2.  .9629321  -.0073596   .0504785   -.056836    1.33381  -.4419221  -.2165544
  3.  .9629321  -.5593303  -.2902512    .229732   1.600928  -.4419221  -.0070102
  4.  .6605985  -.9273108  -.4921651  -.2478812   .4879359  -.2373285   1.289453
  5. -.1708183  -.5593303  -.4038277  -.6180316   1.066692  -1.055703  -.6675716
  6. -.2464016  -.3753401  -.5931219     .15809  -.2243793  -.8511091    .828598
  7. -.2086102  -.3753401  -.8328946  -.7374349   .2208178   -.032735  -.2308523
  8. -.0574432  -.7433205  -.6814593  -.5344493   .0872586  -.2373285   .5966167
  9. -.3597767  -.5593303  -.4164473  -.8687785  -.3579383   .1718586   1.330146
 10. -.2086102  -.5593303  -.5931219  -1.071764   .1317783  -.2373285   .6678652
 11. -.9644436  -.5593303  -.7571769   .3371949   -.402458  -.6465156   .6544669
 12. -1.191194  -.1913498  -.1766747  -.9881818   .3543768  -.6465156  -1.087407
 13. -1.002235  -.5593303  -.7319377  -1.215048   .5769752  -.6465156   -.739045
 14. -1.493527  -.5593303   .2397728  -1.943408  -1.337372   -.032735  -.1899908
 15. -.4731519   3.672445   2.902511   2.534216   .6660147   2.217794  -.1347351
 16.  -.586527   .3606208   1.388158    1.23272   1.066692   2.422388  -1.978911
 17. -.7754853   .9125916   2.763696   1.364064   .2653374   1.808607   -.840383
 18. -.5487351   .7286013   .6688396   1.041674   .7550541   1.808607  -.8380698
 19.  .9251402  -.7433205  -.1009569   .3610757   .6214949   .7856392  -.9651281
 20.  1.794349  -.0073596  -.1892942  -.1881796  -1.248332  -.4419221   1.536437
 21.  3.003683  -.9273108  -.2271531  -.1881796  -1.203813  -.2373285    1.37083
 22. -.2086102   1.648552  -.9086123   1.328242  -1.470931  -.8511091  -1.708569
 23. -.2086102   .7286013   .1388157   .2536127  -1.203813  -.4419221  -.6954768
 24. -.0952351  -.3753401  -.5300238   .5760016   -1.51545  -.8511091   .3701242
 25. -.4731519    .544611    -.65622  -1.035943   -1.55997  -.6465156   1.504596
Figure 16.3, page 387.
reshape long st , i(obsno) j(variable) 
graph twoway (line st variable if obsno ==1), yline(0) ylab(-3 -2.5 to 2.5) ///
	xlabel(1 "ROR5" 2 "D/E" 3 "SALESGR5" 4 "EPS5" 5 "NPM1" 6 "P/E" 7 "PAYOUR1", ///
	angle(veritcal)) ytitle("Standardized Variable")
Figure 16.4, page 388.
gen sta = st
replace sta = -1*st if variable == 1 | variable == 7
separate sta, by(obsno)
graph twoway (line sta15 sta16 sta17 sta18 sta19 sta20 sta21 variable), yline(0) ///
	ylabel(-3 -2 to 4) xlab(1 "ROR5" 2 "D/E" 3 "SALESGR5" 4 "EPS5" 5 "NPM1" 6 "P/E" 7 "PAYOUR1", ///
	angle(veritcal)) ytitle("Standardized Variable")
Figure 16.9, page 399.
use compstd.dta, clear

cluster cent  st1 st2 st3 st4 st5 st6 st7
cluster tree
Table 16.4, page 401.
NOTE: We were unable to reproduce this table.
Figure 16.10, page 403.
NOTE: We were unable to reproduce this graph.

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California