(For more resources related to this topic, see here.)

# Xbar-R charts and applying stages to a control chart

As with all control charts, the Xbar-R charts are used to monitor process stability. Apart from generating the basic control chart, we will look at how we can control the output with a few options within the dialog boxes. Xbar-R stands for means and ranges; we use the means chart to estimate the population mean of a process and the range chart to observe how the population variation changes.

For more information on control charts, see Understanding Statistical Process Control by Donald J. Wheeler and David S. Chambers.

As an example, we will study the fill volumes of syringes. Five syringes are sampled from the process at hourly intervals; these are used to represent the mean and variation of that process over time.

We will plot the means and ranges of the fill volumes across 50 subgroups. The data also includes a process change. This will be displayed on the chart by dividing the data into two stages.

The charts for subgrouped data can use a worksheet set up in two formats. Here the data is recorded such that each row represents a subgroup. The columns are the sample points. The Xbar-S chart will use data in the other format where all the results are recorded in one column.

The following screenshot shows the data with subgroups across the rows on the left, and the same data with subgroups stacked on the right:

## How to do it…

The following steps will create an Xbar-R chart staged by the Adjustment column with all eight of the tests for special causes:

1. Use the Open Worksheet command from the File menu to open the Volume.mtw worksheet.
2. Navigate to Stat | Control Charts | Variables charts for subgroups. Then click on Xbar-R….
3. Change the drop down at the top of the dialog to Observations for a subgroup are in one row of columns:.
4. Enter the columns Measure1 to Measure5 into the dialog box by highlighting all the measure columns in the left selection box and clicking on Select.

5. Click on Xbar-R Options and navigate to the tab for Tests.
6. Select all the tests for special causes.
7. Select the Stages tab.
8. Enter Adjustment in the Define Stages section.
9. Click on OK in each dialog box.

## How it works…

The R or range chart displays the variation over time in the data by plotting the range of measurements in a subgroup. The Xbar chart plots the means of the subgroups.

The choice of layout of the worksheet is picked from the drop-down box in the main dialog box. The All observations for a chart are in one column: field is used for data stacked into columns. Means of subgroups and ranges are found from subgroups indicated in the worksheet. The Observations for a subgroup are in one row of columns: field will find means and ranges from the worksheet rows.

The Xbar-S chart example shows us how to use the dialog box when the data is in a single column. The dialog boxes for both Xbar-R and Xbar-S work the same way.

Tests for special causes are used to check the data for nonrandom events. The Xbar-R chart options give us control over the tests that will be used. The values of the tests can be changed from these options as well. The options from the Tools menu of Minitab can be used to set the default values and tests to use in any control chart.

By using the option under Stages, we are able to recalculate the means and standard deviations for the pre and post change groups in the worksheet. Stages can be used to recalculate the control chart parameters on each change in a column or on specific values. A date column can be used to define stages by entering the date at which a stage should be started.

## There’s more…

Xbar-R charts are also available under the Assistant menu. The default display option for a staged control chart is to show only the mean and control limits for the final stage. Should we want to see the values for all stages, we would use the Xbar-R Options and Display tab. To place these values on the chart for all stages, check the Display control limit / center line labels for all stages box. See Xbar-S charts for a description of all the tabs within the Control Charts options.

# Using an Xbar-S chart

Xbar-S charts are similar in use to Xbar-R. The main difference is that the variation chart uses standard deviation from the subgroups instead of the range. The choice between using Xbar-R or Xbar-S is usually made based on the number of samples in each subgroup. With smaller subgroups, the standard deviation estimated from these can be inflated. Typically, with less than nine results per subgroup, we see them inflating the standard deviation, which increases the width of the control limits on the charts. Automotive Industry Action Group (AIAG) suggests using the Xbar-R, which is greater than or equal to nine times the Xbar-S.

Now, we will apply an Xbar-S chart to a slightly different scenario. Japan sits above several active fault lines. Because of this, minor earthquakes are felt in the region quite regularly. There may be several minor seismic events on any given day. For this example, we are going to use seismic data from the Advanced National Seismic System. All seismic events from January 1, 2013 to July 12, 2013 from the region that covers latitudes 31.128 to 45.275 and longitudes 129.799 to 145.269 are included in this dataset. This corresponds to an area that roughly encompasses Japan.

The dataset is provided for us already but we could gather more up-to-date results from the following link:

http://earthquake.usgs.gov/monitoring/anss/

To search the catalog yourself, use the following link:

http://www.ncedc.org/anss/catalog-search.html

We will look at seismic events by week that create Xbar-S charts of magnitude and depth. In the initial steps, we will use the date to generate a column that identifies the week of the year. This column is then used as the subgroup identifier.

