views:

7287

answers:

4

Hi everyone,

I have written a Perl script that performs many one-sample t-tests. I get thousands of t-statistics with their degrees of freedom (df). I need to upgrade the script to also return their p-values (there are too many to look them up manually in a table). Is there some kind of formula I can use for this with the t-statistic and d.f as input? I hope someone can help me with this, many thanks in advance!

A.A.

+4  A: 

it sounds like you are asking 'how do i compute a p-value', which isn't really a programming/implementation question, it's a theory question. if that is the case, your best bet is probably your stats book, your professor, or

http://en.wikipedia.org/wiki/P-value

and,

Some Statistical Issues in the Comparison of Speech Recognition Algorithms

also has some good, if somewhat advanced info.

blackkettle
+1  A: 

If you are doing a two-tailed test, then your p-value = 2*P(T > t), where t is your calculated test statistic. So essentially, you need a way to model the T-dist in order to integrate(T-dist from t to INFINITY). Here is a demo: http://www.stat.tamu.edu/~west/applets/tdemo.html

I'm not familiar with Perl and its libraries, but hopefully this gets you started. You can write a rudimentary integrator and check some values to make sure that it is accurate enough.

Elben Shira
FWIW, I think this is the best answer... :)
j_random_hacker
+6  A: 

Using Statistics::Distributions seems pretty straightforward:

print Statistics::Distributions::tprob($dof,$tstat);

In addition, Statistics::Distributions::Analyze will perform the entire t-test.

bubaker
Thanks a lot u guys! I really appreciate all your help. I think bubaker's answer is the one I needed!
Abdel