首页 > 解决方案 > Extracting P-value column from output Anova (car package)

问题描述

I am using the 'car' package function Anova for some statistical testing.

It gives the following output:

    Y = cbind(curdata$V1, curdata$V2, curdata$V3)
    mymdl = lm(Y ~ curdata$V4 + curdata$V5)
    myanova = Anova(mymdl)
    
Type II MANOVA Tests: Pillai test statistic
           Df test stat approx F num Df den Df  Pr(>F)  
curdata$V4  1   0.27941   2.9728      3     23 0.05280 .
curdata$V5  1   0.33570   3.8743      3     23 0.02228 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I would like to extract the values in the 'Pr(>F)' column, so I can place these p-values in another matrix for later correction of multiple comparisons.

I have tried using unlist, but it still does not provide the p-values found in the column.

Any help with this would be greatly appreciated.

标签: ranova

解决方案


If we have multiple response variables, it is a Manova. We could capture the output and use regex

as.numeric(sub(".*\\s*(\\d+\\.[0-9e-]+)\\s*[*.]*", "\\1", capture.output(out)[4:5]))
#[1] 8.836e-06 2.200e-16

data

 mymdl <- lm(cbind(Sepal.Length, Sepal.Width) ~ Petal.Width + 
     Petal.Length, data = iris)

 out <- Anova(mymdl)

推荐阅读