r - 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.
解决方案
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)
推荐阅读
- python - 编写 python 函数,使用 groupby 对每种索引类型的某些行的值求和
- laravel - Laravel 会话 ID 在每个请求上都会更改
- google-cloud-platform - 基于非结构化数据构建 Google Cloud Platform 数据目录
- node.js - 尝试安装 Windows 构建工具时出错
- vue.js - Vue:状态,这是什么?
- php - 更改网址后图片未加载
- c# - 为什么它显示“无法从 'void' 转换为 'System.Action'”
- c# - 密码未从 C# 应用程序正确存储在 SQL Server 中
- sql - 通过 SQL 在表中进行行比较
- spring-boot - Spring Boot 2.3.0 - MongoDB 库不会自动创建索引