Non-Parametric Capability Analysis Code

How to save this page as a macro

macro
#
#    Macro: ECAPA.MAC
#   Author: Cathy Akritas
# 
#  This macro calculates capability indices (Cnpk) using the empirical 
#  percentile method as described in the reference  
#
#    D. W. McCormack Jr.,  Ian R. Harris,  Arnon M. Hurwitz, and Patrick 
#    D. Spagon (2000). "Capability Indices for Non-Normal Data," Quality 
#    Engineering, 12 (4), 489-495.  
#
#  You must have at least 100 observations to run this analysis.
#
#  Typically you would only use this method when your data does not follow 
#  the normal distribution or any of the other distributions that can be 
#  used in a capability analysis in Minitab.  The author of this macro 
#  strongly suggests that you use Stat > Quality Tools > Individual 
#  Distribution Identification to determine if your data follows any of 
#  the distributions listed.  These distributions are normal, lognormal, 
#  3-parameter lognormal, exponential, 2-parameter exponential, Weibull,
#  3-parameter Weibull, largest extreme value, smallest extreme value, 
#  gamma, 3-parameter gamma, logistic, loglogistic, and 3-parameter 
#  loglogistic.
#
#  Suppose your data is in C2 and you have a lower spec limit (LSL) of 12 
#  and an upper spec limit (USL) of 16.  Go to Edit > Command Line Editor 
#  and type the following commands
#
#  %ecapa C2;
#    LSL 12;
#    USL 16.  
#
#  Click on the Submit Commands button.  
#
#  If you have just a lower spec limit, then use the following commands
#
#  %ecapa C2;
#    LSL 12.
#
#  If you have just an upper spec limit, then use the following commands
#
#  %ecapa C2;
#    USL 16. 
#
###########################################################################
#
#  Neither Minitab, Inc. nor the author(s) of this MACRO makes any claim 
#  of or offers any Warranty whatsoever with regard to the accuracy of 
#  this MACRO or its suitability for use.  Minitab, Inc. and the author(s) 
#  of this MACRO each hereby disclaims any Warranty and/or liability with 
#  respect thereto. 
#
###########################################################################

ecapa x;
  usl u;
  lsl l;
  target t.

mcolumn x y tmp lab1 lab2 lab3 lab4 lab5 xtab1 xtab2 xtab3 xtab4 xtab5 xtab6 ytab1 
mcolumn ytab2 ytab3 ytab4
mconstant xtype cnt u l t lo hi m Cnp Cnpl Cnpu Cnpk ppmup ppmlo ppmtotal
mconstant xbar s t1 t2 t3 xname

mreset
brief 0
noecho
notitle


#Check data type and length
let cnt = n(x) 
if cnt < 100
  brief 1
  note
  note
  note   ***You must have more than 100 data points for this 
  note      capability analysis to produce valid results
  note
  note   ***Macro is exiting
  exit 
endif

dtype x xtype

if xtype = 0 or xtype = 10
 brief 1
  note
  note
  note   ***Error*** Data must be numeric or date/time
  note
  note   ***Macro is exiting***
  exit 
endif

set tmp
  .005 .5 .995
end

let y = percentile(x, tmp)

unstack y lo m hi

let xbar = mean(x)
let s = stdev(x)
if s = 0
  brief 1
  note
  note   ***Error*** No variation in the data
  note
  note   ***Macro exiting***
  note 
  exit
endif
  
tset lab1
  "LSL           "
  "USL           "
  "Sample Median " 
  "Sample Mean   "
  "Sample StDev  "
  "Sample N      "
end

tset lab3
  "PPM < LSL "
  "PPM > USL "
  "PPM Total "
end

tset lab5
  "Cnp "
  "Cnpl "
  "Cnpu "
  "Cnpk "
end

kkset t1 "Empirical Process Capability of "
kkname xname x
kkcat t1 xname t2

If usl = 1 and lsl = 1
  if lsl > usl
    brief 1
    note
    note   ***Error*** Lower spec must be less than Upper Spec 
    note
    note   ***Macro exiting***
    note 
    exit
  endif
#u = usl
#l = lsl
#hi = 99.5th percentile
#lo =.5th percentile
  let Cnp = (u-l)/(hi - lo)
  let Cnpl = (m - l)/(m - lo)
  let Cnpu = (u - m)/(hi - m)
  stack Cnpl Cnpu tmp
  let Cnpk = mini(tmp)
  let tmp = (x < l)
  let ppmlo = sum(tmp)/cnt*1000000
  let tmp = (x > u)
  let ppmup = sum(tmp)/cnt*1000000
  let ppmtotal = ppmlo + ppmup

 elseif usl = 1 and lsl = 0
  let Cnp = '*'
  let l = '*'
  let Cnpl = '*'
  let Cnpu = (u - m)/(hi - m)
  let Cnpk = Cnpu
  let ppmlo = '*'
  let tmp = (x > u)
  let ppmup = sum(tmp)/cnt*1000000
  let ppmtotal = ppmup

elseif usl = 0 and lsl = 1
  let Cnp = '*'
  let u = '*'
  let Cnpl = (m - l)/(m - lo)
  let Cnpu = '*'
  let Cnpk = Cnpl
  let ppmup = '*'
  let tmp = (x < l)
  let ppmlo = sum(tmp)/cnt*1000000
  let ppmtotal = ppmlo

else
  brief 1  
  note
  note
  note   ***Error*** No specification limits entered 
  note              
  note
  note   ***Macro exiting***
  note
  exit
endif

erase tmp 
let tmp[1] = cnt

text tmp tmp;
  decimal 0.
stack l u m xbar s lab2

