Section 27 One-way ANOVA: function lm

27.1 lm

  • We can fit a linear model using the function lm

  • Fit a linear model using the function lm to compare if there is a difference between Groups.

  • Examine the R object of the lm outputs.

  • Note: It is crucial to convert the grouping variable into a factor before running the ANOVA analysis. This is the key difference between an ANOVA analysis and a regression analysis, and the results could be very misleading if this step is not performed.


27.2 Model

\[ \large y_{ij} = \mu + \tau_{i} + \epsilon_{ij} \]


27.3 Hypothesis

\[ \large H_O: \tau_1 = \tau_2 = ...= \tau_g \]

\[ \large H_A: \tau_i \ne 0 \space for \space at \space least \space one \space \tau_i\]


27.4 Syntax

\[ \large fm \leftarrow lm(SBP \sim Group, data=BP) \]

\[ \large anova(fm) \]

\[ \large summary(fm) \]