# What is the maths behind treatment effect coding making the intercept the grand mean?

I am learning about dummy coding and effect coding. Intuitively, they make sense. I understand the interpretations of the intercepts in both examples: mean of the reference condition in dummy coding and the grand mean in effect coding.

I'm struggling to understand what it is in the maths, however, that makes centering the coding on 0 lead to an intercept that reflects the grand mean.

In dummy coding, it's clear the intercept is the mean of the reference condition:

\begin{align} \hat{Y}_{group1,i} = \beta_0 + \beta_1 \times 0 \\ = \beta_0 \end{align}

and the slope the difference between this reference condition and the other predictor (in a 2 condition regression)

\begin{align}\hat{\beta}_1 = \overline{Y}_\text{group2} - \beta_0\\ = \overline{Y}_\text{group2} - \overline{Y}_\text{group1}\end{align}

But how does centering the predictors around 0, e.g. (-0.5,0.5) affect the GLM equation such that the intercept now represents the grand mean?

I've looked up loads of sites and they all just say that the intercept is the grand mean when using effects coding, but im yet to see why that's the case mathematically.

• You mention "GLM" in passing, which is surprising, because the concept of "grand mean" doesn't apply to most GLMs. Did you mean to write "OLS" instead?
– whuber
Nov 5, 2020 at 15:39
• "General linear model" or "generalized linear model"? They aren't the same.
– Dave
Nov 5, 2020 at 15:41
• hmm, no - the course im using to learn stats is discussing this in reference to the GLM (general linear model). I.e. the glm equation Y = B0 + B1 x X1 + B2 x X2 etc. and then states the grand mean is simply the mean of all the means of the dependent variable across conditions Nov 5, 2020 at 15:45
• @Dave yes thanks, if you type glm into the tag box it automatically makes it generalized linear model. my bad Nov 5, 2020 at 15:46
• I suppose I can simplify the question: Mathematically, why is the intercept the grand mean when using effect coding? Nov 5, 2020 at 15:53

I will try an intuitive explanation rather than the mathematical one but that may help as well. Suppose that you have a two level predictor and it is balanced so that half your sample have one value, half the other. For half the sample the predicted value of $$Y$$ is $$\beta_0 +0.5 \beta_1$$ and for the other half it is $$\beta_0 - 0.5 \beta_1$$. Now average everybody's predicted value and the effect of $$\beta_1$$ cancels out and you are left with $$\beta_0$$ which must therefore be the grand mean since otherwise the model would be systematically over or under predicting.