LazStats: More refactoring of blkanovaunit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7488 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-06-23 17:41:18 +00:00
parent f8a14ebfe1
commit 6a36491ee5

View File

@ -97,7 +97,7 @@ type
FF1, FF2, FF1F2, ProbF1, ProbF2, ProbF3, ProbF1F2, ProbF1F3 : double;
FF3, FF2F3, FF1F3, FF1F2F3, ProbF2F3, ProbF1F2F3 : double;
DepVarCol, F1Col, F2Col, F3Col, Nf1cells, Nf2cells, Nf3cells : integer;
MeanDep, MeanF1, MeanF2, MeanF3, X : double;
MeanDep, MeanF1, MeanF2, MeanF3: double;
minf1, maxf1, minf2, maxf2, minf3, maxf3, nofactors, totcells : integer;
cellcnts : DblDyneVec; // array of cell counts
cellvars : DblDyneVec; // arrray of cell sums of squares then variances
@ -153,7 +153,7 @@ var
implementation
uses
Math;
Math, Utils;
{ TBlksAnovaFrm }
@ -244,20 +244,9 @@ var
msg: String;
C: TWinControl;
lReport: TStrings;
procedure CleanIt;
begin
cellcnts := nil;
cellvars := nil;
cellsums := nil;
ColNoSelected := nil;
end;
begin
lReport := TStringList.Create;
try
// initialize values
SetLength(ColNoSelected,NoVariables);
SetLength(ColNoSelected, NoVariables);
DepVarCol := 0;
F1Col := 0;
F2Col := 0;
@ -286,6 +275,8 @@ begin
minf3 := 0;
maxf3 := 0;
lReport := TStringList.Create;
try
// Get column numbers of dependent variable and factors
for i := 1 to NoVariables do
begin
@ -318,12 +309,13 @@ begin
if not Validate(msg, C, DepVarCol, F1Col, F2Col, F3Col) then begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ErrorMsg(msg);
exit;
end;
if F2Col = 0 then nofactors := 1 else nofactors := 2;
if F3Col <> 0 then nofactors := 3;
allAlpha := StrToFloat(OverAllalpha.Text);
PostHocAlpha := StrToFloat(PostAlpha.Text);
@ -365,11 +357,12 @@ begin
Bonferroni(cellsums, cellcnts, cellvars, minf1, maxf1, posthocAlpha, lReport);
if OrthoContrasts.Checked then
Contrasts(MSErr, DFErr, cellsums, cellcnts, minf1, maxf1, 0.05, lReport);
//OutputFrm.ShowModal;
if (PlotMeans.Checked) or (Plot2DLines.Checked) or (Plot3DLines.Checked) then
if BrownForsythe.Checked then
BrownForsytheOneWay(lReport);
if Welch.Checked then
WelchOneWay(lReport);
if PlotMeans.Checked or Plot2DLines.Checked or Plot3DLines.Checked then
OneWayPlot;
if BrownForsythe.Checked then BrownForsytheOneWay(lReport);
if Welch.Checked then WelchOneWay(lReport);
end;
2 : // two-way anova
@ -389,10 +382,10 @@ begin
begin
TwoWayTable(lReport);
TwoWayContrasts(lReport);
//OutputFrm.ShowModal;
if PlotMeans.Checked or Plot2DLines.Checked or Plot3DLines.Checked then
TwoWayPlot;
end;
OrdMeansB := nil;
OrdMeansA := nil;
ColCount := nil;
@ -406,28 +399,29 @@ begin
3 : // three way anova
begin
SetLength(RowSums,Nf1cells); // 2 way row sums
SetLength(ColSums,Nf2cells); // 2 way col sums
SetLength(RowCount,Nf1cells); // 2 way row count
SetLength(ColCount,Nf2cells); // 2 way col count
SetLength(SlcSums,Nf3cells); // 3 way slice sums
SetLength(SlcCount,Nf3cells); // 3 way slice counts
SetLength(OrdMeansA,Nf1cells); // ordered means for factor 1
SetLength(OrdMeansB,Nf2cells); // ordered means for factor 2
SetLength(OrdMeansC,Nf3cells); // ordered means for factor 3
SetLength(wsum,Nf1cells,Nf2cells,Nf3cells);
SetLength(wx2,Nf1cells,Nf2cells,Nf3cells);
SetLength(ncnt,Nf1cells,Nf2cells,Nf3cells);
SetLength(RowSums, Nf1cells); // 2 way row sums
SetLength(ColSums, Nf2cells); // 2 way col sums
SetLength(RowCount, Nf1cells); // 2 way row count
SetLength(ColCount, Nf2cells); // 2 way col count
SetLength(SlcSums, Nf3cells); // 3 way slice sums
SetLength(SlcCount, Nf3cells); // 3 way slice counts
SetLength(OrdMeansA, Nf1cells); // ordered means for factor 1
SetLength(OrdMeansB, Nf2cells); // ordered means for factor 2
SetLength(OrdMeansC, Nf3cells); // ordered means for factor 3
SetLength(wsum, Nf1cells, Nf2cells, Nf3cells);
SetLength(wx2, Nf1cells, Nf2cells, Nf3cells);
SetLength(ncnt, Nf1cells, Nf2cells, Nf3cells);
Calc3Way;
if not CompError then
begin
ThreeWayTable(lReport);
ThreeWayContrasts(lReport);
//OutputFrm.ShowModal;
if (PlotMeans.Checked) or (Plot2DLines.Checked) or (Plot3DLines.Checked) then
ThreeWayPlot;
end;
ncnt := nil;
wx2 := nil;
wsum := nil;
@ -447,7 +441,10 @@ begin
finally
lReport.Free;
CleanIt;
cellcnts := nil;
cellvars := nil;
cellsums := nil;
ColNoSelected := nil;
end;
end;
@ -539,6 +536,10 @@ procedure TBlksAnovaFrm.GetLevels;
var
i: integer;
begin
Nf1cells := 0;
Nf2Cells := 0;
Nf3Cells := 0;
minf1 := MaxInt;
maxf1 := -MaxInt;
for i := 1 to NoCases do
@ -586,6 +587,7 @@ end;
procedure TBlksAnovaFrm.Calc1Way;
var
i: integer;
X, X2: Double;
begin
CompError := false;
@ -595,12 +597,13 @@ begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
X := X*X;
intvalue := intvalue - minf1 + 1;
cellcnts[intvalue-1] := cellcnts[intvalue-1] + 1;
cellsums[intvalue-1] := cellsums[intvalue-1] + X;
cellvars[intvalue-1] := cellvars[intvalue-1] + (X * X);
cellvars[intvalue-1] := cellvars[intvalue-1] + X2;
MeanDep := MeanDep + X;
SSDep := SSDep + (X * X);
SSDep := SSDep + X2;
N := N + 1;
end;
@ -756,7 +759,7 @@ var
i, j : integer;
grpA, grpB : integer;
Constant, RowsTotCnt, ColsTotCnt, SSCells : double;
X, X2: Double;
begin
CompError := false;
@ -792,17 +795,18 @@ begin
grpA := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i])));
grpB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F2Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
X := X*X;
grpA := grpA - minf1 + 1;
grpB := grpB - minf2 + 1;
counts[grpA-1,grpB-1] := counts[grpA-1,grpB-1] + 1;
sums[grpA-1,grpB-1] := sums[grpA-1,grpB-1] + X;
vars[grpA-1,grpB-1] := vars[grpA-1,grpB-1] + (X * X);
vars[grpA-1,grpB-1] := vars[grpA-1,grpB-1] + X2;
RowSums[GrpA-1] := RowSums[GrpA-1] + X;
ColSums[GrpB-1] := ColSums[GrpB-1] + X;
RowCount[GrpA-1] := RowCount[GrpA-1] + 1.0;
ColCount[GrpB-1] := ColCount[GrpB-1] + 1.0;
MeanDep := MeanDep + X;
SSDep := SSDep + (X * X);
SSDep := SSDep + X2;
N := N + 1;
end;
@ -1161,7 +1165,7 @@ var
grpA, grpB, grpC : integer;
Constant, RowsTotCnt, ColsTotCnt, SlcsTotCnt, SSCells : double;
p, n2 : double;
X, X2: Double;
begin
CompError := false;
@ -1169,6 +1173,7 @@ begin
NoGrpsA := maxf1 - minf1 + 1;
NoGrpsB := maxf2 - minf2 + 1;
NoGrpsC := maxf3 - minf3 + 1;
for i := 0 to NoGrpsA-1 do
begin
RowSums[i] := 0.0;
@ -1183,16 +1188,19 @@ begin
end;
end;
end;
for i := 0 to NoGrpsB-1 do
begin
ColCount[i] := 0.0;
ColSums[i] := 0.0;
end;
for i := 0 to NoGrpsC-1 do
begin
SlcCount[i] := 0.0;
SlcSums[i] := 0.0;
end;
N := 0;
MeanDep := 0.0;
SSDep := 0.0;
@ -1216,12 +1224,13 @@ begin
grpB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F2Col,i])));
grpC := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F3Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
X2 := X*X;
grpA := grpA - minf1 + 1;
grpB := grpB - minf2 + 1;
grpC := grpC - minf3 + 1;
ncnt[grpA-1,grpB-1,grpC-1] := ncnt[grpA-1,grpB-1,grpC-1] + 1;
wsum[grpA-1,grpB-1,grpC-1] := wsum[grpA-1,grpB-1,grpc-1] + X;
wx2[grpA-1,grpB-1,grpC-1] := wx2[grpA-1,grpB-1,grpC-1] + (X * X);
wx2[grpA-1,grpB-1,grpC-1] := wx2[grpA-1,grpB-1,grpC-1] + X2;
RowSums[GrpA-1] := RowSums[GrpA-1] + X;
ColSums[GrpB-1] := ColSums[GrpB-1] + X;
SlcSums[GrpC-1] := SlcSums[GrpC-1] + X;
@ -1229,12 +1238,14 @@ begin
ColCount[GrpB-1] := ColCount[GrpB-1] + 1.0;
SlcCount[GrpC-1] := SlcCount[GrpC-1] + 1.0;
MeanDep := MeanDep + X;
SSDep := SSDep + (X * X);
SSDep := SSDep + X2;
N := N + 1;
end;
// Calculate results
Constant := (MeanDep * MeanDep) / N;
// get ss for rows
for i := 0 to NoGrpsA-1 do
begin
@ -1325,10 +1336,11 @@ begin
if (SSF1 < 0.0) or (SSF2 < 0.0) or (SSF3 < 0.0) or (SSF1F2 < 0.0) or
(SSF1F3 < 0.0) or (SSF2F3 < 0.0) or (SSF1F2F3 < 0.0) then
begin
ShowMessage('ERROR! A negative SS found. Unbalanced Design? Ending analysis.');
ErrorMsg('ERROR! A negative SS found. Unbalanced Design? Ending analysis.');
CompError := true;
exit;
end;
DFTot := N - 1;
DFF1 := NoGrpsA - 1;
DFF2 := NoGrpsB - 1;
@ -1338,7 +1350,6 @@ begin
DFF2F3 := DFF2 * DFF3;
DFF1F2F3 := DFF1 * DFF2 * DFF3;
DFErr := DFTot - DFF1 - DFF2 - DFF3 - DFF1F2 - DFF1F3 - DFF2F3 - DFF1F2F3;
// DFCells := N - (NoGrpsA * NoGrpsB * NoGrpsC);
MSF1 := SSF1 / DFF1;
MSF2 := SSF2 / DFF2;
MSF3 := SSF3 / DFF3;
@ -1355,13 +1366,11 @@ begin
OmegaF1F3 := (SSF1F3 - DFF1F3 * MSErr) / (SSDep + MSErr);
OmegaF2F3 := (SSF2F3 - DFF2F3 * MSErr) / (SSDep + MSErr);
OmegaF1F2F3 := (SSF1F2F3 - DFF1F2F3 * MSErr) / (SSDep + MSErr);
Omega := OmegaF1 + OmegaF2 + OmegaF3 + OmegaF1F2 + OmegaF1F3 +
OmegaF2F3 + OmegaF1F2F3;
Omega := OmegaF1 + OmegaF2 + OmegaF3 + OmegaF1F2 + OmegaF1F3 + OmegaF2F3 + OmegaF1F2F3;
MeanDep := MeanDep / N;
// f tests for fixed effects
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and
(Fact3Grp.ItemIndex = 0) then
// F tests for fixed effects
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 0) then
begin
FF1 := abs(MSF1 / MSErr);
FF2 := abs(MSF2 / MSErr);
@ -1379,17 +1388,20 @@ begin
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f tests if all factors are random
// F tests if all factors are random
for i := 1 to 14 do OKterms[i] := 1; // initialize as OK
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and
(Fact3Grp.ItemIndex = 1) then
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 1) then
begin
if (MSF1F2 + MSF1F3 - MSF1F2F3) < 0.0 then OKTerms[1] := 0 else
FF1 := abs(MSF1 / (MSF1F2 + MSF1F3 - MSF1F2F3));
if (MSF1F2 + MSF2F3 - MSF1F2F3) < 0.0 then OKTerms[2] := 0 else
FF2 := abs(MSF2 / (MSF1F2 + MSF2F3 - MSF1F2F3));
if (MSF1F3 + MSF2F3 - MSF1F2F3) < 0.0 then OKTerms[3] := 0 else
FF3 := abs(MSF3 / (MSF1F3 + MSF2F3 - MSF1F2F3));
if (MSF1F2 + MSF1F3 - MSF1F2F3) < 0.0
then OKTerms[1] := 0
else FF1 := abs(MSF1 / (MSF1F2 + MSF1F3 - MSF1F2F3));
if (MSF1F2 + MSF2F3 - MSF1F2F3) < 0.0
then OKTerms[2] := 0
else FF2 := abs(MSF2 / (MSF1F2 + MSF2F3 - MSF1F2F3));
if (MSF1F3 + MSF2F3 - MSF1F2F3) < 0.0
then OKTerms[3] := 0
else FF3 := abs(MSF3 / (MSF1F3 + MSF2F3 - MSF1F2F3));
FF1F2 := abs(MSF1F2 / MSF1F2F3);
FF1F3 := abs(MSF1F3 / MSF1F2F3);
FF2F3 := abs(MSF2F3 / MSF1F2F3);
@ -1403,9 +1415,8 @@ begin
probF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f test if factor A is random, B and C Fixed
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and
(Fact3Grp.ItemIndex = 0) then
// F test if factor A is random, B and C Fixed
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 0) then
begin
FF1 := abs(MSF1 / MSErr);
FF2 := abs(MSF2 / MSF1F2);
@ -1423,9 +1434,8 @@ begin
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f test if factor b is random and A and C are Fixed
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and
(Fact3Grp.ItemIndex = 0) then
// F test if factor b is random and A and C are Fixed
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 0) then
begin
FF1 := abs(MSF1 / MSF1F2);
FF2 := abs(MSF2 / MSErr);
@ -1443,9 +1453,8 @@ begin
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f test if factor c is random and A and B are Fixed
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and
(Fact3Grp.ItemIndex = 1) then
// F test if factor c is random and A and B are Fixed
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 1) then
begin
FF1 := abs(MSF1 / MSF1F3);
FF2 := abs(MSF2 / MSF2F3);
@ -1463,20 +1472,21 @@ begin
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f tests if A is fixed, B and C are random
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and
(Fact3Grp.ItemIndex = 1) then
// F tests if A is fixed, B and C are random
if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 1) then
begin
if (MSF1F3 + MSF1F2 - MSF1F2F3) < 0.0 then OKTerms[1] := 0 else
FF1 := abs(MSF1 / (MSF1F3 + MSF1F2 - MSF1F2F3));
if (MSF1F3 + MSF1F2 - MSF1F2F3) < 0.0
then OKTerms[1] := 0
else FF1 := abs(MSF1 / (MSF1F3 + MSF1F2 - MSF1F2F3));
FF2 := abs(MSF2 / MSF2F3);
FF3 := abs(MSF3 / MSF2F3);
FF1F2 := abs(MSF1F2 / MSF1F2F3);
FF1F3 := abs(MSF1F3 / MSF1F2F3);
FF2F3 := abs(MSF2F3 / MSErr);
FF1F2F3 := abs(MSF1F2F3 / MSErr);
if (DFF1F3 + DFF1F2 - DFF1F2F3) <= 0 then OKTerms[8] := 0 else
ProbF1 := probf(FF1,DFF1,(DFF1F3 + DFF1F2 - DFF1F2F3));
if (DFF1F3 + DFF1F2 - DFF1F2F3) <= 0
then OKTerms[8] := 0
else ProbF1 := probf(FF1,DFF1,(DFF1F3 + DFF1F2 - DFF1F2F3));
ProbF2 := probf(FF2,DFF2,DFF2F3);
ProbF3 := probf(FF3,DFF3,DFF2F3);
ProbF1F2 := probf(FF1F2,DFF1F2,DFF1F2F3);
@ -1484,21 +1494,23 @@ begin
ProbF2F3 := probf(FF2F3,DFF2F3,DFErr);
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f tests if B is fixed, A and C are random
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and
(Fact3Grp.ItemIndex = 1) then
// F tests if B is fixed, A and C are random
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 1) then
begin
FF1 := abs(MSF2 / MSF1F3);
if (MSF2F3 + MSF1F2 - MSF1F2F3) <= 0.0 then OKTerms[2] := 0 else
FF2 := abs(MSF1 / (MSF2F3 + MSF1F2 - MSF1F2F3));
if (MSF2F3 + MSF1F2 - MSF1F2F3) <= 0.0
then OKTerms[2] := 0
else FF2 := abs(MSF1 / (MSF2F3 + MSF1F2 - MSF1F2F3));
FF3 := abs(MSF3 / MSF1F3);
FF1F2 := abs(MSF1F2 / MSF1F2F3);
FF1F3 := abs(MSF1F3 / MSErr);
FF2F3 := abs(MSF2F3 / MSF1F2F3);
FF1F2F3 := abs(MSF1F2F3 / MSErr);
ProbF1 := probf(FF2,DFF2,DFF1F3);
if (DFF2F3 + DFF1F2 - DFF1F2F3) <= 0 then OKTerms[9] := 0 else
ProbF2 := probf(FF1,DFF1,(DFF2F3 + DFF1F2 - DFF1F2F3));
if (DFF2F3 + DFF1F2 - DFF1F2F3) <= 0
then OKTerms[9] := 0
else ProbF2 := probf(FF1,DFF1,(DFF2F3 + DFF1F2 - DFF1F2F3));
ProbF3 := probf(FF3,DFF3,DFF1F3);
ProbF1F2 := probf(FF1F2,DFF1F2,DFF1F2F3);
ProbF1F3 := probf(FF1F3,DFF1F3,DFErr);
@ -1506,27 +1518,29 @@ begin
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
// f tests if C is fixed A and B are random
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and
(Fact3Grp.ItemIndex = 0) then
// F tests if C is fixed A and B are random
if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 0) then
begin
FF1 := abs(MSF1 / MSF1F2);
FF2 := abs(MSF2 / MSF1F2);
if (MSF2F3 + MSF1F3 - MSF1F2F3) <= 0.0 then OKTerms[3] := 0 else
FF3 := abs(MSF3 / (MSF2F3 + MSF1F3 - MSF1F2F3));
if (MSF2F3 + MSF1F3 - MSF1F2F3) <= 0.0
then OKTerms[3] := 0
else FF3 := abs(MSF3 / (MSF2F3 + MSF1F3 - MSF1F2F3));
FF1F2 := abs(MSF2F3 / MSErr);
FF1F3 := abs(MSF1F2 / MSF1F2F3);
FF2F3 := abs(MSF1F3 / MSF1F2F3);
FF1F2F3 := abs(MSF1F2F3 / MSErr);
ProbF1 := probf(FF3,DFF3,DFF1F2);
ProbF2 := probf(FF2,DFF2,DFF1F2);
if (DFF2F3 + DFF1F3 - DFF1F2F3) <= 0 then OKTerms[10] := 0 else
ProbF3 := probf(FF1,DFF1,(DFF2F3 + DFF1F3 - DFF1F2F3));
if (DFF2F3 + DFF1F3 - DFF1F2F3) <= 0
then OKTerms[10] := 0
else ProbF3 := probf(FF1,DFF1,(DFF2F3 + DFF1F3 - DFF1F2F3));
ProbF1F2 := probf(FF2F3,DFF2F3,DFErr);
ProbF1F3 := probf(FF1F2,DFF1F2,DFF1F2F3);
ProbF2F3 := probf(FF1F3,DFF1F3,DFF1F2F3);
ProbF1F2F3 := probf(FF1F2F3,DFF1F2F3,DFErr);
end;
if (ProbF1 > 1.0) then ProbF1 := 1.0;
if (ProbF2 > 1.0) then ProbF2 := 1.0;
if ProbF3 > 1.0 then ProbF3 := 1.0;
@ -2439,6 +2453,7 @@ var
sumc1: double;
fdegfree: double;
Fnumerator, Fdenominator, NewF: double;
X, X2: Double;
begin
for i := 1 to 50 do
begin
@ -2450,7 +2465,7 @@ begin
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
// X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
intvalue := intvalue - minf1 + 1;
cellcnts[intvalue-1] := 0.0;
cellsums[intvalue-1] := 0.0;
@ -2468,12 +2483,13 @@ begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
X2 := X*X;
intvalue := intvalue - minf1 + 1;
cellcnts[intvalue-1] := cellcnts[intvalue-1] + 1;
cellsums[intvalue-1] := cellsums[intvalue-1] + X;
cellvars[intvalue-1] := cellvars[intvalue-1] + (X * X);
cellvars[intvalue-1] := cellvars[intvalue-1] + X2;
MeanDep := MeanDep + X;
SSDep := SSDep + X * X;
SSDep := SSDep + X2;
N := N + 1;
end;
@ -2572,6 +2588,7 @@ var
barxj: array[1..50] of double;
sumc1: double;
fdegfree, term1, term2, term3: double;
X, X2: Double;
begin
for i := 1 to 50 do
begin
@ -2584,7 +2601,7 @@ begin
begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
// X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
intvalue := intvalue - minf1 + 1;
cellcnts[intvalue-1] := 0.0;
cellsums[intvalue-1] := 0.0;
@ -2602,12 +2619,13 @@ begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i])));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i]));
X := X*X;
intvalue := intvalue - minf1 + 1;
cellcnts[intvalue-1] := cellcnts[intvalue-1] + 1;
cellsums[intvalue-1] := cellsums[intvalue-1] + X;
cellvars[intvalue-1] := cellvars[intvalue-1] + (X * X);
cellvars[intvalue-1] := cellvars[intvalue-1] + X2;
MeanDep := MeanDep + X;
SSDep := SSDep + (X * X);
SSDep := SSDep + X2;
barxj[intvalue] := barxj[intvalue] + X;
N := N + 1;
end;