Question

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.

Was it helpful?

Solution

Using Statistics::Distributions seems pretty straightforward:

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

OTHER TIPS

A search of MetaCPAN reveals the following:

https://metacpan.org/pod/Statistics::Distributions

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top