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

View File

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