Skip to content

Rsquared for anova

4 messages · Dorien Herremans, Dieter Menne, Ben Bolker

#
Thanks Dieter,

Even if I use lm(), I get the following output:
? ? ? ? ? ? ?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 ?.?


no R squared to be found.

The lm() output gives this:
? ? ? ? ? ? ?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 ?.?

I just want to see how wel the model fits...


Another strange thing. I did the same calculations in SPSS and got
different results, among others, higher p values. lm() and aov() just
do linear regressions (anova) right? I tried with the same factorial
variables (without interaction effects to test).

Thanks!
On 15 April 2011 18:07, Dieter Menne <dieter.menne at menne-biomed.de> wrote:
--
Dorien Herremans

Department of Environment, Technology and Technology Management
Faculty of Applied Economics
University of Antwerp

B.513
Prinsstraat 13
2000 Antwerp
Belgium
+32 3 265 41 25
#
Dorien Herremans wrote:
You probably used the wrong fit. I get your results, when I use
summary(aov), instead of summary(lm())

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))
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.
#
Dorien Herremans <dorien.herremans <at> ua.ac.be> writes:
Really ??

  When I run the example in ?lm I get:
Call:
lm(formula = weight ~ group)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.0710 -0.4938  0.0685  0.2462  1.3690 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   5.0320     0.2202  22.850 9.55e-15 ***
groupTrt     -0.3710     0.3114  -1.191    0.249    
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 

Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-squared: 0.07308,	Adjusted R-squared: 0.02158 
F-statistic: 1.419 on 1 and 18 DF,  p-value: 0.249 

    Note the last three lines.  I would be shocked if there
weren't a similar set of information in your output ...

  Your output looks like the result of summary(aov(...))
There are a lot of things that could be different. Are
you treating factors (categorical predictors) as numeric by
accident?
http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3452434.html
#
Omg Dieter, thanks so much... I just had to q() and R... that solved
it :-) excellent! finally got the R2 :-)
On 18 April 2011 15:12, Ben Bolker <bbolker at gmail.com> wrote: