Extract p-value from aov

血红的双手。 提交于 2019-11-27 00:40:12
summary(test)[[1]][["Pr(>F)"]]

since the suggest above didn't work for me this is how i managed to solve it:

sum_test = unlist(summary(test))

then looking at the names with

names(sum_test)

i have"Pr(>F)1" and "Pr(>F)2", when the first it the requested value, so

sum_test["Pr(>F)1"]

will give the requested value

I know this is old but I looked around online and didn't find an explanation or general solution and this thread is one of the first things that comes up in a Google search.

Aniko is right, the easiest way is looking in summary(test).

tests <- summary(test)
str(tests)

That gives you a list of 1 for an independent measures aov object but it could have multiple items with repeated measures. With the repeated measures each item in the list is defined by the error term for the item in the list. Where a lot of new people get confused is that if it's between measures the one lone list item isn't named. So, they don't really notice that and don't understand why using a typical selector doesn't work.

In the independent measures case something like the following works.

tests[[1]]$'Pr(>F)'

In repeated measures it's similar but you could also use named items like...

myModelSummary$'Error: subject:A'[[1]]$'Pr(>F)'

Note there I still had to do that list selection because each one of the list items in the repeated measures model is again a list of 1.

Check out str(summary(test)) - that's where you see the p-value.

Illya K

Somewhat shorter, than in BurningLeo's advice:

summary(test)[[1]][[1,"Pr(>F)"]]
summary(aov(y~factor(x)))[[1]][[5]][1]
unlist(summary(myAOV)[[2]])[[9]]

2 and 9 are the positions of p-value in myAOV model

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!