[R] how to access the elements of a univariate results table with Anova (library car)

David Winsemius dwinsemius at comcast.net
Sat Mar 19 15:27:19 CET 2011


On Mar 19, 2011, at 8:44 AM, Juan Andres Hernandez wrote:

> Dear R users,  I use the excelent Anova function of the library car  
> because
> the easy way to get sphericity correction. Unless I use the scan  
> function. I
> have not been able to access the values ​​of sum squares and  
> degrees of
> freedom for each effect in the univariate summary table.
>
> Example of the car library for Anova function:
>
> library(car)
> phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)),
>         levels=c("pretest", "posttest", "followup"))
>         hour <- ordered(rep(1:5, 3))
> idata <- data.frame(phase, hour)
>
> mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5,
>                          post.1, post.2, post.3, post.4, post.5,
>                          fup.1, fup.2, fup.3, fup.4, fup.5) ~
> treatment*gender,
>                     data=OBrienKaiser)
> av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour)
>
> summary(av.ok, multivariate=FALSE)
>
> If you assign the above line to a new object you will get a  
> multivariate
> summary and not the univariate one.
>
> my.summary <- summary(av.ok, multivariate=FALSE)
> my.summary
>
> Does anyone know how to assign the full univariate output to a new  
> object
> or variable. The logical way does not produce the desired  result.
> Than'ks in advance.

summary,Anova.mlm appears to returns the object that was passed to it.  
How to I know this (despite never having used the function before and  
having tried unsuccessfully to access the answer with  
help(summary.Anova.mlm))?  I looked at the code.  You are getting  
console output that varies a bit with different parameters to summary,  
but the object av.ok being passed as the value of summary and is not  
changing.

 > all.equal(av.ok, my.summary)
[1] TRUE

If you want to capture the text output that appears on the console  
display then you need to use either sink() or capture.output().

>
> Juan Hernández Cabrera
> Facultad de Psicología
> Universidad de La Laguna
> Spain

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list