I have linear model
lmB <- lm(vsnIntensity ~ Donor + Condition ,data = check)
Donor and Condition are both factors and vsnIntensity is continous The model in mathematical notation, (I think) is $$ y_{ij} = \alpha + \beta_i + \gamma_j + \epsilon_{ij} $$
Where $\alpha$ is the intercept, which is the mean of the reference donor and condition. $\beta_i$ are the coefficients (effects) for all conditions except the reference condition. $\gamma_j$ are the coefficients (effects) for all the donors except the reference donor. Is the mathematical notation correct?
When I fit the model I am getting:
> lmB <- lm(vsnIntensity ~ Donor + Condition ,data = check)
> data.frame(coefficients(lmB))
coefficients.lmB.
(Intercept) 18.15866653
Donor185 0.06377651
Donor234 0.30834387
Donor235 0.36166529
Donor236 0.09642398
ConditionCMP -0.01566147
ConditionGMP 0.20452979
ConditionMEP 0.06511231
However, computing the mean for the reference donor and condition using aggregate
I have different values:
Group.1 Group.2 x
1 HSC 132 18.06667
2 CMP 132 18.26274
3 GMP 132 18.31288
4 MEP 132 18.24636
5 HSC 185 18.14692
6 CMP 185 18.20435
Why Do I have a different value for the Intercept than the group mean for the reference factors and why when I am using only a single factor e.g.
lmB <- lm(vsnIntensity ~ Condition ,data = check)
the intercept is the group mean for the reference condition?