[R] How to obtain the coefficients from a summary of aov ?

Andrea Bernasconi DG andrea.bernasconi.dg at gmail.com
Wed Apr 21 14:37:35 CEST 2010


Dear Madame, Dear Sir,

I am able to obtain the coefficients from a 'summary' of 'lm', but NOT from a 'summary' of 'aov'.
The following example shows my steps.

## Initialize
rm(list = ls()) # remove (almost) everything in the working environment
utils::data(npk, package="MASS") # get data
model <- yield ~ block + N*P*K

## Using lm
npk.lm <- lm(model, npk)
( s.npk.lm <- summary(npk.lm) )

... 
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  54.8750     0.8021  68.415  < 2e-16 ***
block1        1.7125     1.3893   1.233  0.24131    
block2        1.6792     0.8021   2.093  0.05822 .  
block3       -1.8229     0.5672  -3.214  0.00744 ** 
...

s.npk.lm$coef["block1","Pr(>|t|)"] # this works
[1] 0.2413061
 
## Using aov
npk.aov <- aov(model, npk)
( s.npk.aov <- summary(npk.aov) )

...
            Df Sum Sq Mean Sq F value   Pr(>F)   
block        5 343.29  68.659  4.4467 0.015939 * 
N            1 189.28 189.282 12.2587 0.004372 **
P            1   8.40   8.402  0.5441 0.474904   
...

s.npk.aov$coef["block","Pr(>F)"] # this does NOT works

...
NULL
...

How to obtain the coefficients from a 'summary'  of 'aov' ?

In advance, I thank you very much for your eventual answer.

Sincerely, Andrea Bernasconi

mobile: +41 79 621 74 07
URL: http://web.me.com/andrea.bernasconi.dg/Andrea_Bernasconi_DG_home_page/HOME.html



More information about the R-help mailing list