<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/using-control-charts-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://r-posts.com/using-control-charts-in-r/"> R-posts.com</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I am sure you must have heard of Six Sigma quality standard or Six Sigma experts. But, what is Six Sigma?</p>
<p>Six Sigma is a set of techniques used by organizations to improve their processes and optimize operations. Six Sigma was popularized by manufacturing organizations and Jack Welch, former CEO of GE, was one of advocators of Six Sigma. At the heart of Six Sigma lies the core strategies to improve the quality of processes by identifying and removing the causes leading to defects and variability in product quality and business processes. Six Sigma uses empirical and statistical quality management methods to carry out operational improvement and excellence projects in organizations.</p>
<p>Six Sigma projects follow methodologies which are called as DMAIC and DMADV. DMAIC methodology is used for projects aimed at improving existing business processes; while, DMADV is used for projects which aims at creating new processes. Since this article talks about control charts, we will focus on DMAIC project methodology of which control charts is a part of. DMAIC methodology has five phases:</p>
<ol>
<li>Define</li>
<li>Measure</li>
<li>Analyze</li>
<li>Improve</li>
<li>Control</li>
</ol>
<p><strong>Define</strong></p>
<p>Defining the goals that you wish to achieve - basically, identifying the problem statement you are trying to solve. In this stage, everyone involved in the project understands his/her role and responsibilities. There should be clarity on â€˜Why is the project being undertaken?'</p>
<p><strong>Measure</strong></p>
<p>Understanding the â€˜As-Is' state of the process. Based on the goal defined in the â€˜Define' phase, you understand the process in detail and collect relevant data which is to be used in subsequent phases.</p>
<p><strong>Analyze</strong></p>
<p>By this phase, you know the goal that are you trying to achieve and also, you understand the entire process and have the relevant data to diagnose and analyze the problem. In this phase, make sure that your biases don't lead you to results. Instead, it should be a complete fact-based and data-driven exercise to identify the root cause.</p>
<p><strong>Improve</strong></p>
<p>Now, you are aware about the entire process and cause behind the problems. In this phase, you need to find out ways or methodologies to work on the problem and improve the current processes. You have to think of new ways using techniques such as design of experiments and set up pilot projects to test the idea.</p>
<p><strong>Control</strong></p>
<p>You have implemented new processes and now, you have to ensure that any deviations in the optimized processes are corrected before they result in any defects. One of the techniques that can be used in control phase is statistical process control. Statistical process control can be used to monitor the processes and ensure that the desired quality level is maintained.</p>
<p>Control chart is the primary statistical process control tool used to monitor the performance of processes and ensure that they are operating within the permissible limits. Let's understand what are control charts and how are they used in process improvement.</p>
<p>According to Wikipedia, <em>&quot;The data from measurements of variations at points on the process map is monitored using control charts. Control charts attempt to differentiate “assignable” (“special”) sources of variation from “common” sources. “Common” sources, because they are an expected part of the process, are of much less concern to the manufacturer than “assignable” sources. Using control charts is a continuous activity, ongoing over time.â€�</em></p>
<p>Let's take an example and understand it step by step using above definition. You leave for office from your home every day at 9:00 AM. The average time it takes you to reach office is 35 minutes; while in most of the cases it takes 30 to 40 minutes for you to reach office. There is a variation of 5 minutes less or more because of slight traffic or you get all the traffic signals red on your way. However, on one fine day you leave from your home and you reach office in 60 minutes because there was an accident on the way and the entire traffic was diverted which caused additional delay of around 20 minutes. Now, relating our example with the definition above:</p>
<p><strong>Measurements:</strong> Time to reach office - the time taken on daily basis to reach office from home is measured to monitor the system/process.</p>
<p><strong>Variations:</strong> Deviations from the average time of 35 minutes - these variations are due to inherent attributes in the system such as traffic or traffic signals on the route.</p>
<p><strong>Common sources:</strong> Slight traffic or traffic signals on the route - these are usually part of the processes and are of much less concern while driving to office.</p>
<p><strong>Excessive Variation: </strong>Accident - these are events which leads to variations in the processes, leading to defects in the outputs or delayed processes.</p>
<p>Summing up everything, control charts are graphical techniques to monitor the performance of a process over time. In the control chart, the performance of these processes is monitored visually to identify any anomalies or variations from the usual behavior. For every control chart, there are control limits or decision limits set which define the normal behavior of the process. Any movement outside those limits indicate variation in the process and needs to be corrected to prevent further damage.</p>
<figure class="wp-block-image"><img data-orig-file="https://i0.wp.com/r-posts.com/wp-content/uploads/2018/08/1-2.png?fit=1204%2C830&amp;ssl=1" data-orig-size="1204,830" data-medium-file="https://i0.wp.com/r-posts.com/wp-content/uploads/2018/08/1-2.png?fit=435%2C300&amp;ssl=1" data-attachment-id="607" data-image-meta="{" data-image-description="" src="https://i0.wp.com/r-posts.com/wp-content/uploads/2018/08/1-2.png?w=660" data-permalink="https://r-posts.com/using-control-charts-in-r/1-2-2/" data-large-file="https://i0.wp.com/r-posts.com/wp-content/uploads/2018/08/1-2.png?fit=450%2C310&amp;ssl=1" alt="" data-image-title="1-2" sizes="(max-width: 660px) 100vw, 660px" data-comments-opened="1" class="wp-image-607" data-recalc-dims="1"></figure>
<p>In any control chart, there are three main attributes - Average Line, UCL and LCL. Average line is the mean of all the observations taken in the process. UCL and LCL are upper control limit and lower control limit, respectively. These limits define the control or decision limits within which a process should always fall for efficient and optimized operations. These three values are determined by the process. For a process where all the values lie within the control limits and there is no specific pattern in the values, the process is said to be &quot;in-control.â€�</p>
<p>X-axis can have either time or sample sequence; while, the Y-axis can have individual values or deviations. There are different control charts based on the data you have, continuous or variable (height, weight, density, cost, temperature, age) and attribute (number of defective parts produced). Accordingly, you choose the control chart and control objective.</p>
<p><strong>Following steps present the step-by-step approach to implement a control chart:</strong></p>
<ul>
<li>What process needs to be controlled?</li>
</ul>
<p>Answer to this question will come from the DMAIC process while implementing the entire project methodology.</p>
<ul>
<li>Which system will provide the data to monitor?</li>
</ul>
<p>Identifying the systems that will provide the data based on which control charts will be prepared and monitored.</p>
<ul>
<li>Develop and monitor control charts</li>
</ul>
<p>Develop the control charts by specifying the X-axis and Y-axis.</p>
<ul>
<li>What actions to take based on control charts?</li>
</ul>
<p>Once you have developed control charts, you need to monitor the processes and check for any special or excessive variations which may lead to defects in the processes.</p>
<p>By now, we have understood what control charts are and what information do they provide. Let us understand further uses of control charts and what more information can be extracted from these charts. Apart from manufacturing, control charts find their applications in healthcare industry and a host of other industries.</p>
<ul>
<li> Control charts provide a very simple and easy to understand methodology to understand the performance of processes.</li>
<li> It reduces the need for inspection - the need for inspection arises only when the process behavior is significantly different from the usual behavior.</li>
<li> If changes have been made to the process, control charts can help in understanding the impact of those changes on desired results.</li>
<li> The data collected in the process can be used for improvement in the subsequent of follow-up projects</li>
</ul>
<p><strong>Control Chart Rules</strong></p>
<p>For a process â€˜in-control', most of the points should lie near the average line i.e. Zone A, followed by Zone B and Zone C. Very few points should lie close to control limits and none of the points should fall beyond the control limits. There are eight rules which are helpful in identifying if there are certain patterns or special causes of variation in the observations.</p>
<p>Rule 1: One or more points beyond the control limits</p>
<p>Rule 2: 8 out of 9 points on the same side of the center line (Average line)</p>
<p>Rule 3: 6 consecutive points increasing or decreasing (monotonic)</p>
<p>Rule 4: 14 consecutive points are alternating up and down</p>
<p>Rule 5: 2 out of 3 consecutive points in Zone C or beyond</p>
<p>Rule 6: 4 out of 5 consecutive points in Zone B or beyond</p>
<p>Rule 7: 15 consecutive points are in Zone A</p>
<p>Rule 8: 8 consecutive points on either side of the Average line but not in Zone A</p>
<p>Now, we have understood the control charts, attributes, applications and associated rules, let's try to implement a small example in R.</p>
<p>Let's assume that there is a company which manufactures cylindrical piston rings. For each of the rings manufactured, measurement of the diameter is taken 5 times and captured to examine the within piece variability. These five measurements for one-piece forms one sample or one sub-group. Similarly, measurements for 25 pieces is taken. Using rnorm function in R, let's create the measurement values.</p>
<table class="wp-block-table">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
<table class="wp-block-table">
<tbody>
<tr>
<td>> obs<br>Â Â Â Â Â Â Â Â  V1Â Â Â Â Â Â  V2Â Â Â Â Â Â  V3Â Â Â Â Â Â  V4Â Â Â Â Â Â  V5<br>1Â  1.448786 1.555614 1.400382 1.451316 1.328760<br>2Â  1.748518 1.525284 1.552703 1.417736 1.420078<br>3Â  1.600783 1.409819 1.350917 1.521953 1.358915<br>4Â  1.529281 1.582439 1.544136 1.712162 1.553276<br>5Â  1.479104 1.343972 1.642736 1.589858 1.460230<br>6Â  1.685809 1.553799 1.493372 1.609255 1.471565<br>7Â  1.493397 1.373165 1.660502 1.535789 1.512498<br>8Â  1.483724 1.564052 1.415218 1.436863 1.578013<br>9Â  1.480014 1.446424 1.604218 1.565367 1.412440<br>10 1.530056 1.398036 1.469385 1.667835 1.384063<br>11 1.423609 1.419212 1.420791 1.347140 1.485413<br>12 1.508196 1.505683 1.642166 1.559233 1.332157<br>13 1.574303 1.595021 1.484574 1.375992 1.367742<br>14 1.491598 1.387324 1.486832 1.372965 1.444112<br>15 1.420711 1.479883 1.411519 1.377991 1.251022<br>16 1.407785 1.477150 1.671345 1.562293 1.617919<br>17 1.586156 1.555872 1.515936 1.498874 1.579370<br>18 1.700294 1.574875 1.710501 1.544640 1.660743<br>19 1.593655 1.691820 1.470600 1.479399 1.506595<br>20 1.338427 1.600721 1.434118 1.541265 1.602901<br>21 1.442494 1.825335 1.450115 1.493083 1.433342<br>22 1.499603 1.483825 1.479840 1.466675 1.465325<br>23 1.432389 1.533376 1.456744 1.460206 1.456417<br>24 1.395037 1.382133 1.460687 1.449885 1.305300<br>25 1.445672 1.607760 1.534657 1.422726 1.416209</td>
</tr>
</tbody>
</table>
<table class="wp-block-table">
<tbody>
<tr>
<td>> qq = qcc(obs, type = “R”, nsigmas = 3)Â Â </td>
</tr>
</tbody>
</table>
<figure class="wp-block-image"><img data-orig-file="https://i2.wp.com/r-posts.com/wp-content/uploads/2018/08/RChart.jpeg?fit=540%2C545&amp;ssl=1" data-orig-size="540,545" data-medium-file="https://i2.wp.com/r-posts.com/wp-content/uploads/2018/08/RChart.jpeg?fit=297%2C300&amp;ssl=1" data-attachment-id="605" data-image-meta="{" data-image-description="" src="https://i2.wp.com/r-posts.com/wp-content/uploads/2018/08/RChart.jpeg?w=660" data-permalink="https://r-posts.com/using-control-charts-in-r/rchart/" data-large-file="https://i2.wp.com/r-posts.com/wp-content/uploads/2018/08/RChart.jpeg?fit=450%2C454&amp;ssl=1" alt="" data-image-title="RChart" sizes="(max-width: 540px) 100vw, 540px" data-comments-opened="1" class="wp-image-605" data-recalc-dims="1"></figure>
<p>In R chart, we look for all rules that we have mentioned above. If any of the above rules is violated, then R chart is out of control and we don't need to evaluate further. This indicates the presence of special cause variation. If the R chart appears to be in control, then we check the run rules against the X-Bar chart. In the above chart, R chart appears to be in control; hence, we move to check run rules against the X-Bar chart.</p>
<table class="wp-block-table">
<tbody>
<tr>
<td>> summary(qq)Â <br>Call:<br>qcc(data = obs, type = “R”, nsigmas = 3)Â 
<p>R chart for obs Â </p>
<p>Summary of group statistics:Â Â Â Â  <br>Min.Â Â  1st Qu.Â Â Â  MedianÂ Â Â Â Â  MeanÂ Â  3rd Qu.Â Â Â Â Â  Max. <br>0.0342775 0.1627947 0.2212205 0.2131489 0.2644740 0.3919933 Â </p>
<p>Group sample size:Â  5<br>Number of groups:Â  25<br>Center of group statistics:Â  0.2131489<br>Standard deviation:Â  0.09163753 Â <br>Control limits:Â <br>LCLÂ Â Â Â Â Â  UCLÂ Â  <br>0 0.4506969Â 



