如何对anova而不是aov命令执行自定义测试。例如:
anova(cap.res,
by = "terms",
step = 1000)在得到anova结果之后,我想要一个临时比较。我有三个比较,"N","C“和"S”。
发布于 2022-10-10 13:08:30
这是很久以前发布的,但为了澄清万一有人发现了这一点,anova和aov有相似的名称,但功能是无与伦比的。查看帮助页面,您可以看到anova函数实际上用于通过表比较模型,而aov函数仅用于经典的ANOVA测试。例如:
#### Load Library ####
library(rstatix)
#### Fit LR, AOV, and ANOVA ####
fit <- lm(Sepal.Width ~ Species,
data=iris)
fit2 <- anova(fit)
fit3 <- aov(fit)
#### Run Tukeys ####
tukey_hsd(fit)
tukey_hsd(fit2)
tukey_hsd(fit3)如果运行fit和fit3,基本上可以得到相同的Tukey:
# A tibble: 3 × 9
term group1 group2 null.…¹ estim…² conf.…³ conf.…⁴ p.adj p.adj…⁵
* <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
1 Speci… setosa versi… 0 -0.658 -0.819 -0.497 3.1 e-14 ****
2 Speci… setosa virgi… 0 -0.454 -0.615 -0.293 1.36e- 9 ****
3 Speci… versi… virgi… 0 0.204 0.0431 0.365 8.78e- 3 **
# … with abbreviated variable names ¹null.value, ²estimate, ³conf.low,
# ⁴conf.high, ⁵p.adj.signif这是因为在很多方面,线性回归和anova在功能上是等价的。但是,在使用fit2进行相同操作时会出现错误。
Error in tukey_hsd.data.frame(fit2) :
argument "formula" is missing, with no default如果您查看帮助页面,它在这里寻找的公式是aov或lm类:
Arguments
x
an object of class aov, lm or data.frame containing the variables used in the formula.https://stackoverflow.com/questions/62692164
复制相似问题