LazStats: Some refactoring in LatinSqrsUnit

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7923 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-12-05 12:40:55 +00:00
parent d2ffe083b1
commit 94677510b7
2 changed files with 57 additions and 86 deletions

View File

@ -60,14 +60,14 @@ inherited LatinSqrsForm: TLatinSqrsForm
DropDownCount = 16
ItemHeight = 15
Items.Strings = (
'Plan 1. Three Factors (A,B,C) with no interactions.'
'Plan 2. Four Factors (A,B,C,D) with partial interactions.'
'Plan 3. Like Plan 2 but different assumptions (Partial confounding of interaction ABC.)'
'Plan 4. The Greco-Latin with no interactions assumed.'
'Plan 5. Repeated measures Latin Square (random assignment of groups to rows.)'
'Plan 6. Fractional replication of a three factor factorial experiment in incomplete blocks.'
'Plan 7. Plan 5 with superimposing of an orthogonal Latin square.'
'Plan 9. AxBxC (same square used for all levels of Factor C.)'
'Plan 1. Three Factors (A,B,C) with no interactions'
'Plan 2. Four Factors (A,B,C,D) with partial interactions'
'Plan 3. Like Plan 2 but different assumptions (partial confounding of interaction ABC)'
'Plan 4. The Greco-Latin with no interactions assumed'
'Plan 5. Repeated measures Latin Square (random assignment of groups to rows)'
'Plan 6. Fractional replication of a three factor factorial experiment in incomplete blocks'
'Plan 7. Plan 5 with superimposing of an orthogonal Latin square'
'Plan 9. AxBxC (same square used for all levels of factor C)'
)
OnChange = PlanComboChange
Style = csDropDownList
@ -527,12 +527,4 @@ inherited LatinSqrsForm: TLatinSqrsForm
Left = 367
Height = 573
end
inherited PageControl: TPageControl
Left = 376
Height = 557
Width = 530
ActivePage = ReportPage
TabIndex = 0
TabOrder = 1
end
end

View File

@ -6,14 +6,14 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
ComCtrls, Buttons, MainUnit, Globals, GraphLib,
MatrixLib, BasicStatsReportAndChartFormUnit;
ComCtrls, Buttons, MainUnit, Globals,
MatrixLib, BasicStatsReportFormUnit;
type
{ TLatinSqrsForm }
TLatinSqrsForm = class(TBasicStatsReportAndChartForm)
TLatinSqrsForm = class(TBasicStatsReportForm)
ACodeEdit: TEdit;
ACodeLabel: TLabel;
AInBtn: TBitBtn;
@ -368,14 +368,10 @@ begin
FactorC := CCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then ACol := i;
if (cellstring = FactorB) then BCol := i;
if (cellstring = FactorC) then Ccol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
CCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorC);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B and C
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -424,10 +420,10 @@ begin
// Read in the data
for i := 1 to NoCases do
begin
row := Round(StrToFloat(OS3MainFrm.DataGrid.Cells[Acol,i]));
col := Round(StrTofloat(OS3MainFrm.DataGrid.Cells[Bcol,i]));
slice := Round(StrToFloat(OS3MainFrm.DataGrid.Cells[Ccol,i]));
data := StrToFloat(OS3MainFrm.DataGrid.Cells[DataCol,i]);
row := Round(StrToFloat(OS3MainFrm.DataGrid.Cells[Acol, i]));
col := Round(StrTofloat(OS3MainFrm.DataGrid.Cells[Bcol, i]));
slice := Round(StrToFloat(OS3MainFrm.DataGrid.Cells[Ccol, i]));
data := StrToFloat(OS3MainFrm.DataGrid.Cells[DataCol, i]);
cellcnts[row-1,col-1] := cellcnts[row-1,col-1] + 1;
celltotals[row-1,col-1] := celltotals[row-1,col-1] + data;
Ctotals[slice-1] := Ctotals[slice-1] + data;
@ -667,15 +663,11 @@ begin
FactorD := DCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then ACol := i;
if (cellstring = FactorB) then BCol := i;
if (cellstring = FactorC) then Ccol := i;
if (cellstring = FactorD) then Dcol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
CCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorC);
DCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorD);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B and C
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -1080,15 +1072,11 @@ begin
FactorD := DCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then ACol := i;
if (cellstring = FactorB) then BCol := i;
if (cellstring = FactorC) then Ccol := i;
if (cellstring = FactorD) then Dcol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
CCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorC);
DCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorD);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B and C
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -1615,15 +1603,11 @@ begin
FactorD := DCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then ACol := i;
if (cellstring = FactorB) then BCol := i;
if (cellstring = FactorC) then Ccol := i;
if (cellstring = FactorD) then Dcol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
CCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorC);
DCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorD);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B and C
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -2086,15 +2070,11 @@ begin
GroupFactor := GrpCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then ACol := i;
if (cellstring = FactorB) then BCol := i;
if (cellstring = GroupFactor) then Grpcol := i;
if (cellstring = SubjectFactor) then Sbjcol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
GrpCol := GetVariableIndex(OS3MainFrm.DataGrid, GroupFactor);
SbjCol := GetVariableIndex(OS3MainFrm.DataGrid, SubjectFactor);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B and Group
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -2567,15 +2547,11 @@ begin
GroupFactor := GrpCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then ACol := i;
if (cellstring = FactorB) then BCol := i;
if (cellstring = GroupFactor) then Grpcol := i;
if (cellstring = SubjectFactor) then Sbjcol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
GrpCol := GetVariableIndex(OS3MainFrm.DataGrid, GroupFactor);
SbjCol := GetVariableIndex(OS3MainFrm.DataGrid, SubjectFactor);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B and Group
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -3051,16 +3027,12 @@ begin
GroupFactor := GrpCodeEdit.Text;
DataVar := DepVarEdit.Text;
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = FactorA) then Acol := i;
if (cellstring = FactorB) then Bcol := i;
if (cellstring = FactorC) then Ccol := i;
if (cellstring = GroupFactor) then Grpcol := i;
if (cellstring = SubjectFactor) then Sbjcol := i;
if (cellstring = DataVar) then DataCol := i;
end;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
CCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorC);
GrpCol := GetVariableIndex(OS3MainFrm.DataGrid, GroupFactor);
SbjCol := GetVariableIndex(OS3MainFrm.DataGrid, SubjectFactor);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
// determine no. of levels in A, B, C and Group
if not GetRange(ACol, rangeA, mn, mx) then exit;
@ -3623,6 +3595,13 @@ begin
GroupFactor := GrpCodeEdit.Text;
DataVar := DepVarEdit.Text;
ACol := GetVariableIndex(OS3MainFrm.DataGrid, FactorA);
BCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorB);
CCol := GetVariableIndex(OS3MainFrm.DataGrid, FactorC);
GrpCol := GetVariableIndex(OS3MainFrm.DataGrid, GroupFactor);
SbjCol := GetVariableIndex(OS3MainFrm.DataGrid, SubjectFactor);
DataCol := GetVariableIndex(OS3MainFrm.DataGrid, DataVar);
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];