2
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

I believe aggregate() is giving you the actual means by condition. That is, it should equal what you get from doing something like: with(check, tapply(donor, condition, mean)).

However, the intercept is the model-implied or predicted value for when the subjects are in the reference conditions for both donor and condition.

The model-implied solution does not always equal the actual observed values, especially if donor and condition might be correlated.

I believe this is correct, but I would need to see the data and/or what you typed in for the aggregate() command to know for sure.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.