This project has moved and is read-only. For the latest updates, please go here.

Is there a p-value that I can get from student t-test?

May 3, 2011 at 6:22 PM

I really like meta.numerics library as it's light weight but powerful.

Just wondering if there is any way to get a p-value from, let's say, a student t-test without looking up the reference table on the web?

I am developing a web tool that can pull data from database and do some statistical analysises.

Meta.Numerics.Statistics.

TestResult t = Meta.Numerics.Statistics.Sample

.StudentTTest(sample1, sample2);

The only items I can get are left probability, right probability and statistic, which will be the T value. 

May 3, 2011 at 6:50 PM
Edited May 3, 2011 at 6:52 PM

The left and right probabilities are P-values. Suppose the distribution of a test statistic (t.Distribution) looks like this:

   XX
  XXXY
XXXXXYYY
     ^

(That's supposed to look like a t-distribution.) If the actual value of the test statistic (t.Statistic) is where the caret is, then the one sided tail probability of that test statistic value is the area of Ys, which is t.RightProbability. So the code to compute a one-sided tail probability is:

double oneSidedP;
if (t.Statistic < 0.0) {
  oneSidedP = t.LeftProbability;
} else {
  oneSidedP = t.RightProbability;
}

If you are asking for the two-sided tail probability, that is:

double twoSidedP;
if (t.Statistic< 0.0) {
  twoSidedP = 2.0 * t.LeftProbability;
} else {
  twoSidedP = 2.0 * t.RightProbability;
}

Do let me know if these values aren't agreeing with your table values. They certainly should be.

For tests that are often used two-sided, we should probably add CentralProbability and TailProbability methods to the TestResult.

May 3, 2011 at 7:34 PM
gosh thanks a lot for that quick, nice and clear response.

Yes the number did match on my result, which doesn't even have one sided p value there.

You are so awesome. I love the software too.

Thanks a lot

Best regards,

David Liang




From: [email removed]
To: [email removed]
Date: Tue, 3 May 2011 10:50:17 -0700
Subject: Re: Is there a p-value that I can get from student t-test? [metanumerics:256175]

From: ichbin
The left and right probabilities are P-values. Suppose the distribution of a test statistic (t.Distribution) looks like this:
   XX
  XXXY
XXXXXYYY
     ^
(That's supposed to look like a t-distribution.) If the actual value of the test statistic (t.Statistic) is where the caret is, then the one sided tail probability of that test statistic value is the area of Ys, which is t.RightProbability. So the code to compute a one-sided tail probability is:
double oneSidedP;
if (t.Statistic < 0.0) {
  oneSidedP = t.LeftProbability;
} else {
  oneSidedP = t.RightProbability;
}
If you are asking for the two-sided tail probability, that is:
double twoSidedP;
if (t.Statistic< 0.0) {
  twoSidedP = 2.0 * t.LeftProbability;
} else {
  twoSidedP = 2.0 * t.RightProbability;
}
Do let me know if these values aren't agreeing with your table values. They certainly should be.
For tests that are often used two-sided, we should probably add CentralProbability and TailProbability methods to the TestResult.
Read the full discussion online.
To add a post to this discussion, reply to this email (metanumerics@discussions.codeplex.com)
To start a new discussion for this project, email metanumerics@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Jul 26, 2011 at 4:17 AM
Edited Jul 28, 2011 at 5:42 PM

nice library!

I am running into the below problem.

I am writing data into excel. I want to use the t-test paired two sample for means to calculate the p-values. When I calculate the p-value as shown in the

above post, it calculates the p-value based on assumption that the variances of the two data groups are equal. But the variance of the data groups I am using are not equal.

How can I calculate the p-value when the variance of two data groups are not equal.

Any help is appreciated.

Thanks.