Hi:

Someone off-list (Josh Wiley - thank you) mentioned the Error() term in the
OP's ANOVA, which I missed in responding to the post - sorry for the
misinformation. Using the npk example with code that Josh showed me, we
have, for the following model,
npk.aov2 <- aov(yield ~ N*P*K + Error(block/P), data = npk)
npk.aovE2 <- summary(npk.aov2)
str(npk.aovE2)
List of 3
 $ Error: block  :List of 1
  ..$ :Classes ‘anova’ and 'data.frame':        2 obs. of  5 variables:
  .. ..$ Df     : num [1:2] 1 4
  .. ..$ Sum Sq : num [1:2] 37 306
  .. ..$ Mean Sq: num [1:2] 37 76.6
  .. ..$ F value: num [1:2] 0.483 NA
  .. ..$ Pr(>F) : num [1:2] 0.525 NA
  ..- attr(*, "class")= chr [1:2] "summary.aov" "listof"
 $ Error: block:P:List of 1
  ..$ :Classes ‘anova’ and 'data.frame':        3 obs. of  5 variables:
  .. ..$ Df     : num [1:3] 1 1 4
  .. ..$ Sum Sq : num [1:3] 8.4 33.1 38.3
  .. ..$ Mean Sq: num [1:3] 8.4 33.14 9.57
  .. ..$ F value: num [1:3] 0.878 3.464 NA
  .. ..$ Pr(>F) : num [1:3] 0.402 0.136 NA
  ..- attr(*, "class")= chr [1:2] "summary.aov" "listof"
 $ Error: Within :List of 1
  ..$ :Classes ‘anova’ and 'data.frame':        5 obs. of  5 variables:
  .. ..$ Df     : num [1:5] 1 1 1 1 8
  .. ..$ Sum Sq : num [1:5] 189.282 95.202 21.282 0.482 147.023
  .. ..$ Mean Sq: num [1:5] 189.282 95.202 21.282 0.482 18.378
  .. ..$ F value: num [1:5] 10.2994 5.1802 1.158 0.0262 NA
  .. ..$ Pr(>F) : num [1:5] 0.0124 0.0524 0.3133 0.8754 NA
  ..- attr(*, "class")= chr [1:2] "summary.aov" "listof"
 - attr(*, "class")= chr "summary.aovlist"

In this case, the p-values can be gotten from each component of the list,
but one has to read the output from str() carefully. For example, under each
$Error component is another component, and it is the subcomponent that needs
to be subsetted to grab the p-values:

Top level:
> npk.aovE2[[1]][[1]][, 5]
[1] 0.5252361        NA

Mid-level:
> npk.aovE2[[2]][[1]][, 5]
[1] 0.4017266 0.1362185        NA

Bottom level:
> npk.aovE2[[3]][[1]][, 5]
[1] 0.01243794 0.05239664 0.31325902 0.87540509         NA

BTW, this is one reason why str() is such an important function in R.

Thanks to Peter and Josh for pointing out my error; apologies for the
thickheadedness.

Dennis

On Wed, Sep 29, 2010 at 5:56 AM, peter dalgaard <pda...@gmail.com> wrote:

>
> On Sep 29, 2010, at 14:25 , Dennis Murphy wrote:
>
> >
> > test.summary[[1]][, 5][1]
> >
> > You mean that wasn't obvious?   :)
>
> Worse, it doesn't actually work...
>
> > test.summary <- summary(npk.aovE)
> > test.summary[[1]][, 5]
> Error in `[.default`(test.summary[[1]], , 5) :
>  incorrect number of dimensions
> > test.summary$"Error: block"[[1]][, 5]
> [1] 0.5252361        NA
> > test.summary[[1]][[1]][, 5]
> [1] 0.5252361        NA
>
> I.e., you need an extra list extraction operator. The data structure goes
>
> List of 2
>  $ Error: block :List of 1
>  ..$ :Classes ‘anova’ and 'data.frame':        2 obs. of  5 variables:
>  .. ..$ Df     : num [1:2] 1 4
>  .. ..$ Sum Sq : num [1:2] 37 306
> ...
>  and the intermediate list has class ("summary.aov","listof"). I believe
> the point is that you can have a matrix LHS and get a table for each of its
> columns.
>
> --
> Peter Dalgaard
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd....@cbs.dk  Priv: pda...@gmail.com
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to