*89*

AÂ **one sample t-test**Â is used to test whether or not the mean of a population is equal to some value.

This tutorial explains how to conduct a one sample t-test in Stata.

**Example: One Sample t-test in Stata**

Researchers want to know if automobiles, on average, get 20 miles per gallon. They collect a sample of 74 cars andÂ wish to conduct a one sample t-test to determine if the true average mpg is 20 or not.

Perform the following steps to conduct a one sample t-test.

**Step 1: Load the data.**

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

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

Before we perform a one sample t-test, letâ€™s first view the raw data. Along the top menu bar, go toÂ **Data > Data Editor > Data Editor (Browse)**. This will show us a bunch of information about each of the 74 cars, but keep in mind weâ€™re only interested in miles per gallon (the *mpgÂ *column):

**Step 3: Perform a one sample t-test.**

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

Keep *One-sample *selected. For Variable name, chooseÂ *mpg*. For Hypothesized mean, type inÂ *20*.Â 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 one sample t-test will be displayed:

Here is how to interpret the results:

**Obs:Â **The number of observations. In this case, there are 74 total cars.

**Mean:Â **The mean mpg of all cars. In this case, the mean is 21.2973 miles per gallon.

**Std. Err:Â **Calculated as Ïƒ /Â âˆšn = 5.785503 /Â âˆš74 = .6725511.

**Std. Dev:Â **The standard deviation of mpg. In this case, itâ€™s 5.785503.

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

**t:Â **The test statistic, calculated as (x â€“ u) / (Ïƒ /Â âˆšn)= (21.2973-20) / 5.785503 /Â âˆš74 = 1.9289.

**degrees of freedom:Â **The degrees of freedom to be used for the t-test, calculated as n-1 = 74-1 = 73.

The p-values for three different one sample t-tests are displayed at the bottom of the results. Since we are interested in understanding if the true average mpg is 20 or not, we will look at the results of the middle test (in which the alternative hypothesis is Ha: mean !=20) which has a p-value ofÂ **0.0576**.

Since this value is not smaller than our significance level of 0.05, we fail to reject the null hypothesis. We do not have sufficient evidence to say that the true mean mpg for this population of cars is different than 20 mpg.

**Step 4: Report the results.**

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

A one sample t-test was conducted on 74 cars to determine if the true population mean mpg was different than 20 mpg.

Â

Results showed that the true population mean wasÂ

notÂdifferent than 20 mpg (t = 1.9289 w/ df = 73, p = .0576) at a significance level of 0.05.Â

A 95% confidence interval for the true population mean resulted in the interval of (19.9569, 22.63769).