*11*

AÂ **paired samples t-test**Â is used to compareÂ the means of two samples when each observation in one sample can be paired with an observation in the other sample.

This tutorial explains how to conduct a paired samples t-test in Stata.

**Example: Paired samples t-test in Stata**

Researchers want to know if a new fuel treatment leads to a change in the average mpg of a certain car. To test this, they conduct an experiment in which they measure the mpg of 12 cars with and without the fuel treatment.

Since each car receives the treatment, we can conduct a paired t-test in which each car is paired with itselfÂ to determine if there is a difference in average mpg with and without the fuel treatment.

Perform the following steps to conduct a paired t-test in Stata.

**Step 1: Load the data.**

First, load the data by typing **use http://www.stata-press.com/data/r13/fuelÂ **in the command box and clicking Enter.

**StepÂ ****2: View the raw data.**

Before we perform a paired t-test, letâ€™s first view the raw data. Along the top menu bar, go toÂ **Data > Data Editor > Data Editor (Browse)**. The first column,Â *mpg1*, shows the mpg for the first car without fuel treatment while the second column, *mpg2*, shows the mpg for the first car with the fuel treatment.

**Step 3: Perform a paired t-test.**

Along the top menu bar, go to **Statistics > Summaries, tables, and tests > Classical tests of hypotheses > t test (mean-comparison test)**.

Choose *Paired.*Â For First variable, chooseÂ *mpg1*. For Second variable, chooseÂ *mpg2*. For Confidence level, chooseÂ any level youâ€™d like. A value of 95 corresponds to a significance level of 0.05. We will leave this at 95. Lastly, click *OK*.

The results of the paired t-test will be displayed:

We are given the following information for each group:

**Obs:Â **The number of observations. There are 12 observations in each group.

**Mean:Â **The mean mpg. In group 0, the mean is 21. In group 1, the mean is 22.75.

**Std. Err: **The standard error, calculated as Ïƒ /Â âˆšn

**Std. Dev:Â **The standard deviation of mpg.

**95% Conf. Interval:Â **The 95% confidence interval for the true population mean of mpg.

**t:Â **The test statistic of the paired t-test.

**degrees of freedom:Â **The degrees of freedom to be used for the test, calculated as #pairs-1 = 12-1 = 11.

The p-values for three different two sample t-tests are displayed at the bottom of the results. Since we are interested in understanding if the average mpg is simply different between the two groups, we will look at the results of the middle test (in which the alternative hypothesis is Ha: diff !=0) which has a p-value ofÂ **0.0463**.

Since this value is smaller than our significance level of 0.05, we reject the null hypothesis. We have sufficient evidence to say that the true mean mpg is different between the two groups.

**Step 5: Report the results.**

Lastly, we will report the results of our paired t-test. Here is an example of how to do so:

A paired t-test was conducted on 12 cars to determine if a new fuel treatment lead to a difference in mean miles per gallon.

Â

Results showed that the mean mpg was statistically significantly

Âdifferent between the two groups (t = -2.2444 w/ df=11, p = .0463) at a significance level of 0.05.Â

A 95% confidence interval for the true difference in population means resulted in the interval of (-3.466, -.034).

Â

Based on these results, the new fuel treatment leads to a statistically significantly higher mpg for cars.