# [R] Rsquared for anova

Dieter Menne dieter.menne at menne-biomed.de
Mon Apr 18 14:58:41 CEST 2011

```Dorien Herremans wrote:
>
>
> Even if I use lm(), I get the following output:
>
>> summary(fit)
>              Df  Sum Sq Mean Sq F value    Pr(>F)
> nh1            1   324.0  323.99  139.13 < 2.2e-16 ***
> nh2            1   723.1  723.12  310.53 < 2.2e-16 ***
> nh3            1  1794.2 1794.21  770.49 < 2.2e-16 ***
> Residuals   4604 10721.2    2.33
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’
>

You probably used the wrong fit. I get your results, when I use

Dieter

d = data.frame(nh1 = sample(letters[1:2],4000,TRUE),
nh2 = sample(letters[1:2],4000,TRUE),
nh3 = sample(letters[1:2],4000,TRUE),
x = rnorm(4000))

summary(lm(x~nh1+nh2+nh3,data=d))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.01517    0.03121  -0.486    0.627
nh1b         0.01990    0.03116   0.639    0.523
nh2b        -0.02932    0.03116  -0.941    0.347
nh3b         0.02814    0.03116   0.903    0.367

Residual standard error: 0.9851 on 3996 degrees of freedom
Multiple R-squared: 0.0005315,  Adjusted R-squared: -0.0002189
F-statistic: 0.7083 on 3 and 3996 DF,  p-value: 0.5469

summary(aov(x~nh1+nh2+nh3,data=d))
> summary(aov(x~nh1+nh2+nh3,data=d))
Df Sum Sq Mean Sq F value Pr(>F)
nh1            1    0.4 0.40556  0.4179 0.5180
nh2            1    0.9 0.86530  0.8916 0.3451
nh3            1    0.8 0.79142  0.8155 0.3666
Residuals   3996 3878.2 0.97052
>

I suggest you kill your history file and your workspace, and try again from
scratch. I never use these, but always start from scratch with my program
(self-consistent) in the text editor.

Dieter

--
View this message in context: http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3457451.html
Sent from the R help mailing list archive at Nabble.com.

```