Re: [R] extract t-values from pairwise.t.test

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Mon 08 Aug 2005 - 20:00:25 EST

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 tvalues  AND p-values together in one table it probably is not so simple.

...)
{

DNAME <- paste(deparse(substitute(x)), "and", deparse(substitute(g)))

g <- factor(g)

```        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
}
```

}

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
}
```

}

ans <- list(method = METHOD, data.name = DNAME, p.value = PVAL,
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
> 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@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@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@jcu.edu.au
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help