UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Textbook Examples
Experimental Design by Roger Kirk
Chapter 11: Hierarchical Designs

Table 11.2-1, page 480.
use http://www.ats.ucla.edu/stat/stata/examples/kirk/crh28, clear

tabdisp order b, cellvar(y) by(a)

----------+-----------------------------------------------
a and     |                       b                       
order     |    1     2     3     4     5     6     7     8
----------+-----------------------------------------------
1         |
        1 |    3     1     5     2                        
        2 |    6     2     6     3                        
        3 |    3     2     5     4                        
        4 |    3     2     6     3                        
----------+-----------------------------------------------
2         |
        1 |                            7     4     7    10
        2 |                            8     5     8    10
        3 |                            7     4     9     9
        4 |                            6     3     8    11
----------+-----------------------------------------------

table a b, cont(sum y)

----------+-----------------------------------------------
          |                       b                       
        a |    1     2     3     4     5     6     7     8
----------+-----------------------------------------------
        1 |   15     7    22    12                        
        2 |                           28    16    32    40
----------+-----------------------------------------------
Table 9.3-2, page 370, and bottom part of Table 11.2-3, page 482.
anova y a / b|a /

                     Number of obs =      32     R-squared     =  0.9214
                     Root MSE      = .877971     Adj R-squared =  0.8985

            Source |  Partial SS    df       MS           F     Prob > F
        -----------+----------------------------------------------------
             Model |      217.00     7       31.00      40.22     0.0000
                   |
                 a |      112.50     1      112.50       6.46     0.0440
               b|a |      104.50     6  17.4166667   
        -----------+----------------------------------------------------
               b|a |      104.50     6  17.4166667      22.59     0.0000
                   |
          Residual |       18.50    24  .770833333   
        -----------+----------------------------------------------------
             Total |      235.50    31  7.59677419
Top part of Table 11.2-3, page 482.
anova y a

                           Number of obs =      32     R-squared     =  0.4777
                           Root MSE      = 2.02485     Adj R-squared =  0.4603

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |      112.50     1      112.50      27.44     0.0000
                         |
                       a |      112.50     1      112.50      27.44     0.0000
                         |
                Residual |      123.00    30        4.10   
              -----------+----------------------------------------------------
                   Total |      235.50    31  7.59677419 
Table 11.8-2, page 502.
use http://www.ats.ucla.edu/stat/stata/examples/kirk/crh28, clear

tabdisp order b, cellvar(y) by(a)

----------+-----------------------------------------
a and     |                    b                    
order     |    1     3     4     5     6     7     8
----------+-----------------------------------------
1         |
        1 |    3     5     2                        
        2 |    6     6     3                        
        3 |    3     5     4                        
        4 |    3           3                        
----------+-----------------------------------------
2         |
        1 |                      7     4     7    10
        2 |                      8     5     8    10
        3 |                      7     4     9     9
        4 |                      6     3          11
----------+-----------------------------------------

table b a, cont(mean y)

----------+-----------------
          |        a        
        b |       1        2
----------+-----------------
        1 |    3.75         
        3 | 5.33333         
        4 |       3         
        5 |                7
        6 |                4
        7 |                8
        8 |               10
----------+-----------------
Table 11.8-3, page 503.
anova y a / b|a /

                     Number of obs =      26     R-squared     =  0.8976
                     Root MSE      = .957427     Adj R-squared =  0.8652

            Source |  Partial SS    df       MS           F     Prob > F
        -----------+----------------------------------------------------
             Model |  152.621795     6  25.4369658      27.75     0.0000
                   |
                 a |  64.7701564     1  64.7701564       3.86     0.1066
               b|a |  83.8924242     5  16.7784848   
        -----------+----------------------------------------------------
               b|a |  83.8924242     5  16.7784848      18.30     0.0000
                   |
          Residual |  17.4166667    19  .916666667   
        -----------+----------------------------------------------------
             Total |  170.038462    25  6.80153846

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.