UCLA Academic Technology Services HomeServicesClassesContactJobs

Stata Textbook Examples
Applied Linear Statistical Models by Neter, Kutner, et. al.
Chapter 20: Analysis of Factor Effects in Two-Factor Studies-Equal Sample Sizes

Inputting the Castle Bakery data, table 19.7, p. 818.
input sales height width store
  47  1  1  1
  43  1  1  2
  46  1  2  1
  40  1  2  2
  62  2  1  1
  68  2  1  2
  67  2  2  1
  71  2  2  2
  41  3  1  1
  39  3  1  2
  42  3  2  1
  46  3  2  2
end

Fig. 20.2a, p. 857. 

clear
input hmean
44
67
42
end
label define fa 44 "A1" 67 "A2" 42 "A3"
label values hmean fa
qnorm h, mlabel(hmean)

Fig. 20.2b, p. 857. 

clear
input wmean
50
52
end
label define fb 50 "B1" 52 "B2"
label values wmean fb
qnorm w, mlabel(wmean)xscale(r(50 52)) yscale(r(40 60)) ylabel(#3)

Table 20.1 and confidence intervals for main effects of height and for the interaction effects, p. 858-859. This uses a user-written program tukeyhsd and it can be downloaded via "findit tukeyhsd".

anova sales height width height*width

                           Number of obs =      12     R-squared     =  0.9622
                           Root MSE      = 3.21455     Adj R-squared =  0.9308

                  Source |  Partial SS    df       MS           F     Prob > F
            -------------+----------------------------------------------------
                   Model |        1580     5         316      30.58     0.0003
                         |
                  height |        1544     2         772      74.71     0.0001
                   width |          12     1          12       1.16     0.3226
            height*width |          24     2          12       1.16     0.3747
                         |
                Residual |          62     6  10.3333333   
            -------------+----------------------------------------------------
                   Total |        1642    11  149.272727   

tukeyhsd height

Tukey HSD pairwise comparisons for variable height
studentized range critical value(.05, 3, 6) = 4.3388774
uses harmonic mean sample size =    4.000

                                       mean 
grp vs grp       group means           dif    HSD-test
-------------------------------------------------------
  1 vs   2    44.0000    67.0000     23.0000  14.3099*
  1 vs   3    44.0000    42.0000      2.0000   1.2443 
  2 vs   3    67.0000    42.0000     25.0000  15.5543*

Table 20.3, p. 867 using burr data.

clear
input efficiency spacing speed
  21.6  1.0  300
  22.3  1.0  400
  22.9  1.0  500
  18.7  1.2  300
  19.1  1.2  400
  21.6  1.2  500
  15.8  1.4  300
  17.9  1.4  400
  19.4  1.4  500
  13.2  1.6  300
  16.7  1.6  400
  19.5  1.6  500
end
table spacing speed, contents(mean efficiency)
----------------------------
          |      speed      
  spacing |  300   400   500
----------+-----------------
        1 | 21.6  22.3  22.9
      1.2 | 18.7  19.1  21.6
      1.4 | 15.8  17.9  19.4
      1.6 | 13.2  16.7  19.5
----------------------------

Figure 20.5a, p. 867.
Note: To get the graph below copy and paste the code below into a do file and run all at once.

twoway (line  efficiency spacing if  speed==300, text(18 1.2 "300 rpm")) ///
(line  efficiency spacing if  speed==400, text(18 1.5 "400 rpm")) ///
(line  efficiency spacing if  speed==500, text(21 1.3 "500 rpm")) ///
(scatter  efficiency spacing, mc(navy)), legend(off)


 

Figure 20.5b, p. 867.

twoway (line  efficiency speed if  spacing==float(1.0), text(22.5 350 "1.0 Units")) ///
(line  efficiency speed if  spacing==float(1.2), text(19.5 350 "1.2 Units")) ///
(line  efficiency speed if  spacing==float(1.4), text(17 325 "1.4 Units")) ///
(line  efficiency speed if  spacing==float(1.6), text(15 325 "1.6 Units")) ///
(scatter  efficiency speed, mc(navy)), legend(off)

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.