[R] extracting p-values from Anova objects (from the car library)

John Fox jfox at mcmaster.ca
Mon Aug 23 23:53:30 CEST 2010


Dear Johan,

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of Johan Steen
> Sent: August-23-10 3:02 PM
> To: r-help at r-project.org
> Subject: [R] extracting p-values from Anova objects (from the car library)
> 
> Dear all,
> 
> is there anyone who can help me extracting p-values from an Anova object
> from the car library? I can't seem to locate the p-values using
> str(result) or str(summary(result)) in the example below
> 
>  > A <- factor( rep(1:2,each=3) )
>  > B <- factor( rep(1:3,times=2) )
>  > idata <- data.frame(A,B)
>  > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ~ sex,
> data=Data.wide)
>  > result <- Anova(fit, type="III", test="Wilks", idata=idata,
idesign=~A*B)
> 
> 
> Any help would be much appreciated!

I'm afraid that the answer is that the p-values aren't easily accessible.
The print method for Anova.mlm objects just passes through the object
invisibly as its result, as is conventional for print methods. The summary
method does the same -- that isn't conventional, but the summary method can
produce so many different kinds of printed output (various multivariate test
criteria for models with and without repeated measures; for the latter,
multivariate and univariate tests with and without corrections for
non-sphericity) that the printed output is produced directly rather than put
in an object with its own print method. 

What you can do is take a look at car:::print.Anova.mlm or
car:::summary.Anova.mlm (probably the print method, which is simpler) to see
how the p-values that you want are computed and write a small function to
return them.

I hope this helps,
 John

--------------------------------
John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox
> 
> 
> Many thanks,
> 
> Johan
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list