|
|
|
||||||||
|
Stat Computing > Stata > Textbook Examples > Applied Linear Statistical Models, by Neter, Kutner, Nachtsheim, and Wasserman
Stata Textbook Examples
| |||||||||
| (a) | (b) |
![]() |
![]() |
F tests of the interaction and main effects, p. 830-831.
Note the F tests are included in the standard output and have been italicized for illustration.
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
Creating the dummy and interaction variables for the Regression model of the Bakery data, p. 833.
gen x1 = 0 recode x1 0 = 1 if height == 1 recode x1 0 = -1 if height == 3 gen x2 = 0 recode x2 0 = 1 if height == 2 recode x2 0 = -1 if height == 3 gen x3 = -1 recode x3 -1 = 1 if width == 1 gen x1x3 = x1*x3 gen x2x3 = x2*x3 list height width x1 x2 x3 x1x3 x2x3
+---------------------------------------------+
| height width x1 x2 x3 x1x3 x2x3 |
|---------------------------------------------|
1. | 1 1 1 0 1 1 0 |
2. | 1 1 1 0 1 1 0 |
3. | 1 2 1 0 -1 -1 0 |
4. | 1 2 1 0 -1 -1 0 |
5. | 2 1 0 1 1 0 1 |
|---------------------------------------------|
6. | 2 1 0 1 1 0 1 |
7. | 2 2 0 1 -1 0 -1 |
8. | 2 2 0 1 -1 0 -1 |
9. | 3 1 -1 -1 1 -1 -1 |
10. | 3 1 -1 -1 1 -1 -1 |
|---------------------------------------------|
11. | 3 2 -1 -1 -1 1 1 |
12. | 3 2 -1 -1 -1 1 1 |
+---------------------------------------------+
Table 19.10a, p. 836.
list height width store sales x1 x2 x3 x1x3 x2x3
+-------------------------------------------------------------+
| height width store sales x1 x2 x3 x1x3 x2x3 |
|-------------------------------------------------------------|
1. | 1 1 1 47 1 0 1 1 0 |
2. | 1 1 2 43 1 0 1 1 0 |
3. | 1 2 1 46 1 0 -1 -1 0 |
4. | 1 2 2 40 1 0 -1 -1 0 |
5. | 2 1 1 62 0 1 1 0 1 |
|-------------------------------------------------------------|
6. | 2 1 2 68 0 1 1 0 1 |
7. | 2 2 1 67 0 1 -1 0 -1 |
8. | 2 2 2 71 0 1 -1 0 -1 |
9. | 3 1 1 41 -1 0 1 -1 0 |
10. | 3 1 2 39 -1 0 1 -1 0 |
|-------------------------------------------------------------|
11. | 3 2 1 42 -1 0 -1 1 0 |
12. | 3 2 2 46 -1 0 -1 1 0 |
+-------------------------------------------------------------+
Table 19.10c, p. 836.
anova sales x1 x2 x3 x1x3 x2x3, seq cont( x1 x2 x3 x1x3 x2x3)
Number of obs = 12 R-squared = 0.9622
Root MSE = 3.21455 Adj R-squared = 0.9308
Source | Seq. SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 1580 5 316 30.58 0.0003
|
x1 | 8 1 8 0.77 0.4128
x2 | 1536 1 1536 148.65 0.0000
x3 | 12 1 12 1.16 0.3226
x1x3 | 18 1 18 1.74 0.2350
x2x3 | 6 1 6 0.58 0.4749
|
Residual | 62 6 10.3333333
-----------+----------------------------------------------------
Total | 1642 11 149.272727
Pooling sums of squares in the Bakery Sales example, p. 837.
anova sales height width
Number of obs = 12 R-squared = 0.9476
Root MSE = 3.27872 Adj R-squared = 0.9280
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 1556 3 518.666667 48.25 0.0000
|
height | 1544 2 772 71.81 0.0000
width | 12 1 12 1.12 0.3216
|
Residual | 86 8 10.75
-----------+----------------------------------------------------
Total | 1642 11 149.272727
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