8. Testing for Differences in Means and Proportions: Paired Samples t-test
Paired Samples t-test: Test Statistic and p-value
Paired Samples t-test: Test Statistic
The test statistic of a paired samples -test is denoted .
To compute the -statistic, first compute the difference score for each subject:
The resulting sample of difference scores will serve as the sample data for the hypothesis test.
Once the sample of difference scores has been constructed, calculate the sample mean and the sample standard deviation for the sample of difference scores:
Once the statistics of the sample of difference scores have been calculated, the -statistic can be computed:
Under the null hypothesis of a paired samples -test, the -statistic follows a -distribution with degrees of freedom.
Calculating the p-value of a Paired Samples t-test with Statistical Software
The calculation of the -value of a paired samples -test is dependent on the direction of the test and can be performed using either Excel or R.
To calculate the -value of a paired samples -test for in Excel, make use of one of the following commands:
To calculate the -value of a paired samples -test for in R, make use of one of the following commands:
If , reject and conclude . Otherwise, do not reject .
The government of Canada wants to know whether the legalization of marihuana has had any effect on the rate of drug-related offenses. To investigate this matter, a researcher selects a simple random sample of cities and compares the rates of drug-related offenses before and after the legalization was implemented.
The values in the table below are the number of drug-related offenses per , residents:
City | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
242 | 237 | 270 | 261 | 251 | 261 | 262 | 228 | 255 | 221 | |
237 | 221 | 267 | 251 | 254 | 256 | 265 | 218 | 257 | 226 |
You may assume that the population distributions of drug-related offenses both before and after the legalization are normal.
The researcher plans on using a paired samples -test to determine whether the legalization of marihuana has had a significant effect on the number of drug-related offenses.
Define .
Calculate the -value of the test and make a decision regarding . Round your answer to decimal places. Use the significance level.
On the basis of this -value, should not be rejected, because .
There are a number of different ways we can calculate the -value of the test. Click on one of the panels to toggle a specific solution.
Compute the difference scores using :
City | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
242 | 237 | 270 | 261 | 251 | 261 | 262 | 228 | 255 | 221 | |
237 | 221 | 267 | 251 | 254 | 256 | 265 | 218 | 257 | 226 | |
5 | 16 | 3 | 10 | -3 | 5 | -3 | 10 | -2 | -5 |
Compute the mean of the difference scores :
Compute the standard deviation of the difference scores :
Compute the -statistic:
Assuming the population distributions of drug-related offenses are normal, we know that the test statistic
has the distribution, under the assumption that is true.
To calculate the -value of a -test, make use of the following Excel function:
T.DIST(x, deg_freedom, cumulative)
- x: The value at which you wish to evaluate the distribution function.
- deg_freedom: An integer indicating the number of degrees of freedom.
- cumulative: A logical value that determines the form of the function.
- TRUE - uses the cumulative distribution function,
- FALSE - uses the probability density function
Since we are dealing with a two-tailed -test, run the following command to calculate the -value:
This gives:
Since , should not be rejected.
Compute the difference scores using :
City | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
242 | 237 | 270 | 261 | 251 | 261 | 262 | 228 | 255 | 221 | |
237 | 221 | 267 | 251 | 254 | 256 | 265 | 218 | 257 | 226 | |
5 | 16 | 3 | 10 | -3 | 5 | -3 | 10 | -2 | -5 |
Compute the mean of the difference scores :
Compute the standard deviation of the difference scores :
Compute the -statistic:
Assuming the population distributions of drug-related offenses are normal, we know that the test statistic
has the distribution, under the assumption that is true.
To calculate the -value of a -test, make use of the following R function:
pt(q, df, lower.tail)
- q: The value at which you wish to evaluate the distribution function.
- df: An integer indicating the number of degrees of freedom.
- lower.tail: If TRUE (default), probabilities are , otherwise, .
Since we are dealing with a two-tailed -test, run the following command to calculate the -value:
This gives:
Since , should not be rejected.