Hi, how can I extract the t-values after running a pairwise.t.test? The output just list the p-values. Many thanks for your help. Cheers Guido ____________________________________ Guido J. Parra School of Tropical Environment Studies and Geography James Cook University Townsville Queensland 4811 Phone: 61 7 47815824 Fax: 61 7 47814020 Mobile: 0437630843 e-mail: guido.parravergara at jcu.edu.au
extract t-values from pairwise.t.test
6 messages · Guido Parra Vergara, PIKAL Petr, Simon Blomberg +1 more
Hallo My output lists more than p-values
ttt<-t.test(rnorm(10), rnorm(10), paired=T) ttt
Paired t-test
data: rnorm(10) and rnorm(10)
t = 1.7508, df = 9, p-value = 0.1139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.1750263 1.3735176
sample estimates:
mean of the differences
0.5992456
str(ttt)
List of 9 $ statistic : Named num 1.75 ..- attr(*, "names")= chr "t" $ parameter : Named num 9 ..- attr(*, "names")= chr "df" $ p.value : num 0.114 $ conf.int : atomic [1:2] -0.175 1.374 ..- attr(*, "conf.level")= num 0.95 $ estimate : Named num 0.599 ..- attr(*, "names")= chr "mean of the differences" $ null.value : Named num 0 ..- attr(*, "names")= chr "difference in means" $ alternative: chr "two.sided" $ method : chr "Paired t-test" $ data.name : chr "rnorm(10) and rnorm(10)" - attr(*, "class")= chr "htest"
ttt$statistic
t 1.750790
The output is list and you can call any part of it by its name or by [] braces. HTH Petr
On 8 Aug 2005 at 16:26, Guido Parra Vergara wrote:
Hi, how can I extract the t-values after running a pairwise.t.test? The output just list the p-values. Many thanks for your help. Cheers Guido
____________________________________ Guido J. Parra School of Tropical Environment Studies and Geography James Cook University Townsville Queensland 4811 Phone: 61 7 47815824 Fax: 61 7 47814020 Mobile: 0437630843 e-mail: guido.parravergara at jcu.edu.au ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Petr Pikal petr.pikal at precheza.cz
I think the questioner was interested in pairwise.t.test. See ?pairwise.t.test. From looking at the source, pairwise.t.test calls t.test if sd's are not pooled, or calculates its own t.val if sds are pooled. It looks very easy to hack to return the t values instead of the p values. Simon.
At 04:46 PM 8/08/2005, Petr Pikal wrote:
Hallo My output lists more than p-values
ttt<-t.test(rnorm(10), rnorm(10), paired=T) ttt
Paired t-test
data: rnorm(10) and rnorm(10)
t = 1.7508, df = 9, p-value = 0.1139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.1750263 1.3735176
sample estimates:
mean of the differences
0.5992456
str(ttt)
List of 9 $ statistic : Named num 1.75 ..- attr(*, "names")= chr "t" $ parameter : Named num 9 ..- attr(*, "names")= chr "df" $ p.value : num 0.114 $ conf.int : atomic [1:2] -0.175 1.374 ..- attr(*, "conf.level")= num 0.95 $ estimate : Named num 0.599 ..- attr(*, "names")= chr "mean of the differences" $ null.value : Named num 0 ..- attr(*, "names")= chr "difference in means" $ alternative: chr "two.sided" $ method : chr "Paired t-test" $ data.name : chr "rnorm(10) and rnorm(10)" - attr(*, "class")= chr "htest"
ttt$statistic
t 1.750790
The output is list and you can call any part of it by its name or by [] braces. HTH Petr On 8 Aug 2005 at 16:26, Guido Parra Vergara wrote:
Hi, how can I extract the t-values after running a pairwise.t.test? The output just list the p-values. Many thanks for your help. Cheers Guido
____________________________________ Guido J. Parra School of Tropical Environment Studies and Geography James Cook University Townsville Queensland 4811 Phone: 61 7 47815824 Fax: 61 7 47814020 Mobile: 0437630843 e-mail: guido.parravergara at jcu.edu.au ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Petr Pikal petr.pikal at precheza.cz
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Guido Parra Vergara <guido.parravergara at jcu.edu.au> writes:
Hi, how can I extract the t-values after running a pairwise.t.test? The output just list the p-values. Many thanks for your help.
It's not a very complicated function. Why not just modify it to your needs?
O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Hi, I am not familiar with changing R functions. I can see in the code that t-values get calculated as t. val, however when I modified the code to include t.val under ans and then run the modified function I get Object "t.val" not found. How do I properly modify the function to list t. val in the output? Thanks Guido
At 05:20 PM 8/08/2005, Peter Dalgaard wrote:
Guido Parra Vergara <guido.parravergara at jcu.edu.au> writes:
Hi, how can I extract the t-values after running a pairwise.t.test? The output just list the p-values. Many thanks for your help.
It's not a very complicated function. Why not just modify it to your needs? -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
____________________________________ Guido J. Parra School of Tropical Environment Studies and Geography James Cook University Townsville Queensland 4811 Phone: 61 7 47815824 Fax: 61 7 47814020 Mobile: 0437630843 e-mail: guido.parravergara at jcu.edu.au
Hallo
I am not sure but this could be what you want. You has to change
function compare.levels not only add t.val in ans. If you want t-
values AND p-values together in one table it probably is not so
simple.
my.pairded.t.test <- function (x, g, p.adjust.method =
p.adjust.methods, pool.sd = TRUE,
...)
{
DNAME <- paste(deparse(substitute(x)), "and",
deparse(substitute(g)))
g <- factor(g)
p.adjust.method <- match.arg(p.adjust.method)
if (pool.sd) {
METHOD <- "t tests with pooled SD"
xbar <- tapply(x, g, mean, na.rm = TRUE)
s <- tapply(x, g, sd, na.rm = TRUE)
n <- tapply(!is.na(x), g, sum)
degf <- n - 1
total.degf <- sum(degf)
pooled.sd <- sqrt(sum(s^2 * degf)/total.degf)
compare.levels <- function(i, j) {
dif <- xbar[i] - xbar[j]
se.dif <- pooled.sd * sqrt(1/n[i] + 1/n[j])
t.val <- dif/se.dif
# 2 * pt(-abs(t.val), total.degf) this is commented out
t.val # this is added
}
}
else {
METHOD <- "t tests with non-pooled SD"
compare.levels <- function(i, j) {
xi <- x[as.integer(g) == i]
xj <- x[as.integer(g) == j]
t.test(xi, xj, ...)$statistic # this is changed in case
# pool.sd=F
}
}
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
}
HTH
Petr
On 8 Aug 2005 at 18:28, Guido Parra Vergara wrote:
Hi, I am not familiar with changing R functions. I can see in the code that t-values get calculated as t. val, however when I modified the code to include t.val under ans and then run the modified function I get Object "t.val" not found. How do I properly modify the function to list t. val in the output? Thanks Guido At 05:20 PM 8/08/2005, Peter Dalgaard wrote:
Guido Parra Vergara <guido.parravergara at jcu.edu.au> writes:
Hi, how can I extract the t-values after running a pairwise.t.test? The output just list the p-values. Many thanks for your help.
It's not a very complicated function. Why not just modify it to your needs? -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
____________________________________ Guido J. Parra School of Tropical Environment Studies and Geography James Cook University Townsville Queensland 4811 Phone: 61 7 47815824 Fax: 61 7 47814020 Mobile: 0437630843 e-mail: guido.parravergara at jcu.edu.au ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Petr Pikal petr.pikal at precheza.cz