[R] Extracting Numbers from MANOVA output

Marc Schwartz MSchwartz at medanalytics.com
Sun Jun 8 03:15:06 CEST 2003


On Sat, 2003-06-07 at 18:43, Ko-Kang Kevin Wang wrote:
> Hi,
> 
> Suppose I have:
> > summary(manova(plank.man))
>                   Df Pillai approx F num Df den Df    Pr(>F)    
> plankton.new[, 1]  1 0.5267   9.8316      6     53 2.849e-07 ***
> Residuals         58                                            
> ---
> Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
> 
> My understanding is the MANOVA summary returns a list.  However I am not 
> sure how to extract out only part of the list.  For example is I want to 
> extract the Pillai's test statistic, 0.5267, how can I do this?


Kevin,

To use the example from ?summary.manova, since I don't have your data:

## Example on producing plastic film from Krzanowski (1998, p. 381)
> tear <- c(6.5, 6.2, 5.8, 6.5, 6.5, 6.9, 7.2, 6.9, 6.1, 6.3,
          6.7, 6.6, 7.2, 7.1, 6.8, 7.1, 7.0, 7.2, 7.5, 7.6)
> gloss <- c(9.5, 9.9, 9.6, 9.6, 9.2, 9.1, 10.0, 9.9, 9.5, 9.4,
           9.1, 9.3, 8.3, 8.4, 8.5, 9.2, 8.8, 9.7, 10.1, 9.2)
> opacity <- c(4.4, 6.4, 3.0, 4.1, 0.8, 5.7, 2.0, 3.9, 1.9, 5.7,
             2.8, 4.1, 3.8, 1.6, 3.4, 8.4, 5.2, 6.9, 2.7, 1.9)
> Y <- cbind(tear, gloss, opacity)
> rate <- factor(gl(2,10), labels=c("Low", "High"))
> additive <- factor(gl(2, 5, len=20), labels=c("Low", "High"))

> fit <- manova(Y ~ rate * additive)

> summary(fit)
              Df Pillai approx F num Df den Df   Pr(>F)
rate           1 0.6181   7.5543      3     14 0.003034 **
additive       1 0.4770   4.2556      3     14 0.024745 *
rate:additive  1 0.2229   1.3385      3     14 0.301782
Residuals     16
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1


If you then use:

> str(summary(fit))

You will note at the bottom, the following:

...
 $ stats      : num [1:4, 1:6]  1.000  1.000  1.000 16.000  0.618 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:4] "rate" "additive" "rate:additive" "Residuals"
  .. ..$ : chr [1:6] "Df" "Pillai" "approx F" "num Df" ...
 - attr(*, "class")= chr "summary.manova"


In this case 'stats' is a 4 by 6 matrix with defined dimnames. Thus to
get the individual statistics (ie. "Pillai"), use:

> summary(fit)$stats[, "Pillai"]
         rate      additive rate:additive     Residuals
    0.6181416     0.4769651     0.2228942            NA


The use of str(object) will provide you with the internal structure of
the object, which in turn will enable you to extract specific values.


HTH,

Marc Schwartz




More information about the R-help mailing list