UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

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

Please Note: Stata graph commands changed with version 8 and this page was developed before version 8 was released and uses Stata 7 graph commands.  Please see How do I use version 7 graph commands in Stata version 8? for information on how to either run these Stata 7 graph commands in Stata version 8, or how you can covert these commands to use Stata 8 syntax.

For the Stata 8 code and output, please click here.
Page 386 Table 16.2
use "c:\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 "c:\cama3\chemicalstd.dta"
listblck type symbol obsno st1 st2 st3 st4 st5 st6 st7

       type   symbol   obsno        st1        st2        st3        st4        st5        st6        st7
  1.      1      dia       1   .9629321  -.0073596    .429067   .2774933    1.28929  -.2373285   .1505716
  2.      1      dow       2   .9629321  -.0073596   .0504785   -.056836    1.33381  -.4419221  -.2165544
  3.      1      stf       3   .9629321  -.5593303  -.2902512    .229732   1.600928  -.4419221  -.0070102
  4.      1       dd       4   .6605985  -.9273108  -.4921651  -.2478812   .4879359  -.2373285   1.289453
  5.      1       uk       5  -.1708183  -.5593303  -.4038277  -.6180316   1.066692  -1.055703  -.6675716
  6.      1      psm       6  -.2464016  -.3753401  -.5931219     .15809  -.2243793  -.8511091    .828598
  7.      1      gra       7  -.2086102  -.3753401  -.8328946  -.7374349   .2208178   -.032735  -.2308523
  8.      1      hpc       8  -.0574432  -.7433205  -.6814593  -.5344493   .0872586  -.2373285   .5966167
  9.      1      mtc       9  -.3597767  -.5593303  -.4164473  -.8687785  -.3579383   .1718586   1.330146
 10.      1      acy      10  -.2086102  -.5593303  -.5931219  -1.071764   .1317783  -.2373285   .6678652
 11.      1       cz      11  -.9644436  -.5593303  -.7571769   .3371949   -.402458  -.6465156   .6544669
 12.      1      ald      12  -1.191194  -.1913498  -.1766747  -.9881818   .3543768  -.6465156  -1.087407
 13.      1      rom      13  -1.002235  -.5593303  -.7319377  -1.215048   .5769752  -.6465156   -.739045
 14.      1      rei      14  -1.493527  -.5593303   .2397728  -1.943408  -1.337372   -.032735  -.1899908
 15.      2      hum      15  -.4731519   3.672445   2.902511   2.534216   .6660147   2.217794  -.1347351
 16.      2      hca      16   -.586527   .3606208   1.388158    1.23272   1.066692   2.422388  -1.978911
 17.      2      nme      17  -.7754853   .9125916   2.763696   1.364064   .2653374   1.808607   -.840383
 18.      2      ami      18  -.5487351   .7286013   .6688396   1.041674   .7550541   1.808607  -.8380698
 19.      2      ahs      19   .9251402  -.7433205  -.1009569   .3610757   .6214949   .7856392  -.9651281
 20.      3      lks      20   1.794349  -.0073596  -.1892942  -.1881796  -1.248332  -.4419221   1.536437
 21.      3      win      21   3.003683  -.9273108  -.2271531  -.1881796  -1.203813  -.2373285    1.37083
 22.      3      sgl      22  -.2086102   1.648552  -.9086123   1.328242  -1.470931  -.8511091  -1.708569
 23.      3      slc      23  -.2086102   .7286013   .1388157   .2536127  -1.203813  -.4419221  -.6954768
 24.      3       kr      24  -.0952351  -.3753401  -.5300238   .5760016   -1.51545  -.8511091   .3701242
 25.      3       sa      25  -.4731519    .544611    -.65622  -1.035943   -1.55997  -.6465156   1.504596
Page 387 Figure 16.3
reshape long st , i(obsno) j(variable) 
graph st variable if obsno==1, c(l) ylabel(-3 -2.5 to 2.5) yline(0) xlabel(1 2 to 7)
Page 388 Figure 16.4
gen sta = st
replace sta = -1*st if variable == 1 | variable == 7
separate sta, by(obsno)
graph sta15 sta16 sta17 sta18 sta19 sta20 sta21 variable, c(lllllll) ylabel(-3 -2.5 to 2.5) yline(0) xlabel(1 2 to 7)
Page 399 Figure 16.9
NOTE: We were unable to reproduce this graph. However, this is easily done in Stata 8; please see the link at the top of the page.
Page 401 Table 16.4
NOTE: We were unable to reproduce this table.
Page 403 Figure 16.10
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