[R] Indexing ANOVA table

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Nov 29 12:32:41 CET 2003


Pascal.Niklaus at unibas.ch writes:

> Hi all,
> 
> I'd like to extract a value from an ANOVA table, but experience the following
> problem:
> 
> ### This works:
> 
> > s.pseudo <- summary(aov(m ~ block + mix*graz,data=split1))
> > s.pseudo
>             Df  Sum Sq Mean Sq F value  Pr(>F)
> block        2 1114.66  557.33  4.4296 0.04192 *
> mix          1    6.14    6.14  0.0488 0.82956
> graz         2    1.45    0.72  0.0057 0.99427
> mix:graz     2    3.82    1.91  0.0152 0.98495
> Residuals   10 1258.19  125.82
> ---
> Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
> > s.pseudo[[1]]["mix ","Pr(>F)"]
> [1] 0.8295556
> 
> ### But this doesn't -- why?
> 
> > s.split <-  summary(aov(m ~ block + mix*graz + Error(Plot),data=split1))
> > s.split
> 
> Error: Plot
>           Df  Sum Sq Mean Sq F value Pr(>F)
> block      2 1114.66  557.33  0.8994 0.5265
> mix        1    6.14    6.14  0.0099 0.9298
> Residuals  2 1239.37  619.68
> 
> Error: Within
>           Df  Sum Sq Mean Sq F value Pr(>F)
> graz       2  1.4464  0.7232  0.3073 0.7437
> mix:graz   2  3.8206  1.9103  0.8117 0.4776
> Residuals  8 18.8278  2.3535
> > s.split[["Error: Plot"]]  ## extracting first list element works
>           Df  Sum Sq Mean Sq F value Pr(>F)
> block      2 1114.66  557.33  0.8994 0.5265
> mix        1    6.14    6.14  0.0099 0.9298
> Residuals  2 1239.37  619.68
> > s.split[["Error: Plot"]]["mix ","Pr(>F)"]  ### <== FAILS
> Error in s.split[["Error: Plot"]]["mix ", "Pr(>F)"] :
>         incorrect number of dimensions
> 
> So where is the difference between the two?
> 
> Thanks for any hint

There's an extra list level:

> example(aov)
...
> str(summary(npk.aovE)[["Error: Within"]])
List of 1
 $ :Classes anova  and `data.frame':    7 obs. of  5 variables:
  ..$ Df     : num [1:7] 1 1 1 1 1 1 12
  ..$ Sum Sq : num [1:7] 189.3   8.4  95.2  21.3  33.1 ...
  ..$ Mean Sq: num [1:7] 189.3   8.4  95.2  21.3  33.1 ...
  ..$ F value: num [1:7] 12.259  0.544  6.166  1.378  2.146 ...
  ..$ Pr(>F) : num [1:7] 0.00437 0.47490 0.02880 0.26317 0.16865 ...
 - attr(*, "class")= chr [1:2] "summary.aov" "listof"
> summary(npk.aovE)[["Error: Within"]][[1]]["N:P","Pr(>F)"]
[1] 0.2631653

As to *why* there's this extra level, you have to ask the author...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list