aov
and lm
lm
rather than aov
?aov
first:lm
Call:
lm(formula = weight ~ feed, data = pigs)
Residuals:
Min 1Q Median 3Q Max
-3.900 -2.025 -0.570 1.845 5.000
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 60.620 1.404 43.190 < 2e-16 ***
feedfeed2 8.680 1.985 4.373 0.000473 ***
feedfeed3 33.480 1.985 16.867 1.30e-11 ***
feedfeed4 25.620 1.985 12.907 7.11e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.138 on 16 degrees of freedom
Multiple R-squared: 0.9572, Adjusted R-squared: 0.9491
F-statistic: 119.1 on 3 and 16 DF, p-value: 3.72e-11
anova
:Read the data:
lm
Call:
lm(formula = pulse_rate ~ temperature + species, data = crickets)
Residuals:
Min 1Q Median 3Q Max
-3.0128 -1.1296 -0.3912 0.9650 3.7800
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -7.21091 2.55094 -2.827 0.00858 **
temperature 3.60275 0.09729 37.032 < 2e-16 ***
speciesniveus -10.06529 0.73526 -13.689 6.27e-14 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.786 on 28 degrees of freedom
Multiple R-squared: 0.9896, Adjusted R-squared: 0.9888
F-statistic: 1331 on 2 and 28 DF, p-value: < 2.2e-16
Can I remove anything? No:
drop1
is right thing to use in a regression with categorical (explanatory) variables in it: “can I remove this categorical variable as a whole?”
Call:
lm(formula = pulse_rate ~ temperature + species, data = crickets)
Residuals:
Min 1Q Median 3Q Max
-3.0128 -1.1296 -0.3912 0.9650 3.7800
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -7.21091 2.55094 -2.827 0.00858 **
temperature 3.60275 0.09729 37.032 < 2e-16 ***
speciesniveus -10.06529 0.73526 -13.689 6.27e-14 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.786 on 28 degrees of freedom
Multiple R-squared: 0.9896, Adjusted R-squared: 0.9888
F-statistic: 1331 on 2 and 28 DF, p-value: < 2.2e-16
speciesniveus
says that pulse rate for niveus
about 10 lower than that for exclamationis
at same temperature (latter species is baseline).