Bias of Cpm Estimator

 /****************************************************************/
 /*       S A S   S A M P L E   L I B R A R Y                    */
 /*                                                              */
 /*    NAME: CPMBIAS                                             */
 /*   TITLE: Bias of Cpm Estimator                               */
 /* 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.                         */
 /*                                                              */
 /*   NOTES: This program calculates the bias for the estimator  */
 /*          of Cpm using results of Pearn et al. (1992).  The   */
 /*          bias can be computed as a function of the standar-  */
 /*          dized parameters                                    */
 /*                     d = ( USL - LSL ) / 2 sigma              */
 /*                     | Mu - M | / sigma                       */
 /*          where M=(USL+LSL)/2.                                */
 /*                                                              */
 /*    MISC:                                                     */
 /*                                                              */
 /****************************************************************/

   options ps=60 ls=80;

   data cpm;
     keep ds ms bi;
     label ds = 'd/Sigma'
           bi = 'Bias'
           ms = '|Mu-M|/Sigma';
       n = 30;
       f = n-1;
       do ms = 0.0 to 2.0 by 0.1;
         lamda = n*(ms**2);
         f1 = sqrt((f+1)/2)*exp(-lamda/2);
         f2 = (f+1)*exp(-lamda/2);
         do ds = 2 to 6 by 0.1;
           if(lamda>0.0) then
           do;
             ex = 0.0;
             j = 0;
             do until (exp(aj) <0.0001);
               retain ex;
               aj = (j*log(lamda/2))-lgamma(j+1);
               bj = lgamma((f/2)+j)-lgamma(((f+1)/2)+j);
               cj = exp(aj+bj);
               ex = ex+cj;
               j=j+1;
             end;
             ex = f1*ex*(ds/3);
             bi = ex - (1/(3*sqrt(ds*ds+ms*ms)));
           output;
           end;
           else
           do;
             ex = f1*(gamma(f/2)/gamma((f+1)/2))*(ds/3);
             bi = ex - (1/(3*sqrt(ds*ds+ms*ms)));
             output;
           end;
         end;
       end;
   run;

 title 'Bias of Cpm Estimator for n=30';
 proc g3d data = cpm;
   plot ds*ms = bi /
     xticknum = 5
     yticknum = 5
     zticknum = 5
     zmin     = 0.0
     rotate   = 45
     tilt     = 70
     grid
     ;
 run;

 goptions reset=all;