text lab2 lab2
stack lab2 tmp lab2

set xtab1
  6(.025)
end

let xtab2 = xtab1 + .135

set ytab1
  .7825:.6450/-.0275
end

set ytab3
  .28:.2250/-.0275
end

stack ppmlo ppmup ppmtotal lab4
text lab4 lab4;
  maxwidth 80.

set xtab3
  3(.025)
end

let xtab4 = xtab3 + .12

set xtab5
  4(.03)
end
let xtab6 = xtab5 + .11
set ytab4
  .53:.4475/-.0275
end

stack Cnp Cnpl Cnpu Cnpk tmp
text tmp tmp;
  maxwidith 30.


if usl = 1 and lsl = 1
  hist x;
    Data 0.25 0.9533 0.1373 0.8375;
    title t2;
      offset 0 -.035;
    wtitle t2;
    subtile "Using the Empirical Percentile Method";
      offset 0 -.085;
    Scale 2;
      LDisplay 1 0 0 0;
    AxLabel 1;
      ADisplay 0;
    AxLabel 2;
      ADisplay 0;
    reference 1 u;
      label "USL";
        offset 0 -.00725;
        Tcolor 2;
      Type 2;
      Color 2;
      Size 1; 
    reference 1 l;
      label "LSL";
        offset 0 -.00725;
        Tcolor 2;
      Type 2;
      Color 2;
      Size 1;
    Bar;
    NoDTitle;
    text .05 .815 "Process Data";
      unit 0;
      psize 8.5;
      bold; 
    text xtab1 ytab1 lab1;
      psize 7.5;
      unit 0;
    text xtab2 ytab1 lab2;
      unit 0;
      psize 7.5;
    text .035 .56 "Capability Indices";
      unit 0;
      psize 8.5;
      Bold;
    text  xtab5 ytab4 lab5;
      unit 0;
      psize 7.5;
    text  xtab6 ytab4 tmp;
      unit 0;
      psize 7.5;
    text .0125 .315 "Observed Performance";
      unit 0;
      psize 8.5;
      bold;
    text xtab3 ytab3 lab3;
      unit 0;
      psize 7.5;
    text xtab4 ytab3 lab4;
      unit 0;
      psize 7.5.
  
elseif usl = 0 and lsl = 1

  let lab2[2] = "*"
  let tmp[1] = "*"
  let tmp[3] = "*"
  let lab4[2] = "*"
  hist x;
    Data 0.25 0.9533 0.1373 0.8375;
    title t2;
      offset 0 -.035;
    wtitle t2;
    subtile "Using the Empirical Percentile Method";
      offset 0 -.085;
    Scale 2;
      LDisplay 1 0 0 0;
    AxLabel 1;
      ADisplay 0;
    AxLabel 2;
      ADisplay 0;
    reference 1 l;
      label "LSL";
        offset 0 -.00725;
        Tcolor 2;
      Type 2;
      Color 2;
      Size 1;
    Bar;
    NoDTitle;
    text .05 .815 "Process Data";
      unit 0;
      psize 8.5;
      bold;
    text xtab1 ytab1 lab1;
      psize 7.5;
      unit 0;
    text xtab2 ytab1 lab2;
      unit 0;
      psize 7.5;
    text .035 .56 "Capability Indices";
      unit 0;
      psize 8.5;
      Bold;
    text  xtab5 ytab4 lab5;
      unit 0;
      psize 7.5;
    text  xtab6 ytab4 tmp;
      unit 0;
      psize 7.5;
    text .0125 .315 "Observed Performance";
      unit 0;
      psize 8.5;
      bold;
    text xtab3 ytab3 lab3;
      unit 0;
      psize 7.5;
    text xtab4 ytab3 lab4;
      unit 0;
      psize 7.5.

elseif usl = 1 and lsl = 0

  let lab2[1] = "*"
  let tmp[1] = "*"
  let tmp[2] = "*"
  let lab4[1] = "*"
  hist x;
    Data 0.25 0.9533 0.1373 0.8375;
    title t2;
      offset 0 -.035;
    wtitle t2;
    subtile "Using the Empirical Percentile Method";
      offset 0 -.085;
    Scale 2;
      LDisplay 1 0 0 0;
    AxLabel 1;
      ADisplay 0;
    AxLabel 2;
      ADisplay 0;
    reference 1 u;
      label "USL";
        offset 0 -.00725;
        Tcolor 2;
      Type 2;
      Color 2;
      Size 1; 
    Bar;
    NoDTitle;
    text .05 .815 "Process Data";
      unit 0;
      psize 8.5;
      bold; 
    text xtab1 ytab1 lab1;
      psize 7.5;
      unit 0;
    text xtab2 ytab1 lab2;
      unit 0;
      psize 7.5;
    text .035 .56 "Capability Indices";
      unit 0;
      psize 8.5;
      bold;
    text  xtab5 ytab4 lab5;
      unit 0;
      psize 7.5;
    text  xtab6 ytab4 tmp;
      unit 0;
      psize 7.5;
    text .0125 .315 "Observed Performance";
      unit 0;
      psize 8.5;
      bold;
    text xtab3 ytab3 lab3;
      unit 0;
      psize 7.5;
    text xtab4 ytab3 lab4;
      unit 0;
      psize 7.5.
  
endif
endmacro

Disclaimer:

Minitab Inc. provides the Macro Library as a convenience only. Minitab neither endorses, supports, nor verifies the accuracy of any content, information, or functionality of any macro found in the Macro Library. Minitab specifically disclaims any and all responsibility or liability arising from or related to any reliance upon, use, or incorporation of any content, information, or macro found in the Macro Library.

Need Assistance?

+1-814-231-2682