Sean Raleigh
Sean Raleigh

Reputation: 589

ANOVA using the sample mean as intercept in R

Many students first learn ANOVA using a form of the model that compares group means to the overall population mean (between group variability) and individual observations to their group means (within group variability). The sample mean is naturally used as the estimate for the population mean.

If the design is balanced (equal counts in each cell), the sum-to-zero contrast in R (contr.sum) is equivalent to what is described in the paragraph above. However, for an unbalanced design, the sample mean and the so-called "grand mean" are not the same. (The latter is the mean of the group means, whereas the sample mean would be a weighted mean of the group means.)

So my question is this: can the lm command be tricked into giving coefficients for an ANOVA model in which the intercept term is not the grand mean, but in fact the sample mean?

Upvotes: 0

Views: 725

Answers (1)

Sean Raleigh
Sean Raleigh

Reputation: 589

Okay, I found the answer. (I wasn't searching for the right thing.)

Linear Regression with a known fixed intercept in R

The offset argument to lm is an easy way to manually set the intercept for any regression.

Upvotes: 0

Related Questions