Q Charts for Process Variances
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: SHWQCHT4 */
/* TITLE: Q Charts for Process Variances */
/* PRODUCT: QC */
/* SYSTEM: ALL */
/* KEYS: Shewhart Charts, Short Run Process Control, Q Chart,*/
/* PROCS: SHEWHART */
/* DATA: */
/* */
/* REF: Quesenberry, C. P. (1991). "SPC Q Charts For Start- */
/* Up Processes and Short or Long Runs" Journal of */
/* Quality Technology, Vol. 23, No. 3, pp. 213-224. */
/* */
/* NOTE: See Example 4, pg. 220 of above Reference. */
/* */
/****************************************************************/
options ps=60 ls=80 nodate;
/*************************************************************/
/* */
/* The following data is 20 samples of size 5. The first 12 */
/* samples have a mean of 10 and standard deviation of .01. */
/* The last 8 samples have the same mean, but the standard */
/* deviation has been doubled to .02. */
/* */
/* The first 2 plots assume the parameters are known, while */
/* the last 2 plots assume the parameters are unknown. */
/* Comparing the plots shows how each reacts to an increase */
/* in standard deviation. */
/* */
/*************************************************************/
data sample;
seed = 2934531;
do i = 1 to 20;
subgrp = i;
do j = 1 to 5;
if ( i < 13 ) then do;
x = 10 + .01*rannor(seed);
end;
else do;
x = 10 + .02*rannor(seed);
end;
output;
end;
end;
run;
/****************************************/
/* Case I: */
/* Assume mu and sigma are known. */
/* mu = 10, sigma = .01 */
/****************************************/
/****************************************/
/* This proc call calculates subgroup */
/* means and standard deviations. */
/****************************************/
proc shewhart data=sample;
xchart x*subgrp / nochart
outhistory = hist1
stddeviations;
run;
data qchart1a;
set hist1;
if ( _n_ < 13 ) then do;
group = 'Std of .01';
gcolor = 'yellow';
end;
else do;
group = 'Std of .02';
gcolor = 'red';
end;
q = sqrt(xn)*( xx - 10 ) / .01;
run;
symbol1 v=dot h=.5 c=white;
title 'Q-Chart for Process Mean (Parameters Known)';
proc shewhart data=qchart1a;
irchart q*subgrp (group) /
mu0 = 0
sigma0 = 1
cframe = gray
czones = yellow
cinfill = blue
llimits = 1
xsymbol = 'CL=0'
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
data qchart1b;
set hist1;
if ( _n_ < 13 ) then do;
group = 'Std of .01';
gcolor = 'yellow';
end;
else do;
group = 'Std of .02';
gcolor = 'red';
end;
q = probit( probchi( (xn - 1)*(xs**2) / .0001, xn - 1) );
run;
title 'Q-Chart for Process Variance (Parameters Known)';
proc shewhart data=qchart1b;
irchart q*subgrp (group) /
mu0 = 0
sigma0 = 1
cframe = gray
czones = yellow
cinfill = blue
llimits = 1
xsymbol = 'CL=0'
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
/****************************************/
/* Case II: */
/* Assume mu and sigma are unknown. */
/****************************************/
data qchart2a;
set hist1;
retain lgmean lsum ls2sum;
if ( _n_ < 13 ) then do;
group = 'Std of .01';
gcolor = 'yellow';
end;
else do;
group = 'Std of .02';
gcolor = 'red';
end;
if (_n_ = 1 ) then do;
sum = xx;
gmean = xx;
s2sum = xs**2;
end;
else do;
sum = lsum + xx;
gmean = sum / _n_;
s2sum = ls2sum + ( xn - 1 )*xs**2;
s2pi = s2sum / (( xn - 1)*_n_);
wi = sqrt( ((xn)*(_n_ - 1 )*xn )/(_n_*xn ) )
*(xx - lgmean)/sqrt(s2pi);
q = probit( probt(wi, (_n_-1 )*xn ) );
output;
end;
lgmean = gmean;
lsum = sum;
ls2sum = s2sum;
run;
title 'Q-Chart for Process Mean (Parameters Unknown)';
proc shewhart data=qchart2a;
irchart q*subgrp (group) /
mu0 = 0
sigma0 = 1
cframe = gray
czones = yellow
cinfill = blue
llimits = 1
xsymbol = 'CL=0'
haxis = 0 to 20 by 2
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
data qchart2b;
set hist1;
retain ls2sum;
if ( _n_ < 13 ) then do;
group = 'Std of .01';
gcolor = 'yellow';
end;
else do;
group = 'Std of .02';
gcolor = 'red';
end;
if (_n_ = 1 ) then do;
s2sum = (xn-1)*xs**2;
end;
else do;
s2sum = ls2sum + (xn-1)*xs**2;
wi = ((xn*(_n_-1) - _n_ + 1)*xs**2) / s2sum;
q = probit( probf(wi,xn - 1, xn*(_n_ - 1) - _n_ + 1) );
output;
end;
ls2sum = s2sum;
run;
title 'Q-Chart for Process Variance (Parameters Unknown)';
proc shewhart data=qchart2b;
irchart q*subgrp (group) /
mu0 = 0
sigma0 = 1
cframe = gray
czones = yellow
cinfill = blue
llimits = 1
xsymbol = 'CL=0'
haxis = 0 to 20 by 2
blockpos = 2
cblockvar = gcolor
ndecimal = 0
nolimitslegend
novangle
nochart2;
label q = 'Standardized Value';
label subgrp = 'Observation Number';
run;
goptions reset=all;