## How to do it…

The following steps will create an Xbar-S chart for the depth and magnitude of earthquakes. This will display the mean, and standard deviation of the events by week:

1. Use the Open Worksheet command from the File menu to open the earthquake.mtw file.
2. Go to the Data menu, click on Extract from Date/Time, and then click on To Text.
3. Enter Date in the Extract from Date/time column: section.
4. Type Week in the Store text column in: section.
5. Check the selection for Week and click on OK to create the new column.
6. Navigate to Stat | Control Charts | Variable charts for Subgroups and click on Xbar-S.
7. Enter Depth and Mag into the dialog box as shown in the following screenshot and Week into the Subgroup sizes: field.

8. Click on the Scale button, and select the option for Stamp.
9. Enter Date in the Stamp columns section.
10. Click on OK.
11. Click on Xbar-S Options and then navigate to the Tests tab.
12. Select all tests for special causes.
13. Click on OK in each dialog box.

## How it works…

Steps 1 to 4 build the Week column that we use as the subgroup. The extracts from the date/time options are fantastic for quickly generating columns based on dates. Days of the week, week of the year, month, or even minutes or seconds can all be separated from the date.

Multiple columns can be entered into the control chart dialog box just as we have done here. Each column is then used to create a new Xbar-S chart. This lets us quickly create charts for several dimensions that are recorded at the same time. The use of the week column as the subgroup size will generate the control chart with mean depth and magnitude for each week.

The scale options within control charts are used to change the display on the chart scales. By default, the x axis displays the subgroup number; changing this to display the date can be more informative when identifying the results that are out of control. Options to add axes, tick marks, gridlines, and additional reference lines are also available. We can also edit the axis of the chart after we have generated it by double-clicking on the x axis.

The Xbar-S options are similar for all control charts; the tabs within Options give us control over a number of items for the chart. The following list shows us the tabs and the options found within each tab:

• Parameters: This sets the historical means and standard deviations; if using multiple columns, enter the first column mean, leave a space, and enter the second column mean
• Estimate: This allows us to specify subgroups to include or exclude in the calculations and change the method of estimating sigma
• Limits: This can be used to change where sigma limits are displayed or place on the control limits
• Tests: This allows us to choose the tests for special causes of the data and change the default values. The Using I-MR chart recipe details the options for the Tests tab.
• Stages: This allows the chart to be subdivided and will recalculate center lines and control limits for each stage
• Box Cox: This can be used to transform the data, if necessary
• Display: This has settings to choose how much of the chart to display. We can limit the chart to show only the last section of the data or split a larger dataset into separate segments. There is also an option to display the control limits and center lines for all stages of a chart in this option.
• Storage: This can be used to store parameters of the chart, such as means, standard deviations, plotted values, and test results

## There’s more…

The control limits for the graphs that are produced vary as the subgroup sizes are not constant; this is because the number of earthquakes varies each week. In most practical applications, we may expect to collect the same number of samples or items in a subgroup and hence have flat control limits.

If we wanted to see the number of earthquakes in each week, we could use Tally from inside the Tables menu. This will display a result of counts per week. We could also store this tally back into the worksheet.

The result of this tally could be used with a c-chart to display a count of earthquake events per week.

If we wanted to import the data directly from the Advanced National Seismic System, then the following steps will obtain the data and prepare the worksheet for us:

2. Enter 2013/01/01 in the Start date, time: field.
3. Enter 2013/06/12 in the End date, time: field.
4. Enter 3 in the Min magnitude: field.
5. Enter 31.128 in the Min latitude field and 45.275 in the Max latitude field.
6. Enter 129.799 in the Min longitude field and 145.269 in the Max longitude filed.
7. Copy the data from the search results, excluding the headers, and paste it into a Minitab worksheet.
8. Change the names of the columns to C1 Date, C2 Time, C3 Lat, C4 Long, C5 Depth, C6 Mag. The other columns, C7 to C13, can then be deleted.
9. The Date column will have copied itself into Minitab as text; to convert this back to a date, navigate to Data | Change Data Type | Text to Date/Time.
10. Enter Date in both the Change text columns: and Store date/time columns in: sections.
11. In the Format of text columns: section, enter yyyy/mm/dd.
12. Click on OK.
13. To extract the week from the Date column, navigate to Data | Date/Time | Extract to Text.
14. Enter ‘Date’ in the Extract from date/time column: section.
15. Enter ‘Week‘ in the Store text column in: field.
16. Check the box for Week and click on OK.

## Subscribe to the weekly Packt Hub newsletter

* indicates required