[BioC] Linear Models and ANOVA

Thomas Hampton thomas.h.hampton at dartmouth.edu
Thu Dec 16 22:03:58 CET 2010


This is an off topic question related more to R and statistics, but I  
will impose myself, if you don't mind.

Here is my issue.

  R anova is essentially a way to interpret some linear model such as

fit <- lm(y ~a*b)

You can generate nice p values by doing something like

anova(lm(y ~a*b))

But you could also generate p values like this:

summary(lm(y~a*b))

I find though, that the p values you generate may be different
depending on whether you call summary.lm or whether
you get them from anova.lm.

For example:
 > data.ex2=read.table(datafilename,header=TRUE)
 > summary(lm(formula = Alertness ~ Gender * Dosage, data = data.ex2))

Call:
lm(formula = Alertness ~ Gender * Dosage, data = data.ex2)

Residuals:
    Min     1Q Median     3Q    Max
-6.500 -3.375  0.000  1.562 10.500

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)
(Intercept)       15.750      2.546   6.185 4.69e-05 ***
Genderm           -4.500      3.601  -1.250    0.235
Dosageb            1.000      3.601   0.278    0.786
Genderm:Dosageb    0.250      5.093   0.049    0.962
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.093 on 12 degrees of freedom
Multiple R-squared: 0.2079,	Adjusted R-squared: 0.009862
F-statistic:  1.05 on 3 and 12 DF,  p-value: 0.4062

 > anova(lm(formula = Alertness ~ Gender * Dosage, data = data.ex2))
Analysis of Variance Table

Response: Alertness
               Df  Sum Sq Mean Sq F value Pr(>F)
Gender         1  76.562  76.562  2.9518 0.1115
Dosage         1   5.062   5.062  0.1952 0.6665
Gender:Dosage  1   0.063   0.063  0.0024 0.9617
Residuals     12 311.250  25.938


The anova output is tidier to look at. But why are the anova p values  
smaller
for Gender and Dosage?


Thanks for your help.

Tom


More information about the Bioconductor mailing list