Search code examples
rp-valuet-test

Back calculating t-statistic in R


I have these information from an independent samples t-test.

p-value=0.989
sample size for group 1 (n1)= 17
sample size for group 2 (n2)= 18
mean difference= 0.30

I need the t-statistic for this test. I did trial and error with the code for p-value to get the t-statistic, that is 0.014 2*pt(0.014, 33, lower.tail=F) #p=0.989

I need a the R code that gets the p-value and df as input, and provides 0.014 as the output.


Solution

  • There's no need of uniroot. Use qt:

    > qt(0.989/2, df = 33, lower.tail = FALSE)
    [1] 0.01389174