<table class="wp-block-table">
<tbody>
<tr>
<td>> qq = qcc(obs, type = “xbar”, nsigmas = 3)Â Â </td>
</tr>
</tbody>
</table>
<figure class="wp-block-image"><img data-orig-file="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/XBar.jpeg?fit=540%2C545&amp;ssl=1" data-orig-size="540,545" data-medium-file="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/XBar.jpeg?fit=297%2C300&amp;ssl=1" data-attachment-id="603" data-image-meta="{" data-image-description="" src="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/XBar.jpeg?w=660" data-permalink="https://r-posts.com/using-control-charts-in-r/xbar/" data-large-file="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/XBar.jpeg?fit=450%2C454&amp;ssl=1" alt="" data-image-title="XBar" sizes="(max-width: 540px) 100vw, 540px" data-comments-opened="1" class="wp-image-603" data-recalc-dims="1"></figure>
<p>In the above chart, one of the points lie outside the UCL which implies that the process is out of control. The standard deviation in the above chart is the standard deviation of means of each of the samples. If we were to look at the sample 18, we see that the values in sample 18 are usually higher than values in other samples.</p>
<table class="wp-block-table">
<tbody>
<tr>
<td>> obs[18,]Â Â Â Â Â Â Â Â  V1Â Â Â Â Â Â  V2Â Â Â Â Â Â  V3Â Â Â Â Â  V4Â Â Â Â Â Â  V5<br>18 1.700294 1.574875 1.710501 1.54464 1.660743Â </td>
</tr>
</tbody>
</table>
<p>Now, let's check process capability. By process capability, we can check if control limits and specification limits are in sync with each other. For instance, in the case we have taken, our client wanted piston rings with target diameter of 1.5 cm with a variation of +/- 0.1 cm. Process capability will help us in identifying whether our system is capable to meeting the specified requirements. It is measured by process capability index C<sub>pk</sub>.</p>
<table class="wp-block-table">
<tbody>
<tr>
<td>> process.capability(qq, spec.limits = c(1.4,1.6))<br>Â <br>Process Capability Analysis<br>Â <br>Call:<br>process.capability(object = qq, spec.limits = c(1.4, 1.6))<br>Â <br>Number of obs = 125Â Â Â Â Â Â Â Â Â  Target = 1.5<br>Â Â Â Â Â Â  Center = 1.498Â Â Â Â Â Â Â Â Â Â  LSL = 1.4<br>Â Â Â Â Â Â  StdDev = 0.09164Â Â Â Â Â Â Â Â  USL = 1.6<br>Â <br>Capability indices:<br>Â <br>Â Â Â Â Â Â  ValueÂ Â Â  2.5%Â Â  97.5%<br>CpÂ Â Â  0.3638Â  0.3185Â  0.4089<br>Cp_lÂ  0.3562Â  0.2947Â  0.4178<br>Cp_uÂ  0.3713Â  0.3088Â  0.4338<br>Cp_kÂ  0.3562Â  0.2829Â  0.4296<br>CpmÂ Â  0.3637Â  0.3186Â  0.4087<br>Â <br>ExpExp>USL 13%Â Â Â Â Â Â Â Â Â  Obs>USL 16%</td>
</tr>
</tbody>
</table>
<figure class="wp-block-image"><img data-orig-file="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/ProcessCapability.jpeg?fit=540%2C545&amp;ssl=1" data-orig-size="540,545" data-medium-file="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/ProcessCapability.jpeg?fit=297%2C300&amp;ssl=1" data-attachment-id="604" data-image-meta="{" data-image-description="" src="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/ProcessCapability.jpeg?w=660" data-permalink="https://r-posts.com/using-control-charts-in-r/processcapability/" data-large-file="https://i1.wp.com/r-posts.com/wp-content/uploads/2018/08/ProcessCapability.jpeg?fit=450%2C454&amp;ssl=1" alt="" data-image-title="ProcessCapability" sizes="(max-width: 540px) 100vw, 540px" data-comments-opened="1" class="wp-image-604" data-recalc-dims="1"></figure>
<p>In the above plot, red lines indicate the target value, the lower and upper specified range. It can easily be inferred that the system is not capable to manufacture products within the specified range. Also, for a capable process, value of C<sub>pk </sub>should be greater than or equal to 1.33. In the above chart, the value is 0.356 which is less than the required value. This shows that the above process is neither stable nor capable.</p>
<p>I am sure after going through this article, you will be able to use and create control charts in multiple other cases in your work. We would love to hear your experience with creating control charts in different settings.</p>
<div class="wp-block-button"><a rel="nofollow" href="http://r-posts.com/wp-content/uploads/2018/08/Control-Charts.zip" class="wp-block-button__link" target="_blank">R Code</a></div>
<h2>Author Bio:</h2>
<p>This article was contributed by Perceptive Analytics. Jyothirmayee Thondamallu, Chaitanya Sagar and Saneesh Veetil contributed to this article.</p>
<p>Perceptive Analytics is a <a rel="nofollow" href="https://www.perceptive-analytics.com/marketing-analytics-companies/" target="_blank">marketing analytics company</a> and it also provides Tableau Consulting, data analytics, business intelligence and reporting services to e-commerce, retail, healthcare and pharmaceutical industries. Our client roster includes Fortune 500 and NYSE listed companies in the USA and India.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://r-posts.com/using-control-charts-in-r/"> R-posts.com</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/zwHTqGu-RYQ" height="1"></a></div></td></tr></tbody></table>