# How to calculate p-value from test statistic

By Indeed Editorial TeamOctober 21, 2021Finding the significance of a data sample is an important tool for statisticians, data analysts and other data scientists. One metric of sig

By Indeed Editorial Team

October 21, 2021

Finding the significance of a data sample is an important tool for statisticians, data analysts and other data scientists. One metric of significance is p-value, which many professionals use when they publish their research because it allows others to make conclusions about data. Knowing what p-value is, how to use it and how to calculate it can help you understand data and form hypotheses based on it. In this article, we discuss what p-value is, review its uses, explain how to calculate it and provide a helpful example.

Related: Statistical Significance: Definition and Application in the Workplace

## What is a p-value?

P-value is a statistical metric that represents the probability of an extreme result occurring. This result is at least as extreme as an observed result in a statistical hypothesis test by random chance, assuming the null hypothesis is correct. Hypothesis testing in statistics is a way to determine the significance of a particular data point or set. Below are definitions for different terms you can use to understand what p-value is:

• Null hypothesis: To make a null hypothesis, it means that you're predicting that there's no statistical significance between an observed result and the data set to which it belongs. For example, if the average body temperature of group A and group B is the same, then you could create a null hypothesis stating there's no statistical significance between the average body temperatures of group A and group B.
• Significance: In hypothesis testing, significance refers to when a result is very unlikely to have occurred if the null hypothesis is correct.
• Alternative hypothesis: This type of hypothesis refers to when there's statistical significance between an observed result and the data set it belongs to, meaning that your test rejects a null hypothesis you made. For example, you could create an alternative hypothesis stating that there's a difference between the average body temperatures of group A and group B based on your results.

P-value is a measurement that assumes the null hypothesis is correct, meaning that if the value is small, then you can reject the null hypothesis in favor of the alternative hypothesis. A large p-value typically means that the data point or set you measured aligns with the null hypothesis, making it the more likely outcome. P-value is a measurement that you can use in published research to allow readers to interpret the data themselves.

Related: Alternative Hypothesis: Definition and When To Use It

## Uses for p-value

Statisticians, data analysts and businesses all use p-value to determine how far outside a data set a particular data point exists. This can be helpful for determining whether the data point is an effective metric for increasing production and profits for businesses, whether data is significant for data analysts and whether a data point is reasonable for other statistical measures. There are two types of p-value you can use:

• One-sided p-value: You can use this method of testing if a large or unexpected change in the data makes only a small or no difference to your data set. Typically, this is unusual and you can use a two-sided p-value test instead.
• Two-sided p-value: You can use this method of testing if a large change in the data would affect the outcome of the research and if the alternative hypothesis is fairly general instead of specific. Most professionals use this method to ensure they account for large changes in data.

Related: Understanding What a Null Hypothesis Is

## How to calculate p-value

Below are steps you can use to help calculate the p-value for a data sample:

### 1. State the null and alternative hypotheses

The first step to calculating the p-value of a sample is to look at your data and create a null and alternative hypothesis. For example, you could state that a hypothesized mean "μ" is equal to 10 and because of this, the alternative hypothesis is that the hypothesized mean "μ" is not equal to 10. You can write these hypotheses as:

H0: μ = 10

H1: μ  10

In these hypotheses:

• "H0" is the null hypothesis.
• "H1" is the alternative hypothesis.
• "μ" is the hypothetical mean that you determine.
• "" is a symbol that means does not equal.

### 2. Use a t-test and its formula

Once you have determined what both of your hypotheses are, you can calculate the value of your test statistic "t" based on your data set. The formula to calculate this statistic is:

t = (x̄ - μ) / (s / n)

In this formula:

• "t" is the test statistic.
• "x̄" is the sample mean.
• "μ" is the hypothesized mean.
• "s" is the standard deviation of the sample.
• "n" is the size of the sample.

Standard deviation in mathematics is a measure of the variation in a set of data. It can also help you understand how close to the mean a data point a sample is in comparison to other data points.

### 3. Use a t-distribution table to find the associated p-value

Once you've calculated the value of the test statistic "t," you can find the associated p-value by referring to a t-distribution table, which you can find on the internet. There are three major significance values on a t-distribution table that p-value uses: 0.01, 0.05 and 0.1. These values measure how close a hypothesis is to a data set. To use the t-distribution table, you can choose which of the significance values you want your data to fall within. You can do this by taking your sample size "n," and subtracting 1 from it. For example:

n = 10

10  1 = 9

Then you can use the significance value you chose to find the corresponding value in the table. If you have a single-tailed distribution, this number is the p-value of your data. If you have a two-tailed distribution, which is more common, then you can multiply this number by two to get your p-value.

Related: Defining Hypothesis Testing (With Examples)

## Example of calculating p-value

Below is an example of calculating p-value based on a known set of data:

Owen wants to know if the mean amount of rainfall for the month of August is nine inches. He finds data for the month of August last year and determines that the sample mean is eight inches, with a standard deviation of two inches. He decides to conduct a two-tailed t-test to find the p-value with a 0.01 level to determine if nine is the true mean of the data. He forms the following hypotheses:

• H0: μ = 9 inches
• H1: μ  9 inches

After he creates his hypotheses, he calculates the absolute value, or "|t|," of the test like this:

• t = (8  9) / (2 / 31)
• t = (1) / (0.35921)
• t = 2.78388
• |t| = 2.78388

Using this t-value, he uses a t-distribution table to locate values based on his values of 0.01 and 2.78388. He uses a sample size of 31 since there are 31 days in August. He subtracts 1 from his sample size like this:

31  1 = 30

Then he reviews his "t" value of 2.78388, which falls between the levels 0.005 and 0.001 on a t-distribution table. He averages 0.005 and 0.001 to get a value of 0.003. With a two-tailed test, he can multiply this value by 2 to get 0.006, which is the p-value for this test. Since the p-value is less than the 0.01 level of significance, he rejects the null hypothesis he made and accepts his alternative hypothesis that the mean amount of rainfall for the month of August is not nine inches.