Extract t value from parwise.t.test file

I would like to know if I can extract the values ​​of t from the pairwise.t.test function, since it only reports the values ​​of p. I used parwise.t.test () for multiple comparisons after running repeated anova measures that reported a significant main effect.

Thank you in advance!

+5
source share
2 answers

There are a few simple things to try when trying to understand something like this (of course, there is no guarantee that they will work in any given case). The first thing to try is to look at the documentation ( ?pairwise.t.test ) and see what is listed in the Value section. In this case, he only says:

Class object "pairwise.htest"

The second thing to try is to get an example of the object and assign it to a variable, then you can run str(obj) . Below is an example from the documentation:

 attach(airquality) Month <- factor(Month, labels = month.abb[5:9]) obj <- pairwise.t.test(Ozone, Month) str(obj) List of 4 $ method : chr "t tests with pooled SD" $ data.name : chr "Ozone and Month" $ p.value : num [1:4, 1:4] 1 0.000264 0.000195 1 NA ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:4] "Jun" "Jul" "Aug" "Sep" .. ..$ : chr [1:4] "May" "Jun" "Jul" "Aug" $ p.adjust.method: chr "holm" - attr(*, "class")= chr "pairwise.htest" 

Unfortunately, this does not show what we would like to see (for example, something like $ t.stat ).

The last option is to look at the code. You can get it by entering a function call without parentheses on the command line:

 > pairwise.t.test function (x, g, p.adjust.method = p.adjust.methods, pool.sd = !paired, paired = FALSE, alternative = c("two.sided", "less", "greater"), ...) { <code omitted> if (pool.sd) { <code omitted> } } else { <code omitted> compare.levels <- function(i, j) { xi <- x[as.integer(g) == i] xj <- x[as.integer(g) == j] t.test(xi, xj, paired = paired, alternative = alternative, ...)$p.value } } PVAL <- pairwise.table(compare.levels, levels(g), p.adjust.method) ans <- list(method = METHOD, data.name = DNAME, p.value = PVAL, p.adjust.method = p.adjust.method) class(ans) <- "pairwise.htest" ans } 

The key part is the specific function compare.levels , which only stores the p value from the underlying t-test. So the direct answer to your question is no, you cannot extract t-statistics.

+5
source

You can get the values ​​of t (as well as dfs) ​​from the parwise.t.test file by writing a custom function. See my previous post .

+1
source

Source: https://habr.com/ru/post/1211793/


All Articles