If you choose to estimate the process variation from the data, the program will expect the topmost Scrollsheet to be the output of a variance components analysis. It is recommended that the data be set up in the following manner:
| PART | MASTER | MEASURE |
|---|---|---|
| 1 | 2.5 | 2.49 |
| 1 | 2.5 | 2.53 |
| 2 | 3.5 | 3.50 |
| 2 | 3.5 | 3.52 |
| ... | ... | ... |
Get the Components of Variation Scrollsheet by choosing MEASURE as the dependent variable and PART as a random factor in the Variance Components module of STATISTICA. Click OK to go to the Results dialog. Uncheck all options under the Components of Variance button, and then click on the Components of Variance button. Make sure that this Scrollsheet is the topmost Scrollsheet when you execute this Basic program.
If the process sigma is entered manually, the program will use 6*(process sigma) as the value of comparison.
Program written, modified, or edited at StatSoft, Inc.}
RandomAccess;
If DisplayMessageBox (MB_YESNO, 'Proceed with Analysis?', 'To estimate the process sigma from the data, the topmost
Scrollsheet must be from Variance Components as described in the comments. If this is the case or if you want to enter
the process sigma manually, then press Yes. Otherwise press No.') = IDNO then stop;
VarCompScroll := GetScrollsheet (0);
{Set up needed arrays and initialize variables}
ReDim Measurement(Ncases), Master(Ncases), d(Ncases), Corr(Ncases,2), R(2,2), ExtractDetails(Ncases);
Sxy := 0;
Sxx := 0;
{Select the two variables for analysis and place the data into the appropriate arrays}
if (SelectVariables2 ('Select One Variable from Each List', 1, 1, MeasVar, MeasCount, 'Variable with Measurements', 1, 1,
MasterVar, MasterCount, 'Variable with Master Values')=0) then stop;
for i := 1 to Ncases do
begin
Measurement(i) := Data(i, MeasVar);
Master(i) := Data(i, MasterVar);
d(i) := Measurement(i) - Master(i);
Corr(i,1) := Master(i);
Corr(i,2) := d(i);
end;
{Calculate regression line and R-squared}
ValMean(d, 1, Ncases, Meand);
ValMean(Master, 1, Ncases, MeanMaster);
for i := 1 to Ncases do
begin
tempxy := d(i)*Master(i);
tempxx := Master(i)^2;
Sxy := Sxy + tempxy;
Sxx := Sxx + tempxx;
end;
Sxy := Sxy - Ncases*Meand*MeanMaster;
Sxx := Sxx - Ncases*MeanMaster^2;
slope := Sxy/Sxx;
intercept := Meand - slope*MeanMaster;
MatrixCorrelations(Corr, 1, R);
RSquared := R(1,2)^2;
{Report regression results}
ReDim Result1(3);
Result1(1) := intercept; Result1(2) := slope; Result1(3) := RSquared;
output1 := NewScrollsheet(1, 3, Result1, 'Fitted Line and R-Squared', ?RowNames$, 'Intercept|Slope|R-Squared');
VectorDualSort (Master, d, SORT_ASCENDING);
ValidCases := Ncases;
{Determine the number of different master values and get information about sample size}
for i := 1 to Ncases do
begin
if i = 1 then
begin
ExtractDetails(1) := 1;
DistinctGroups := 1;
end
else if (Valid(Master(i))) and (Master(i) > Master(i-1)) then
begin
DistinctGroups := DistinctGroups + 1;
ExtractDetails(DistinctGroups) := i;
end;
if Valid(Master(i)) = 0 then ValidCases := ValidCases - 1;
end;
{Calculate the mean bias for each master value}
ReDim BiasNMaster(DistinctGroups, 2);
for i := 1 to DistinctGroups do
begin
if i < DistinctGroups then NoToObtain := ExtractDetails(i+1) - ExtractDetails(i)
else NoToObtain := ValidCases - ExtractDetails(i) + 1;
ReDim TempData(NoToObtain);
for j := 1 to NoToObtain do TempData(j) := d(ExtractDetails(i) + j - 1);
ValMean(TempData, 1, NoToObtain, BiasNMaster(i, 1));
BiasNMaster(i, 2) := Master(ExtractDetails(i));
end;
{Report the mean bias for each master value}
output2 := NewScrollsheet(DistinctGroups, 2, BiasNMaster, 'Average Bias by Master Value', ?RowNames$, 'Mean
Bias|Master Value');
{Prepare titles and data for graph1}
Title1$ := 'Gage Linearity Study for ' + VarName(MeasVar);
Title2$ := 'Bias = ' + Str(intercept, 8, 3) + Str(slope, 8, 3) + ' * Master';
Title3$ := 'R-Squared = ' + Str(RSquared, 5, 3);
ReDim BiasMeans(DistinctGroups), DistinctMaster(DistinctGroups);
{Produce graph with bias & bias means plotted against the master values. Also plot the regression line and report its
equation with the value of R-squared}
graph1 := NewGraph (Scatterplot, Title1$, 'Accuracy Average', 'Master Part Measurement', NCases, Master, d);
MatrixGetColumn (BiasNMaster, 1, BiasMeans);
MatrixGetColumn (BiasNMaster, 2, DistinctMaster);
GraphAddPlot (Graph1, Scatterplot, 'Bias Means', DistinctGroups, DistinctMaster, BiasMeans);
GraphSetPlotFitting (Graph1, 1, FIT_LINEAR);
GraphSetTitle (Graph1, Title_Top2, Title2$);
GraphSetTitle (Graph1, Title_Top3, Title3$);
DisplayGraph(Graph1);
{Choose how to estimate process sigma and calculate it}
EstMeth := DisplayListBox ('Choose Method to Estimate Process Sigma', 'Specify Value|Estimate from Data', 1);
if EstMeth=0 then stop
else if EstMeth=2 then
begin
{If this method is chosen, the topmost scrollsheet must be the output from Variance Components
described at the beginning of this program}
ReDim VarComp (2,1);
ScrollsheetGetMatrix (VarCompScroll, 1, 1, VarComp);
ProcSigma := 5.15 * sqrt(VarComp(1,1) + VarComp(2,1));
end
else
begin
if DisplayNumericInputBox ('Enter Process Sigma', 'Process Sigma', ProcSigma)=0 then stop
else ProcSigma := 6 * ProcSigma;
end;
{Calculate gage linearity and accuracy statistics}
Linearity := abs(slope)*ProcSigma;
PercLinearity := 100*abs(slope);
ValMean(d, 1, Ncases, Bias);
PercBias := 100*abs(Bias)/ProcSigma;
{Report gage linearity and accuracy statistics}
ReDim Result3(4);
Result3(1) := Linearity; Result3(2) := PercLinearity; Result3(3) := Bias; Result3(4) := PercBias;
output3 := NewScrollsheet (4, 1, Result3, 'Gage Linearity and Accuracy', 'Linearity|% Linearity|Bias|% Bias', 'Value');
{Produce graph of percent linearity and accuracy}
Redim Ybar(2), Xbar(2);
Ybar(1) := PercLinearity; Ybar(2) := PercBias;
Xbar(1) := 0; Xbar(2) := 1;
graph2 := NewGraph (Barplot, ?Top_Title$, 'Percent', ?Bottom_Title$, 2, Xbar, Ybar);
GraphSetScaleTextLabels (Graph2, AX_X, 2, Xbar, 'Linearity|Accuracy');
GraphSetPlot2DLayout (Graph2, 1, BarPlot, ?DataLabels, ?BarStyle, 0.8, ?DevLevel, ?IsRightAxis);
| Back to List of Programs |
![[StatSoft]](../../../images/sssmall.gif)
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217
e-mail: info@statsoft.com
©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.