# Obtaining the fitted values of main effects and interactions when GLM coding is used

In short, I need to decompose the fitted values obtained from ANOVA into components corresponding to each term in ANOVA statement. This problem appears trivial, but it becomes tricky when GLM coding is used for the design matrix. Let's take a balanced 2*2 ANOVA with 2 observations per cell.

Y = A + B + A*B

GLM coding produces 8*9 design matrix:

Intercept – column 0

Main effect of A – columns 1-2

Main effect of B – columns 3-4

Interaction – columns 5-8

The estimated coefficients, $$b$$, look like (4 estimable parameters, as expected):

$$b_0 \ b_1 \ b_2 \ b_3 \ b_4 \ b_5 \ b_6 \ b_7 \ b_8$$

5.5 -0.915 0 1.15 0 -0.36 0 0 0

Let's take the covariate pattern:

1 1 0 1 0 1 0 0 0

for which the fitted value is 5.375. One could say that it's decomposed as

5.375 = 5.5 (Int) - 0.915 (A main effect) + 1.15 (B main effect) - 0.36 (A*B interaction)

but that's not the case. The linear restrictions for Type III hypotheses to test the significance of the two main effects and interactions are created as specified here.

In particular, to test

H0: Main effect of A = 0,

we test whether $$k'b = 0$$ where $$k$$ is (defined up to a multiple):

0 0.894427 -0.894427 0 0 0.447214 0.447214 -0.447214 -0.447214

That shows that, for the given covariate pattern, the point estimate of A main effect depends on both $$b_1$$ and $$b_5$$, not just $$b_1$$.

To test H0: Main effect of B = 0, we use the restriction:

0 0 0 0.894427 -0.894427 0.447214 -0.447214 0.447214 -0.447214

and for H0: A*B = 0 it is:

0 0 0 0 0 1 -1 -1 1

I estimated the model using the GLM coded design, ran the corresponding three tests, and all the fitted values and p-values check out vs SAS. The problem is I don't know how to use all that information in order to obtain the point estimates of main effects and interactions for a given covariate pattern.