|
|
|
||||
|
|
|||||
Chapter 12, page 257 shows how to perform an interaction contrast using the data from chapter 10.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap10, clear
This interaction contrast compares a2 with a3 for factor A and compares b1 with b2 for factor B. First, let's create the contrasts for factor a.
generate acomp1 = a recode acomp1 1=0 2=-1 3=1
Let's create a second comparison for factor a that is orthogonal to the first comparison.
generate acomp2 = a recode acomp2 1=2 2=-1 3=-1
Now let's create the contrast for factor b.
generate bcomp1 = b recode bcomp1 1=1 2=-1
Now, let's show the original anova.
anova errors a b a*b
Number of obs = 24 R-squared = 0.4590
Root MSE = 4.28174 Adj R-squared = 0.3087
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 280.00 5 56.00 3.05 0.0361
|
a | 112.00 2 56.00 3.05 0.0721
b | 24.00 1 24.00 1.31 0.2675
a*b | 144.00 2 72.00 3.93 0.0384
|
Residual | 330.00 18 18.3333333
-----------+----------------------------------------------------
Total | 610.00 23 26.5217391
Now, let's perform the interaction comparison by taking the original anova command above and replacing a with acomp1 acomp2 and b with bcomp1, and include contin(acomp1 acomp2 bcomp1).
anova errors acomp1 acomp2 bcomp1 acomp1*bcomp1 acomp2*bcomp1, contin(acomp1 acomp2 bcomp1)
Number of obs = 24 R-squared = 0.4590
Root MSE = 4.28174 Adj R-squared = 0.3087
Source | Partial SS df MS F Prob > F
--------------+----------------------------------------------------
Model | 280.00 5 56.00 3.05 0.0361
|
acomp1 | 4.00 1 4.00 0.22 0.6460
acomp2 | 108.00 1 108.00 5.89 0.0259
bcomp1 | 24.00 1 24.00 1.31 0.2675
acomp1*bcomp1 | 36.00 1 36.00 1.96 0.1781
acomp2*bcomp1 | 108.00 1 108.00 5.89 0.0259
|
Residual | 330.00 18 18.3333333
--------------+----------------------------------------------------
Total | 610.00 23 26.5217391
The effect acomp1*bcomp1 corresponds to the interaction contrast on page 257. Also note that the effect acomp2*bcomp1 is the same as the contrast shown on page 259.
On page 264-265 Keppel shows another interaction contrast. We compute the coefficients for these contrasts below.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap12, clear generate acomp1 = a recode acomp1 1=1 2=-.5 3=-.5 generate acomp2 = a recode acomp2 1=0 2=1 3=-1 generate bcomp1 = b recode bcomp1 1=0 2= 1 3=-1 generate bcomp2 = b recode bcomp2 1=2 2=-1 3=-1
First we show the basic anova.
anova memory a b a*b
Number of obs = 45 R-squared = 0.6728
Root MSE = 1.32098 Adj R-squared = 0.6001
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 129.199997 8 16.1499997 9.26 0.0000
|
a | 32.9333331 2 16.4666665 9.44 0.0005
b | 72.9333359 2 36.466668 20.90 0.0000
a*b | 23.3333283 4 5.83333208 3.34 0.0199
|
Residual | 62.8200027 36 1.74500008
-----------+----------------------------------------------------
Total | 192.02 44 4.36409091
Now we replace a with acomp1 acomp2 and b with bcomp1 bcomp2 and add contin(acomp1 acomp2 bcomp1 bcomp2). We see the effect acomp1*bcomp1 corresponds to the effect shown by Keppel at the top of page 265.
anova memory acomp1 acomp2 bcomp1 bcomp2 acomp1*bcomp1 acomp1*bcomp2 acomp2*bcomp1
acomp2*bcomp2, contin(acomp1 acomp2 bcomp1 bcomp2)
Number of obs = 45 R-squared = 0.6728
Root MSE = 1.32098 Adj R-squared = 0.6001
Source | Partial SS df MS F Prob > F
--------------+----------------------------------------------------
Model | 129.199997 8 16.1499997 9.26 0.0000
|
acomp1 | 32.40 1 32.40 18.57 0.0001
acomp2 | .533333079 1 .533333079 0.31 0.5838
bcomp1 | 56.0333359 1 56.0333359 32.11 0.0000
bcomp2 | 16.90 1 16.90 9.68 0.0036
acomp1*bcomp1 | 14.0166648 1 14.0166648 8.03 0.0075
acomp1*bcomp2 | 8.44999752 1 8.44999752 4.84 0.0343
acomp2*bcomp1 | .050000191 1 .050000191 0.03 0.8665
acomp2*bcomp2 | .816665777 1 .816665777 0.47 0.4983
|
Residual | 62.8200027 36 1.74500008
--------------+----------------------------------------------------
Total | 192.02 44 4.36409091
On pages 269-270, Keppel illustrates another interaction contrast. Below we use the chap10 file and create acomp1 for the contrast of interest for a, and acomp2 as a second orthogonal contrast.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap10, clear generate acomp1 = a recode acomp1 1=-1 2=0 3=1 generate acomp2 = a recode acomp2 1=-1 2=2 3=-1
Now we generate bcomp1 as the comparison on b.
generate bcomp1 = b recode bcomp1 1=1 2=-1
Now, we run the regular anova.
anova errors a b a*b
Number of obs = 24 R-squared = 0.4590
Root MSE = 4.28174 Adj R-squared = 0.3087
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 280.00 5 56.00 3.05 0.0361
|
a | 112.00 2 56.00 3.05 0.0721
b | 24.00 1 24.00 1.31 0.2675
a*b | 144.00 2 72.00 3.93 0.0384
|
Residual | 330.00 18 18.3333333
-----------+----------------------------------------------------
Total | 610.00 23 26.5217391
Now, we replace a with acomp1 acomp2 and b with bcomp1 from the above anova, and we see the effect acomp1*bcomp1 corresponds to that shown by Keppel at the top of page 270.
anova errors acomp1 acomp2 bcomp1 acomp1*bcomp1 acomp2*bcomp1, contin(acomp1 acomp2 bcomp1)
Number of obs = 24 R-squared = 0.4590
Root MSE = 4.28174 Adj R-squared = 0.3087
Source | Partial SS df MS F Prob > F
--------------+----------------------------------------------------
Model | 280.00 5 56.00 3.05 0.0361
|
acomp1 | 100.00 1 100.00 5.45 0.0313
acomp2 | 12.00 1 12.00 0.65 0.4291
bcomp1 | 24.00 1 24.00 1.31 0.2675
acomp1*bcomp1 | 144.00 1 144.00 7.85 0.0118
acomp2*bcomp1 | 0.00 1 0.00 0.00 1.0000
|
Residual | 330.00 18 18.3333333
--------------+----------------------------------------------------
Total | 610.00 23 26.5217391
On pages 270 to 274 Keppel shows how to perform a partial interaction that compares a1 versus a2 and a3 by b. We start by creating a variable acomp1 corresponding to this comparison, and creating acomp2 which is orthogonal to acomp1.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap12, clear generate acomp1 = a recode acomp1 1=-2 2= 1 3=1 generate acomp2 = a recode acomp2 1= 0 2=-1 3=1
Now we run the regular anova.
anova memory a b a*b
Number of obs = 45 R-squared = 0.6728
Root MSE = 1.32098 Adj R-squared = 0.6001
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 129.199997 8 16.1499997 9.26 0.0000
|
a | 32.9333331 2 16.4666665 9.44 0.0005
b | 72.9333359 2 36.466668 20.90 0.0000
a*b | 23.3333283 4 5.83333208 3.34 0.0199
|
Residual | 62.8200027 36 1.74500008
-----------+----------------------------------------------------
Total | 192.02 44 4.36409091
Now, we replace a with acomp1 acomp2 and add contin(acomp1 acomp2). We can see that the acomp1*b effect corresponds to the result Keppel found on page 274.
anova memory acomp1 acomp2 b acomp1*b acomp2*b, contin(acomp1 acomp2)
Number of obs = 45 R-squared = 0.6728
Root MSE = 1.32098 Adj R-squared = 0.6001
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 129.199997 8 16.1499997 9.26 0.0000
|
acomp1 | 32.40 1 32.40 18.57 0.0001
acomp2 | .533333079 1 .533333079 0.31 0.5838
b | 72.9333359 2 36.466668 20.90 0.0000
acomp1*b | 22.4666623 2 11.2333312 6.44 0.0041
acomp2*b | .866665967 2 .433332984 0.25 0.7814
|
Residual | 62.8200027 36 1.74500008
-----------+----------------------------------------------------
Total | 192.02 44 4.36409091
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