[R-sig-ME] Different lm and aov summary
Joshua Wiley
jwiley.psych at gmail.com
Wed Feb 23 15:13:58 CET 2011
Dear Sz,
On Wed, Feb 23, 2011 at 5:38 AM, Szymek Drobniak <geralttee at gmail.com> wrote:
> Dear mixed modellers,
(but note that you are not dealing with a mixed model here)
>
> I'm a bit confused and that's why I'm asking. I came across with sthng
> similar on the listbut couldn't actually fimd the answer there... But to the
> point - there's a model with several fixed effects, some of them with 2
> levels (eg. Age). When I look at the regression-like output there seems to
> be no age-relared effect - and in the aov table (summary.aov() or anova())
> this effect is significant. Are these two tests fundamentally different and
> if so - which one givesthe right answer? Below you'll find both outputs
Ista makes a good point about using appropriate summary methods, but
in this case, the different results are not from using incorrect
methods or code but from asking slightly different questions.
Which one "gives the right answer" really depends on your question.
What is it you want to answer?
Here is a simple example showing one way to get an ANOVA table from an
lm object.
d <- data.frame(y = c(1, 3, 2, 7, 6, 8), x = factor(rep(0:1, each = 3)))
m1 <- aov(y ~ x, data = d)
m2 <- lm(y ~ x, data = d)
summary(m1) # summary of aov object
anova(m2) # ANOVA table from lm object
summary(m2) # summary of lm object
In this simple case, the F for the overall model fit from lm is the
same as the F for x in the ANOVA table (because there is only one
term). Also, note that R^{2} = 0.9036 = 37.5/(37.5 + 4).
A good book on introductory statistics would probably help clear up
what the differences (and similarities) are.
Cheers,
Josh
>> Lmount1 <- lm(Lmount~age*status*morph, data=age)
>> summary(Lmount1)
>
> Call:
> lm(formula = Lmount ~ age * status * morph, data = age)
>
> Residuals:
> Min 1Q Median 3Q Max
> -3337.0 -868.6 -137.1 708.8 6910.0
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) 2651.16 313.49 8.457 1.53e-13 ***
> ageY -659.13 414.71 -1.589 0.1149
> status1 -182.41 224.42 -0.813 0.4181
> status2 650.43 379.11 1.716 0.0891 .
> morphS -96.31 384.30 -0.251 0.8026
> ageY:status1 -216.24 301.50 -0.717 0.4748
> ageY:status2 -451.82 493.18 -0.916 0.3617
> ageY:morphS -295.03 527.77 -0.559 0.5773
> status1:morphS -248.81 279.64 -0.890 0.3756
> status2:morphS -620.20 456.58 -1.358 0.1772
> ageY:status1:morphS 525.32 385.36 1.363 0.1757
> ageY:status2:morphS 324.96 624.60 0.520 0.6040
> ---
> Signif. codes: 0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1
>
> Residual standard error: 1363 on 107 degrees of freedom
> (30 observations deleted due to missingness)
> Multiple R-squared: 0.2042, Adjusted R-squared: 0.1223
> F-statistic: 2.495 on 11 and 107 DF, p-value: 0.007876
>
>> summary.aov(Lmount1)
> Df Sum Sq Mean Sq F value Pr(>F)
> age 1 20619061 20619061 11.1010 0.001185 **
> status 2 19083130 9541565 5.1370 0.007408 **
> morph 1 1503500 1503500 0.8095 0.370299
> age:status 2 1480585 740293 0.3986 0.672276
> age:morph 1 741135 741135 0.3990 0.528945
> status:morph 2 3407887 1703943 0.9174 0.402684
> age:status:morph 2 4148964 2074482 1.1169 0.331087
> Residuals 107 198742119 1857403
> ---
> Signif. codes: 0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1
> 30 observations deleted due to missingness
>
> Cheers,
> Sz.
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-sig-mixed-models
mailing list