# How to Create a Graphical Version of the 1-sample t-Test in Minitab

This is a companion post for a series of blog posts about understanding hypothesis tests. In this series, I create a graphical equivalent to a 1-sample t-test and confidence interval to help you understand how it works more intuitively.

This post focuses entirely on the steps required to create the graphs. It’s a fairly technical and task-oriented post designed for those who need to create the graphs for illustrative purposes. If you’d instead like to gain a better understanding of the concepts behind the graphs, please see the following posts:

- Understanding Hypothesis Tests: Why We Need to Use Hypothesis Tests
- Understanding Hypothesis Tests: The Significance Level and P Values
- Understanding Hypothesis Tests: Confidence Intervals and Confidence Levels

To create the following graphs, we’ll use Minitab’s probability distribution plots in conjunction with several statistics obtained from the 1-sample t output. If you’d like more information about the formulas that are involved, you can find them in Minitab at: **Help > Methods and Formulas > Basic Statistics > 1-Sample t**.

The data for this example is FamilyEnergyCost and it is just one of the many data set examples that can be found in Minitab’s Data Set Library. We’ll perform the regular 1-sample t-test with a null hypothesis mean of 260, and then graphically recreate the results.

## How to Graph the Two-Tailed Critical Region for a Significance Level of 0.05

To create a graphical equivalent to a 1-sample t-test, we’ll need to graph the t-distribution using the correct number of degrees of freedom. For a 1-sample t-test, the degrees of freedom equals the sample size minus 1. So, that’s 24 degrees of freedom for our sample of 25.

- In Minitab, choose:
**Graph > Probability Distribution Plot > View Probability**. - In
**Distribution**, select**t**. - In
**Degrees of freedom**, enter*24*. - Click the
**Shaded Area**tab. - In
**Define Shaded Area By**, select**Probability**and**Both Tails**. - In
**Probability**, enter*0.05*. - Click
**OK**.

You should see this graph.

This graph shows the distribution of t-values for a sample of our size with the t-values for the end points of the critical region. The t-value for our sample mean is 2.29 and it falls within the critical region.

For my blog posts, I thought displaying the x-axis in the same units as our measurement variable (energy costs) would make the graph easier to understand. To do this, we need to transform the x-axis scale from t-values to energy costs.

Transforming the t-values to energy costs for a distribution centered on the null hypothesis mean requires a simple calculation:

Energy Cost = Null Hypothesis Mean + (t-value * SE Mean)

We’ll use the null hypothesis value that we entered in the dialog box (260) and the SE Mean value that appears in the 1-sample t-test output (30.8). We need to calculate the energy cost values for all of the t-values that will appear on the x-axis (-4 to +4).

For example, a t-value of 1 equals 290.8 (260 + (1*30.8). Zero is the null hypothesis value, which is 260.

Next, we need to replace the t-values with the energy cost equivalents.

- Choose
**Editor > Select Item > X Scale**. - Choose
**Editor > Edit X Scale**. - In
**Major Tick Position**, choose**Number of Ticks**and enter*9*. - Click the
**Show**tab and check the**Low**check box for**Major ticks**and**Major tick labels**. - Click the
**Labels**tab of the dialog box that appears. Enter the energy cost values that you calculated as shown below. I use rounded values to keep the x-axis tidy. Click**OK**.

You should see this graph. To cleanup the x-axis, I had to delete the t-values that were still showing from before. Simply click each t-value once and press the **Delete** key.

Let’s add a reference line to show where our sample mean falls within the sampling distribution and critical region. The trick here is that the x-axis still uses t-values despite displaying the energy costs. We need to use the t-value for our sample mean that appears in the 1-sample t output (2.29).

- Choose
**Editor > Add > Reference Lines**. - In
**Show reference lines at X values**, enter*2.29.* - Click
**OK**. - Double click the
*2.29*that now appears on the graph. - In the dialog box that appears, enter
*330.6*in**Text**. - Click
**OK**.

After editing the title and the x-axis label, you should have a graph similar to the one below.

## How to Graph the P Value for a 1-sample t-Test

To do this, we’ll duplicate the graph we created above and then modify it. This allows us to reuse some of the work that we’ve already done.

- Make sure the graph we created is selected.
- Choose
**Editor > Duplicate Graph**. - Double click the blue distribution curve on the graph.
- Click the
**Shaded Area**tab in the dialog box that appears. - In
**Define Shaded Area By**, select**X Value**and**Both Tails**. - In
**X value**, enter*2.29*. - Click
**OK**.

You’ll need to edit the graph title and delete some extra numbers on the x-axis. After these edits, you should have a graph similar to this one.

### How to Graph the Confidence Interval for a 1-sample t-test

To graphically recreate the confidence interval, we’ll need to start from scratch for this graph.

- In Minitab, choose:
**Graph > Probability Distribution Plot > View Probability**. - In
**Distribution**, select**t**. - In
**Degrees of freedom**, enter*24*. - Click the
**Shaded Area**tab. - In
**Define Shaded Area By**, select**Probability**and**Middle**. - Enter
*0.025*in both**Probability 1**and**Probability 2**. - Click
**OK**.

Your graph should look like this:

Like before, we’ll need to transform the x-axis into energy costs. For this graph, I’ll only display the x-values for the end points of the confidence interval and the sample mean. So, we need to convert the three t-values of -2.064, 0, 2.064.

The equation to transform the t-values to energy costs for a distribution centered on the sample mean is:

Energy Cost = Sample Mean + (t-score * SE Mean)

We obtain the following rounded values that represent the lower confidence limit, sample mean, and upper confidence limit: 267, 330.6, 394.

Simply double click the values in the x-axis to edit each individual label. Replace the t-value with the energy cost value. After editing the graph title, you should have a visual representation of the confidence interval that looks like this. I rounded the values for the confidence limits.

## Consider Using Minitab's Command Language

When I create multiple graphs that involve many steps, I generally use Minitab's command language. This may sound daunting if you're not familiar with using this command language. However, Minitab makes this easier for you.

After you create one graph, choose **Editor > Copy Command Language**, and paste it into a text editor, such as Notepad. Save the file with the extension *.mtb and you have a Minitab Exec file. This Exec file contains all of the edits you made. Now, you can easily create similar graphs simply by modifying the parts that you want to change.

You can also get help for the command language right in Minitab. First, make sure the command prompt is enabled by choosing **Editor > Enable Commands**. At the prompt, type *help dplot*, and Minitab displays the help specific to probability distribution plots!

To run an exec file, choose **File > Other Files > Run an Exec**. Click **Select File** and browse to the file you saved. Here are the MTB files for my graphs for the critical region, P value, and confidence interval.

Happy graphing!