Mean Square Error of Estimator for Cpk

 /****************************************************************/
 /*       S A S   S A M P L E   L I B R A R Y                    */
 /*                                                              */
 /*    NAME: CPKMSE                                              */
 /*   TITLE: Mean Square Error of Estimator for Cpk              */
 /* PRODUCT: QC                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: Capability Analysis, Capability Indices,            */
 /*   PROCS: G3D                                                 */
 /*    DATA:                                                     */
 /*                                                              */
 /*     REF: W. L. Pearn, S. Kotz, N. L. Johnson (1992).         */
 /*          "Distributional and Inferential Properties of       */
 /*          Process Capability Indices".  Journal of Quality    */
 /*          Technology 24, pp. 216-231.                         */
 /*                                                              */
 /*          Rodriguez, R. N. (1992).  "Recent Developments in   */
 /*          Process Capability Analysis".  Journal of Quality   */
 /*          Technology 24, pp. 176-187.                         */
 /*                                                              */
 /*   NOTES: This program calculates the MSE for the estimator   */
 /*          of Cpk using results of Pearn et al. (1992).  Also  */
 /*          see page 178 of Rodriguez (1992).  The MSE is       */
 /*          computed as a function of the standardized          */
 /*          parameters                                          */
 /*                     d = ( USL - LSL ) / 2 sigma              */
 /*                     | Mu - M | / sigma                       */
 /*          where M=(USL+LSL)/2.                                */
 /*                                                              */
 /*    MISC:                                                     */
 /*                                                              */
 /****************************************************************/

 options ps=60 ls=80;

 data cpk;
   label bi  = 'Bias'
         ms  = '|Mu-M|/Sigma'
         va  = 'Variance'
         mse = 'MSE'
         std = 'Std Error'
         ds  = 'd/Sigma';
   keep n ms ds ex bi va std mse;

   * Assign sample size;
   n = 30;
   f = n-1;

   f1 = (1/3)*sqrt(f/2)*gamma((f-1)/2)*(1/gamma(f/2));
   do ms = 0.0 to 2.0 by 0.05;
      f2 = sqrt(2/n)*(1/gamma(0.5))*exp(-n*0.5*ms*ms);
      f3 = ms*(1-(2*probnorm(-sqrt(n)*ms)));
      do ds = 2 to 6 by 0.05;
         ex  = f1*(ds-f2-f3);
         bi  = ex - ((ds-ms)/3);
         va  = (f/(9*(f-2)))*(ds**2-(2*ds*(f2+f3))+ms**2+(1/n));
         va  = va-ex**2;
         std = sqrt(va);
         mse = va + (bi*bi);
         output;
         end;
      end;
 run;

 title 'MSE of Cpk Estimator for n=30';
 proc g3d data=cpk;
    plot ds*ms = mse /
       xticknum = 5
       yticknum = 5
       zticknum = 5
       zmin     = 0.00
       zmax     = 0.08
       rotate   = 45
       tilt     = 70
       grid
       ;
 run;

 goptions reset=all;