Tuesday, July 28, 2009

Control Chart as a Feedback System: A JMP JSL Demostration

This script was written using SAS JMP's version 5.1.
It demostrates how a control chart can feedback any change in distribution's central tendency and/or measure of dispersion/variation.

For any feedback, kindly send it to me @ rsfrancisco at up dot edu dot com

Regards,
Reynald Francisco



The JMP JSL Script





/*
DETAILS,
>>SIGMA OF THE MEAN IS COMPUTED USING THE CENTRAL LIMIT THEOREM
>>CONTROL LIMITS ARE COMPUTED USING Individuals and Moving Range Method (IMR) in which each mean and sigma of the sample are treated as an individual measure/data point.
>>DATA USED IS A RANDOMLY GENRERATED NORMALLY DISTRIBUTED VARIABLE WITH MEAN = MU (user specified) AND STDEV = SIGMA (user specified).
*/

dlg = Dialog(
V List(V List("Population parameter","",
Line Up(2,
"Mean", mu = Edit Number(0),
"Standard Deviation", sigma = Edit Number(1)
),"","",
"Define Sampling Plan","",
Line Up( 2,
"Sampling Size ",n = Edit Number(5),
"Initial Sub-groups ",m = Edit Number(25)
)
),
H List( Button("OK"), Button("Cancel") )
));


If( dlg["Button"] == -1, Throw( "User cancelled" ) );
Remove From( dlg ); Eval List( dlg );






rsqrt2pi = 1/sqrt(2*pi());





/*MODULE3*/


dt = New Table( "Process Data" );



col = dt << New Column( "Parameter" );

/* add new column to object 'dt' , which is a data table. Name the new column as "Parameter". Let new column be referred to as new object 'col' */

/*set global constants 'pmean' and 'pSD'*/

pMean = mu;
pSD = sigma;
sigmasample=sigma/sqrt(n);

/*CREATING A MATRIX to contain Normal Random*/




x = J( m, 1, 0 );

For( i=1, i<m+1, i++,
x[i] = mu + sigmasample * Random Normal()
);
musample=0;
For( i=1, i<m+1, i++,
musample=musample + x[i]
);
musample=musample/m;
/* ADDING THE VALUES from the MATRIX into the CREATED COLUMN in the TABLE*/
col << Values( x );

/* CREATE a new window object called 'w' */

w = New Window( "Control Chart Simulation",
H List Box(
(Graph Box(FrameSize(313,313), XScale(mu-6.5*sigma,mu+6.5*sigma), yScale(0,1.10*rsqrt2pi/(sigma/sqrt(n))), Double Buffer,


Handle(mu,rsqrt2pi/sigma,mu=x;sigma=rsqrt2pi/y),

text({musample,rsqrt2pi/sigmasample},"mu_sample= ",musample," \!rsigmasample= ",sigmasample),

sigmasample=sigma/sqrt(n);

Pencolor("blue"),pensize(1), text size(8),TextColor("blue"),

YFunction(Normal Density((x-mu)/sigma)/sigma, x),

text({mu,rsqrt2pi/(pSD/sqrt(n))},"mu= ",mu," sigma= ",(pSD/sqrt(n))),

Pencolor("red"),pensize(1), text size(10),TextColor("red"),
YFunction(Normal Density((x-musample)/(pSD/sqrt(n)))/(pSD/sqrt(n)), x), /*Y-scale is Normalized to Z-scores*/

Pencolor(4),
text({mu,rsqrt2pi/sigmasample},"mu= ",mu," sigma= ",sigmasample),
YFunction(Normal Density((x-mu)/sigmasample)/sigmasample, x) /*Y-scale is Normalized to Z-scores*/
)),



Control Chart(
Sample Label(Empty()),
KSigma(3),
Chart Col(
:Parameter,
Individual Measurement,
Moving Range
),
Show Zones(1),
All Tests(1),

SendToReport(Dispatch({}, "Control Chart", OutlineBox,
Set Title("Control Chart Simulation")),
Dispatch({"Individual Measurement of Parameter"},
"Control Charts", FrameBox, Frame Size(300, 250)),
Dispatch({"Moving Range of Parameter"}, "1",
ScaleBox, {Scale(Linear), Format(Best), Min(4), Max(38), Inc(3),
Minor Ticks(2)}), Dispatch({"Moving Range of Parameter"},
"Control Chart", FrameBox, Frame Size(300, 250)),
Dispatch({"Moving Range of Parameter"},
"Control Charts", FrameBox, Frame Size(80, 90))),

Alarm Script(
Write(
"\!rOut of Control for test ",
qc_test,
" in column ",
qc_col,
" in sample ",
qc_sample
)
)
),

Button Box( "End Simulation",
w << Close Window;
Close( dt, No Save )
)
)
)
;

While( 2,
Wait(1);
dt << Add Rows( 1 );
col[i++] = mu + sigmasample * Random Normal();
);


No comments:

Post a Comment

 
Custom Search