Fixed-effects Model
Fixed-effects Hypotheses
A Main Effect -- H0: αj = 0 for all j; H1: αj ≠ 0 for some j
B Main Effect -- H0: βk = 0 for all k; H1: βk ≠ 0 for some k
A*B Interaction -- H0: αβjk = 0 for all jk; H1: αβjk ≠ 0 for some jk
Fixed-Effects Expected Mean Squares
Fixed-effects ANOVA Summary Table
Source | SS | df | MS | F | Error Term |
A Main effect | 190.000 | 2 | 95.000 | 1.52 | MS WCell |
B Main effect | 1543.333 | 2 | 771.666 | 12.35 | MS WCell |
A*B Interaction | 1236.667 | 4 | 309.167 | 4.95 | MS WCell |
Within Cells | 2250.000 | 36 | 62.500 | ||
Total | 5220.000 | 44 |
Strength of Association
Omega squared
From the example above:
Random-effects Model
Random-effects Hypotheses
A Main Effect -- H0: σ2α = 0; H1: σ2α ≠ 0
B Main Effect -- H0: σ2β = 0; H1: σ2β ≠ 0
A*B Interaction -- H0: σ2αβ = 0; H1: σ2αβ ≠ 0
Random-Effects Expected Mean Squares
Random-effects ANOVA Summary Table
Source | SS | df | MS | F | Error Term |
A Main effect | 190.000 | 2 | 95.000 | .31 | MS A*B |
B Main effect | 1543.333 | 2 | 771.666 | 2.50 | MS A*B |
A*B Interaction | 1236.667 | 4 | 309.167 | 4.95 | MS WCell |
Within Cells | 2250.000 | 36 | 62.500 | ||
Total | 5220.000 | 44 |
Strength of Association
Partial Intraclass Correlation
Computing variance components:
Variance components from the example above:
Partial intraclass correlations from the example above:
Mixed-effects Model
A fixed & B random Hypotheses
A Main Effect -- H0: αj = 0 for all j; H1: αj ≠ 0 for some j
B Main Effect -- H0: σ2β = 0; H1: σ2β ≠ 0
A*B Interaction -- H0: σ2αβ = 0; H1: σ2αβ ≠ 0
A fixed & B random Expected Mean Squares
A fixed & B random ANOVA Summary Table
Source | SS | df | MS | F | Error Term |
A Main effect | 190.000 | 2 | 95.000 | .31 | MS A*B |
B Main effect | 1543.333 | 2 | 771.666 | 12.35 | MS WCell |
A*B Interaction | 1236.667 | 4 | 309.167 | 4.95 | MS WCell |
Within Cells | 2250.000 | 36 | 62.500 | ||
Total | 5220.000 | 44 |
Why does the fixed variable use interaction as the error term?
According to Hays' (2nd Ed) in a two-way design in which A (the columns) is fixed and B (the rows) is random, the levels of B represent a random sample from the population of possible levels. Hays points out that the deviation of a column mean from the grand mean includes not only column effects and mean error deviation but also includes a deviation due to interaction effect of the cell mean from the grand cell mean (cj - Mc). The reason that this is so is that there is no requirement that the interaction effects sum to zero across the rows when the row treatment effects and thus the the interaction effects are only a random sample of such effects. Thus, column means formed by summing across rows contain not only fixed column effects but also some random interaction effects.
A random & B fixed Hypotheses
A Main Effect -- H0: σ2α = 0; H1: σ2α ≠ 0
B Main Effect -- H0: βk = 0 for all k; H1: βk ≠ 0 for some k
A*B Interaction -- H0: σ2αβ = 0; H1: σ2αβ ≠ 0
A random & B fixed Expected Mean Squares
A random & B fixed ANOVA Summary Table
Source | SS | df | MS | F | Error Term |
A Main effect | 190.000 | 2 | 95.000 | 1.52 | MS WCell |
B Main effect | 1543.333 | 2 | 771.666 | 2.50 | MS A*B |
A*B Interaction | 1236.667 | 4 | 309.167 | 4.95 | MS WCell |
Within Cells | 2250.000 | 36 | 62.500 | ||
Total | 5220.000 | 44 |
Using Stata
Example problem taken from Completely Randomized Factorial Design
use http://www.philender.com/courses/data/crf33, clear anova y a b a#b /* fixed effects model */ Number of obs = 45 R-squared = 0.5690 Root MSE = 7.90569 Adj R-squared = 0.4732 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 2970 8 371.25 5.94 0.0001 | a | 190 2 95 1.52 0.2324 b | 1543.33333 2 771.666667 12.35 0.0001 a#b | 1236.66667 4 309.166667 4.95 0.0028 | Residual | 2250 36 62.5 -----------+---------------------------------------------------- Total | 5220 44 118.636364 anova y a b / a#b / /* random effects model */ Number of obs = 45 R-squared = 0.5690 Root MSE = 7.90569 Adj R-squared = 0.4732 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 2970 8 371.25 5.94 0.0001 | a | 190 2 95 0.31 0.7514 b | 1543.33333 2 771.666667 2.50 0.1979 a#b | 1236.66667 4 309.166667 -----------+---------------------------------------------------- a#b | 1236.66667 4 309.166667 4.95 0.0028 | Residual | 2250 36 62.5 -----------+---------------------------------------------------- Total | 5220 44 118.636364 anova y a b a#b /* mixed effects model: a fixed; b random */ Number of obs = 45 R-squared = 0.5690 Root MSE = 7.90569 Adj R-squared = 0.4732 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 2970 8 371.25 5.94 0.0001 | a | 190 2 95 1.52 0.2324 b | 1543.33333 2 771.666667 12.35 0.0001 a#b | 1236.66667 4 309.166667 4.95 0.0028 | Residual | 2250 36 62.5 -----------+---------------------------------------------------- Total | 5220 44 118.636364 test a / a#b Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- a | 190 2 95 0.31 0.7514 a#b | 1236.66667 4 309.166667 anova y a b a#b /* mixed effects model: b fixed; a random */ Number of obs = 45 R-squared = 0.5690 Root MSE = 7.90569 Adj R-squared = 0.4732 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 2970 8 371.25 5.94 0.0001 | a | 190 2 95 1.52 0.2324 b | 1543.33333 2 771.666667 12.35 0.0001 a#b | 1236.66667 4 309.166667 4.95 0.0028 | Residual | 2250 36 62.5 -----------+---------------------------------------------------- Total | 5220 44 118.636364 test b / a#b Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- b | 1543.33333 2 771.666667 2.50 0.1979 a#b | 1236.66667 4 309.166667Using Orthogonal Coding
Example problem taken from Completely Randomized Factorial Design
input a b y x1 x2 x3 x4 1 1 24 1 1 1 1 1 1 33 1 1 1 1 1 1 37 1 1 1 1 1 1 29 1 1 1 1 1 1 42 1 1 1 1 1 2 44 1 1 -1 1 1 2 36 1 1 -1 1 1 2 25 1 1 -1 1 1 2 27 1 1 -1 1 1 2 43 1 1 -1 1 1 3 38 1 1 0 -2 1 3 29 1 1 0 -2 1 3 28 1 1 0 -2 1 3 47 1 1 0 -2 1 3 48 1 1 0 -2 2 1 30 -1 1 1 1 2 1 21 -1 1 1 1 2 1 39 -1 1 1 1 2 1 26 -1 1 1 1 2 1 34 -1 1 1 1 2 2 35 -1 1 -1 1 2 2 40 -1 1 -1 1 2 2 27 -1 1 -1 1 2 2 31 -1 1 -1 1 2 2 22 -1 1 -1 1 2 3 26 -1 1 0 -2 2 3 27 -1 1 0 -2 2 3 36 -1 1 0 -2 2 3 46 -1 1 0 -2 2 3 45 -1 1 0 -2 3 1 21 0 -2 1 1 3 1 18 0 -2 1 1 3 1 10 0 -2 1 1 3 1 31 0 -2 1 1 3 1 20 0 -2 1 1 3 2 41 0 -2 -1 1 3 2 39 0 -2 -1 1 3 2 50 0 -2 -1 1 3 2 36 0 -2 -1 1 3 2 34 0 -2 -1 1 3 3 42 0 -2 0 -2 3 3 52 0 -2 0 -2 3 3 53 0 -2 0 -2 3 3 49 0 -2 0 -2 3 3 64 0 -2 0 -2 end generate x5 = x1*x3 generate x6 = x1*x4 generate x7 = x2*x3 generate x8 = x2*x4 regress y x1 x2 x3 x4 x5 x6 x7 x8 Source | SS df MS Number of obs = 45 ---------+------------------------------ F( 8, 36) = 5.94 Model | 2970.00 8 371.25 Prob > F = 0.0001 Residual | 2250.00 36 62.50 R-squared = 0.5690 ---------+------------------------------ Adj R-squared = 0.4732 Total | 5220.00 44 118.636364 Root MSE = 7.9057 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- x1 | 1.5 1.443376 1.039 0.306 -1.427302 4.427302 x2 | -1.166667 .8333333 -1.400 0.170 -2.856745 .5234117 x3 | -3.833333 1.443376 -2.656 0.012 -6.760635 -.9060318 x4 | -3.5 .8333333 -4.200 0.000 -5.190078 -1.809922 x5 | -.25 1.767767 -0.141 0.888 -3.835198 3.335198 x6 | .25 1.020621 0.245 0.808 -1.819915 2.319915 x7 | 3.083333 1.020621 3.021 0.005 1.013419 5.153248 x8 | 1.916667 .5892557 3.253 0.002 .7216008 3.111733 _cons | 35 1.178511 29.698 0.000 32.60987 37.39013 ------------------------------------------------------------------------------ test x1 x2 /* using residual as error */ ( 1) x1 = 0.0 ( 2) x2 = 0.0 F( 2, 36) = 1.52 Prob > F = 0.2324 test x3 x4 /* using residual as error */ ( 1) x3 = 0.0 ( 2) x4 = 0.0 F( 2, 36) = 12.35 Prob > F = 0.0001 test x5 x6 x7 x8 /* using residual as error */ ( 1) x5 = 0.0 ( 2) x6 = 0.0 ( 3) x7 = 0.0 ( 4) x8 = 0.0 F( 4, 36) = 4.95 Prob > F = 0.0028 regress y x1 x2 Source | SS df MS Number of obs = 45 ---------+------------------------------ F( 2, 42) = 0.79 Model | 190.00 2 95.00 Prob > F = 0.4590 Residual | 5030.00 42 119.761905 R-squared = 0.0364 ---------+------------------------------ Adj R-squared = -0.0095 Total | 5220.00 44 118.636364 Root MSE = 10.944 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- x1 | 1.5 1.998015 0.751 0.457 -2.532157 5.532157 x2 | -1.166667 1.153554 -1.011 0.318 -3.494634 1.1613 _cons | 35 1.631372 21.454 0.000 31.70776 38.29224 ------------------------------------------------------------------------------ regress y x3 x4 Source | SS df MS Number of obs = 45 ---------+------------------------------ F( 2, 42) = 8.82 Model | 1543.33333 2 771.666667 Prob > F = 0.0006 Residual | 3676.66667 42 87.5396825 R-squared = 0.2957 ---------+------------------------------ Adj R-squared = 0.2621 Total | 5220.00 44 118.636364 Root MSE = 9.3563 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- x3 | -3.833333 1.708212 -2.244 0.030 -7.280645 -.3860213 x4 | -3.5 .9862369 -3.549 0.001 -5.490307 -1.509693 _cons | 35 1.39475 25.094 0.000 32.18528 37.81472 ------------------------------------------------------------------------------ regress y x5 x6 x7 x8 Source | SS df MS Number of obs = 45 ---------+------------------------------ F( 4, 40) = 3.10 Model | 1236.66667 4 309.166667 Prob > F = 0.0257 Residual | 3983.33333 40 99.5833333 R-squared = 0.2369 ---------+------------------------------ Adj R-squared = 0.1606 Total | 5220.00 44 118.636364 Root MSE = 9.9791 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- x5 | -.25 2.231405 -0.112 0.911 -4.759837 4.259837 x6 | .25 1.288302 0.194 0.847 -2.353756 2.853756 x7 | 3.083333 1.288302 2.393 0.021 .4795777 5.687089 x8 | 1.916667 .7438015 2.577 0.014 .4133877 3.419946 _cons | 35 1.487603 23.528 0.000 31.99344 38.00656 ------------------------------------------------------------------------------ Regression Results Summarized model m0: R-square 0.5690 model m1: R-square 0.0364 model m2: R-square 0.2957 model m3: R-square 0.2369
Random-Effects F-ratios Using Regression
Random & Mixed Effects Using test2
The test2 command (available from ATS) can be used to perform tests with different error terms after using regress. The test2 command is an alternative to computing the F-ratio manually.
regress y x1 x2 x3 x4 x5 x6 x7 x8 Source | SS df MS Number of obs = 45 -------------+------------------------------ F( 8, 36) = 5.94 Model | 2970.00 8 371.25 Prob > F = 0.0001 Residual | 2250.00 36 62.50 R-squared = 0.5690 -------------+------------------------------ Adj R-squared = 0.4732 Total | 5220.00 44 118.636364 Root MSE = 7.9057 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x1 | 1.5 1.443376 1.04 0.306 -1.427302 4.427302 x2 | -1.166667 .8333333 -1.40 0.170 -2.856745 .5234117 x3 | -3.833333 1.443376 -2.66 0.012 -6.760635 -.9060318 x4 | -3.5 .8333333 -4.20 0.000 -5.190078 -1.809922 x5 | -.25 1.767767 -0.14 0.888 -3.835198 3.335198 x6 | .25 1.020621 0.24 0.808 -1.819915 2.319915 x7 | 3.083333 1.020621 3.02 0.005 1.013419 5.153248 x8 | 1.916667 .5892557 3.25 0.002 .7216008 3.111733 _cons | 35 1.178511 29.70 0.000 32.60987 37.39013 ------------------------------------------------------------------------------ test2 x1 x2 / x5 x6 x7 x8 /* using A*B as error */ Testing: x1 x2 Error term: x5 x6 x7 x8 F( 2, 4) = .31 Prob > F = 0.7514 test2 x3 x4 / x5 x6 x7 x8 /* using A*B as error */ Testing: x3 x4 Error term: x5 x6 x7 x8 F( 2, 4) = 2.50 Prob > F = 0.1979 test x5 x6 x7 x8 /* using residual as error */ ( 1) x5 = 0.0 ( 2) x6 = 0.0 ( 3) x7 = 0.0 ( 4) x8 = 0.0 F( 4, 36) = 4.95 Prob > F = 0.0028
Linear Statistical Models Course
Phil Ender, 24sep10, 29apr06, 12Feb98