[R] Beginner's question about t.test()

Pramote Khuwijitjaru kmote at hotmail.com
Sun Feb 15 15:51:47 CET 2004


>From: pallier <pallier at lscp.ehess.fr>
>To: Pramote Khuwijitjaru <kmote at hotmail.com>
>Subject: Re: [R] Beginner's question about t.test()
>Date: Sun, 15 Feb 2004 10:48:05 +0100
>
>Pramote Khuwijitjaru wrote:
>
>>Dear All,
>>I am doing some exercise in statistics textbook on comparison of two 
>>experimental means. Is it possible to use t.test() do t-test when I have 
>>only two means, sample size, two standard deviations ? (no raw data).
>
>
>When you type 't.test.default', you get the source code of the t.test 
>function.
>
>If you are conducting a t.test with var.equal=T, paired=F, 
>alternative=two.sided,
>the following commands are executed:
>
>        df <- nx + ny - 2
>        v <- ((nx - 1) * vx + (ny - 1) * vy)/df
>        stderr <- sqrt(v * (1/nx + 1/ny))
>        tstat <- (mx - my - mu)/stderr
>        pval <- 2 * pt(-abs(tstat), df)
>
>
>You could write your own function taking nx, mx, vx and ny, my and vy as 
>args.
>
>my.t.test <- function (nx,mx,vx,ny,my,vy) {
>        df <- nx + ny - 2
>        v <- ((nx - 1) * vx + (ny - 1) * vy)/df
>        stderr <- sqrt(v * (1/nx + 1/ny))
>        tstat <- (mx - my)/stderr
>        pval <- 2 * pt(-abs(tstat), df)
>
>        cat("df=",df)
>        cat("\nT=",tstat)
>        cat("\np=",pval)
>}
>
>Christophe Pallier
>www.pallier.org
>
>
Thanks for your advice. Writing my own function should be the best way.

But  when I type t.test, I got
>t.test
function (x, ...)
UseMethod("t.test")
<environment: namespace:ctest>

and

>t.test.default
Error: Object "t.test.default" not found

I tried other couple of functions and found that only some functions (sd, 
var) will show their source when  type the name.

Could you point out the way to see function's source again ?

                                                                             
                 Pramote




More information about the R-help mailing list