LazStats: Inherit form of ABRAnovaUnit from TBasicStatsReportAndChartForm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7795 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-24 15:56:52 +00:00
parent 41ce82784b
commit 1e7192bd8e
6 changed files with 398 additions and 387 deletions

View File

@ -361,7 +361,7 @@
<Unit32>
<Filename Value="forms\analysis\comparisons\abranovaunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="ABRAnovaFrm"/>
<ComponentName Value="ABRAnovaForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="ABRANOVAUnit"/>

View File

@ -1,164 +1,87 @@
object ABRAnovaFrm: TABRAnovaFrm
Left = 577
Height = 405
Top = 337
Width = 481
inherited ABRAnovaForm: TABRAnovaForm
Left = 323
Height = 352
Top = 279
Width = 823
HelpType = htKeyword
HelpKeyword = 'html/AxBxRAnalysisofVariance.htm'
AutoSize = True
Caption = 'AxBxR ANOVA (two between and repeated measures)'
ClientHeight = 405
ClientWidth = 481
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 51
Top = 305
Width = 324
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 8
Caption = 'Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 320
TabOrder = 1
object PlotChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 79
Caption = 'Plot Means'
TabOrder = 0
ClientHeight = 352
ClientWidth = 823
inherited ParamsPanel: TPanel
Height = 336
Width = 329
ClientHeight = 336
ClientWidth = 329
object OptionsGroup: TGroupBox[0]
AnchorSideLeft.Control = ParamsPanel
AnchorSideBottom.Control = ButtonBevel
Left = 0
Height = 51
Top = 244
Width = 324
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Options:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 320
TabOrder = 10
object PlotChk: TCheckBox
AnchorSideLeft.Control = TestChk
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TestChk
AnchorSideTop.Side = asrCenter
Left = 229
Height = 19
Top = 6
Width = 79
Caption = 'Plot Means'
TabOrder = 1
end
object TestChk: TCheckBox
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = OptionsGroup
Left = 12
Height = 19
Top = 6
Width = 193
Caption = 'Test Homogeneity of Covariance'
TabOrder = 0
end
end
object TestChk: TCheckBox
Left = 115
Height = 19
Top = 6
Width = 193
Caption = 'Test Homogeneity of Covariance'
TabOrder = 1
inherited CloseBtn: TButton[1]
Left = 274
Top = 311
TabOrder = 14
end
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 268
Height = 25
Top = 372
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 330
Height = 25
Top = 372
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 414
Height = 25
Top = 372
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 102
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 209
Height = 25
Top = 372
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 356
Width = 481
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 289
Top = 8
Width = 465
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 289
ClientWidth = 465
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
inherited ComputeBtn: TButton[2]
Left = 190
Top = 311
TabOrder = 13
end
inherited ResetBtn: TButton[3]
Left = 128
Top = 311
TabOrder = 12
end
inherited HelpBtn: TButton[4]
Left = 69
Top = 311
TabOrder = 11
end
inherited ButtonBevel: TBevel[5]
Top = 295
Width = 329
end
object Label1: TLabel[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
Left = 0
Height = 15
Top = 0
@ -166,13 +89,13 @@ object ABRAnovaFrm: TABRAnovaFrm
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel
object Label2: TLabel[7]
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = ACodes
Left = 254
AnchorSideBottom.Control = ACodesEdit
Left = 185
Height = 15
Top = 25
Top = 21
Width = 88
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
@ -180,13 +103,13 @@ object ABRAnovaFrm: TABRAnovaFrm
Caption = 'Factor A Variable'
ParentColor = False
end
object Label3: TLabel
object Label3: TLabel[8]
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = BCodes
Left = 254
AnchorSideBottom.Control = BCodesEdit
Left = 185
Height = 15
Top = 109
Top = 101
Width = 87
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
@ -194,60 +117,60 @@ object ABRAnovaFrm: TABRAnovaFrm
Caption = 'Factor B Variable'
ParentColor = False
end
object Label4: TLabel
object Label4: TLabel[9]
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CInBtn
Left = 254
Left = 185
Height = 15
Top = 185
Top = 177
Width = 102
BorderSpacing.Left = 8
Caption = 'Repeated Measures'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel1
object VarList: TListBox[10]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AInBtn
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
AnchorSideBottom.Control = OptionsGroup
Left = 0
Height = 272
Height = 219
Top = 17
Width = 210
Width = 145
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Right = 6
ItemHeight = 0
MultiSelect = True
OnDblClick = VarListDblClick
OnSelectionChange = CListSelectionChange
TabOrder = 0
end
object AInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
object AInBtn: TBitBtn[11]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 218
Height = 28
Left = 151
Height = 26
Top = 17
Width = 28
Width = 26
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = AInBtnClick
Spacing = 0
TabOrder = 1
end
object AOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
object AOutBtn: TBitBtn[12]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AInBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 49
Width = 28
Left = 151
Height = 26
Top = 47
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
@ -255,15 +178,15 @@ object ABRAnovaFrm: TABRAnovaFrm
Spacing = 0
TabOrder = 2
end
object BInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
object BInBtn: TBitBtn[13]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = AOutBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 101
Width = 28
Left = 151
Height = 26
Top = 97
Width = 26
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
@ -271,15 +194,15 @@ object ABRAnovaFrm: TABRAnovaFrm
Spacing = 0
TabOrder = 4
end
object BOutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
object BOutBtn: TBitBtn[14]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BInBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 133
Width = 28
Left = 151
Height = 26
Top = 127
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
@ -287,15 +210,15 @@ object ABRAnovaFrm: TABRAnovaFrm
Spacing = 0
TabOrder = 5
end
object CInBtn: TBitBtn
AnchorSideLeft.Control = Panel1
object CInBtn: TBitBtn[15]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = BOutBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 185
Width = 28
Left = 151
Height = 26
Top = 177
Width = 26
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
@ -303,15 +226,15 @@ object ABRAnovaFrm: TABRAnovaFrm
Spacing = 0
TabOrder = 7
end
object COutBtn: TBitBtn
AnchorSideLeft.Control = Panel1
object COutBtn: TBitBtn[16]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = CInBtn
AnchorSideTop.Side = asrBottom
Left = 218
Height = 28
Top = 217
Width = 28
Left = 151
Height = 26
Top = 207
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
@ -319,64 +242,93 @@ object ABRAnovaFrm: TABRAnovaFrm
Spacing = 0
TabOrder = 8
end
object ACodes: TEdit
object ACodesEdit: TEdit[17]
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AOutBtn
AnchorSideBottom.Side = asrBottom
Left = 254
Left = 185
Height = 23
Top = 42
Width = 211
Top = 38
Width = 144
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
OnChange = ACodesChange
OnChange = ACodesEditChange
ReadOnly = True
TabOrder = 3
Text = 'ACodes'
Text = 'ACodesEdit'
end
object BCodes: TEdit
object BCodesEdit: TEdit[18]
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BOutBtn
AnchorSideBottom.Side = asrBottom
Left = 254
Left = 185
Height = 23
Top = 126
Width = 211
Top = 118
Width = 144
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
OnChange = ACodesChange
OnChange = ACodesEditChange
ReadOnly = True
TabOrder = 6
Text = 'BCodes'
Text = 'BCodesEdit'
end
object CList: TListBox
object CList: TListBox[19]
AnchorSideLeft.Control = AInBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label4
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 254
Height = 85
Top = 202
Width = 211
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
Left = 183
Height = 42
Top = 194
Width = 146
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 2
ItemHeight = 0
MultiSelect = True
OnDblClick = CListDblClick
OnSelectionChange = CListSelectionChange
TabOrder = 9
end
end
inherited ParamsSplitter: TSplitter
Left = 341
Height = 352
end
inherited PageControl: TPageControl
Left = 350
Height = 336
Width = 465
ActivePage = ChartPage
TabIndex = 1
end
object ListChartSource_AB: TListChartSource[3]
Left = 465
Top = 73
end
object ListChartSource_AC: TListChartSource[4]
Left = 465
Top = 130
end
object ListChartSource_BC: TListChartSource[5]
Left = 465
Top = 192
end
object ChartStyles: TChartStyles[6]
Styles = <>
Left = 622
Top = 73
end
end

View File

@ -7,55 +7,49 @@ unit ABRANOVAUnit;
interface
uses
contexthelpunit, Classes, SysUtils, FileUtil, LResources, Forms, Controls,
Graphics, Dialogs, StdCtrls, Buttons, ExtCtrls,
MainUnit, OutputUnit, FunctionsLib, GraphLib, Globals, DataProcs, MatrixLib;
contexthelpunit, Classes, SysUtils, FileUtil, TASources, TAStyles, Forms,
Controls, Graphics, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, MainUnit,
FunctionsLib, GraphLib, Globals, DataProcs, MatrixLib,
BasicStatsReportAndChartFormUnit;
type
{ TABRAnovaFrm }
{ TABRAnovaForm }
TABRAnovaFrm = class(TForm)
TABRAnovaForm = class(TBasicStatsReportAndChartForm)
AInBtn: TBitBtn;
AOutBtn: TBitBtn;
Bevel1: TBevel;
BInBtn: TBitBtn;
BOutBtn: TBitBtn;
ChartStyles: TChartStyles;
CInBtn: TBitBtn;
COutBtn: TBitBtn;
ACodes: TEdit;
BCodes: TEdit;
HelpBtn: TButton;
Panel1: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
ACodesEdit: TEdit;
BCodesEdit: TEdit;
ListChartSource_AB: TListChartSource;
ListChartSource_AC: TListChartSource;
ListChartSource_BC: TListChartSource;
TestChk: TCheckBox;
PlotChk: TCheckBox;
GroupBox1: TGroupBox;
OptionsGroup: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
CList: TListBox;
VarList: TListBox;
procedure ACodesChange(Sender: TObject);
procedure ACodesEditChange(Sender: TObject);
procedure AInBtnClick(Sender: TObject);
procedure AOutBtnClick(Sender: TObject);
procedure BInBtnClick(Sender: TObject);
procedure BOutBtnClick(Sender: TObject);
procedure CInBtnClick(Sender: TObject);
procedure CListDblClick(Sender: TObject);
procedure CListSelectionChange(Sender: TObject; User: boolean);
procedure ComputeBtnClick(Sender: TObject);
procedure COutBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
private
{ private declarations }
FAutoSized: Boolean;
ColNoSelected: IntDyneVec;
ACol, BCol, NoSelected, MinA, MaxA, MinB, MaxB, NoAGrps, NoBGrps : integer;
group, MaxRows, MaxCols, TotalN, NinGrp : integer;
@ -83,127 +77,110 @@ type
procedure BoxTests(AReport: TStrings);
procedure GraphMeans;
procedure CleanUp;
procedure UpdateBtnStates;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
public
{ public declarations }
constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end;
var
ABRAnovaFrm: TABRAnovaFrm;
ABRAnovaForm: TABRAnovaForm;
implementation
{$R *.lfm}
uses
Math, MathUnit;
Math,
MathUnit, GridProcs;
{ TABRAnovaFrm }
{ TABRAnovaForm }
procedure TABRAnovaFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
constructor TABRAnovaForm.Create(AOwner: TComponent);
begin
VarList.Items.Clear;
CList.Items.Clear;
ACodes.Text := '';
BCodes.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
PlotChk.Checked := false;
TestChk.Checked := false;
UpdateBtnStates;
end;
procedure TABRAnovaFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinHeight := Height;
Constraints.MinWidth := Width;
FAutoSized := true;
end;
procedure TABRAnovaFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
inherited;
if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TABRAnovaFrm.FormShow(Sender: TObject);
procedure TABRAnovaForm.AdjustConstraints;
begin
ResetBtnClick(self);
inherited;
ParamsPanel.Constraints.MinWidth := Max(
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
OptionsGroup.Width
);
ParamsPanel.Constraints.MinHeight := COutBtn.Top + COutBtn.Height +
OptionsGroup.BorderSpacing.Top + OptionsGroup.Height +
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height
end;
procedure TABRAnovaFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TABRAnovaFrm.ACodesChange(Sender: TObject);
procedure TABRAnovaForm.ACodesEditChange(Sender: TObject);
begin
UpdateBtnStates;
end;
procedure TABRAnovaFrm.AInBtnClick(Sender: TObject);
procedure TABRAnovaForm.AInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (ACodes.Text = '') then
if (index > -1) and (ACodesEdit.Text = '') then
begin
ACodes.Text := VarList.Items[index];
ACodesEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TABRAnovaFrm.AOutBtnClick(Sender: TObject);
procedure TABRAnovaForm.AOutBtnClick(Sender: TObject);
begin
if ACodes.Text <> '' then
if ACodesEdit.Text <> '' then
begin
VarList.Items.Add(ACodes.Text);
ACodes.Text := '';
VarList.Items.Add(ACodesEdit.Text);
ACodesEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TABRAnovaFrm.BInBtnClick(Sender: TObject);
procedure TABRAnovaForm.BInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (BCodes.Text = '') then
if (index > -1) and (BCodesEdit.Text = '') then
begin
BCodes.Text := VarList.Items[index];
BCodesEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TABRAnovaFrm.BOutBtnClick(Sender: TObject);
procedure TABRAnovaForm.BOutBtnClick(Sender: TObject);
begin
if BCodes.Text <> '' then
if BCodesEdit.Text <> '' then
begin
VarList.Items.Add(BCodes.Text);
BCodes.Text := '';
VarList.Items.Add(BCodesEdit.Text);
BCodesEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TABRAnovaFrm.CInBtnClick(Sender: TObject);
procedure TABRAnovaForm.CInBtnClick(Sender: TObject);
var
i: integer;
begin
@ -221,7 +198,49 @@ begin
UpdateBtnStates;
end;
procedure TABRAnovaFrm.ComputeBtnClick(Sender: TObject);
procedure TABRAnovaForm.CleanUp;
begin
ABCNcnt := nil;
ABCSums := nil;
ColLabels := nil;
RowLabels := nil;
Ccnt := nil;
Bcnt := nil;
Acnt := nil;
SumPSqr := nil;
AMatrix := nil;
BCSums := nil;
ACSums := nil;
ABSums := nil;
CSums := nil;
BSums := nil;
ASums := nil;
ColNoSelected := nil;
end;
procedure TABRAnovaForm.CListDblClick(Sender: TObject);
var
index: Integer;
begin
index := CList.ItemIndex;
if index > -1 then
begin
VarList.Items.Add(CList.Items[index]);
CList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TABRAnovaForm.CListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TABRAnovaForm.Compute;
var
lReport: TStrings;
begin
@ -234,7 +253,7 @@ begin
Summarize(lReport);
MeansReport(lReport);
if TestChk.Checked then BoxTests(lReport);
DisplayReport(lReport);
FReportFrame.DisplayReport(lReport);
if PlotChk.Checked then GraphMeans;
end;
finally
@ -243,7 +262,7 @@ begin
end;
end;
procedure TABRAnovaFrm.COutBtnClick(Sender: TObject);
procedure TABRAnovaForm.COutBtnClick(Sender: TObject);
var
i: Integer;
begin
@ -263,7 +282,8 @@ begin
UpdateBtnStates;
end;
function TABRAnovaFrm.InitData: Boolean;
function TABRAnovaForm.InitData: Boolean;
var
cellstring: string;
i, j, k: integer;
@ -276,8 +296,8 @@ begin
for i := 1 to NoVariables do
begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if (cellstring = ACodes.Text) then ACol := i;
if (cellstring = BCodes.Text) then BCol := i;
if (cellstring = ACodesEdit.Text) then ACol := i;
if (cellstring = BCodesEdit.Text) then BCol := i;
end;
if ( (ACol = 0) or (BCol = 0)) then
begin
@ -292,14 +312,14 @@ begin
MaxB := -10000;
for i := 1 to NoCases do
begin
if not ValidValue(i,ACol) then continue;
if not ValidValue(OS3MainFrm.DataGrid, i, ACol) then continue;
cellstring := Trim(OS3MainFrm.DataGrid.Cells[ACol,i]);
group := round(StrToFloat(cellstring));
if (group > MaxA) then MaxA := group;
if (group < MinA) then MinA := group;
cellstring := Trim(OS3MainFrm.DataGrid.Cells[BCol,i]);
if not ValidValue(i,BCol) then continue;
if not ValidValue(OS3MainFrm.DataGrid, i, BCol) then continue;
group := round(StrToFLoat(cellstring));
if (group > MaxB) then MaxB := group;
if (group < MinB) then MinB := group;
@ -369,42 +389,37 @@ begin
Result := true;
end;
procedure TABRAnovaFrm.GetData;
procedure TABRAnovaForm.GetData;
var
i, j, SubjA, SubjB: integer;
cellstring: string;
X: double;
begin
for i := 0 to NoSelected - 1 do
begin
cellstring := CList.Items.Strings[i];
for j := 1 to NoVariables do
if (OS3MainFrm.DataGrid.Cells[j,0] = cellstring) then ColNoSelected[i] := j;
end;
ColNoSelected[i] := GetVariableIndex(OS3MainFrm.DataGrid, CList.Items[i]);
ColNoSelected[NoSelected] := ACol;
ColNoSelected[NoSelected+1] := BCol;
ColNoSelected[NoSelected+1] := BCol; // must be over-dimensioned by +2
selected := NoSelected + 2;
// read data and store sums
for i := 1 to NoCases do
begin
if not GoodRecord(i,selected,ColNoSelected) then continue;
if not DataProcs.GoodRecord(i,selected,ColNoSelected) then continue;
SubjA := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ACol,i])));
SubjA := SubjA - MinA + 1;
SubjB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[BCol,i])));
SubjB := SubjB - MinB + 1;
SubjTot := 0.0;
for j := 1 to NoSelected do
for j := 0 to NoSelected-1 do
begin
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[j-1],i]));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[j], i]));
SubjTot := SubjTot + X;
SumXSqr := SumXSqr + (X * X);
ABCSums[SubjA-1,SubjB-1,j-1] := ABCSums[SubjA-1,SubjB-1,j-1] + X;
ABCNcnt[SubjA-1,SubjB-1,j-1] := ABCNcnt[SubjA-1,SubjB-1,j-1] + 1;
ABCSums[SubjA-1, SubjB-1, j] := ABCSums[SubjA-1, SubjB-1, j] + X;
ABCNcnt[SubjA-1, SubjB-1, j] := ABCNcnt[SubjA-1, SubjB-1, j] + 1;
Acnt[SubjA-1] := Acnt[SubjA-1] + 1;
Bcnt[SubjB-1] := Bcnt[SubjB-1] + 1;
Ccnt[j-1] := Ccnt[j-1] + 1;
Ccnt[j] := Ccnt[j] + 1;
TotalN := TotalN + 1;
end;
SumPSqr[i-1] := SumPSqr[i-1] + (SubjTot * SubjTot);
@ -413,7 +428,7 @@ begin
end;
end;
procedure TABRAnovaFrm.Calculate;
procedure TABRAnovaForm.Calculate;
var
SumA, SumB, SumC, SumAB, SumAC, SumBC, SumABC : double;
Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10 : double;
@ -568,7 +583,7 @@ begin
ProbABC := ProbF(FABC,DFABC,DFerrorWithin);
end;
procedure TABRAnovaFrm.Summarize(AReport: TStrings);
procedure TABRAnovaForm.Summarize(AReport: TStrings);
begin
AReport.Add('SOURCE DF SS MS F PROB.');
AReport.Add('');
@ -590,7 +605,7 @@ begin
// OutputFrm.ShowModal;
end;
procedure TABRAnovaFrm.MeansReport(AReport: TStrings);
procedure TABRAnovaForm.MeansReport(AReport: TStrings);
var
ColHeader, LabelStr: string;
Title: string;
@ -667,7 +682,7 @@ begin
// OutputFrm.ShowModal;
end;
procedure TABRAnovaFrm.BoxTests(AReport: TStrings);
procedure TABRAnovaForm.BoxTests(AReport: TStrings);
const
EPS = 1E-35;
var
@ -717,17 +732,17 @@ begin
// read data and add to covariances
for row := 1 to NoCases do
begin
if not GoodRecord(row,selected,ColNoSelected) then
if not DataProcs.GoodRecord(row, selected, ColNoSelected) then
continue;
SubjA := round(StrToFLoat(Trim(OS3MainFrm.DataGrid.Cells[ACol,row])));
SubjA := round(StrToFLoat(Trim(OS3MainFrm.DataGrid.Cells[ACol, row])));
SubjA := SubjA - MinA + 1;
SubjB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[BCol,row])));
SubjB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[BCol, row])));
SubjB := SubjB - MinB + 1;
if ((SubjA <> i)or(SubjB <> j)) then
continue;
for k := 1 to NoSelected do
begin
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[k-1],row]));
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[k-1], row]));
XVector[k-1] := X;
XSums[k-1] := XSums[k-1] + X;
end;
@ -853,7 +868,7 @@ begin
XVector := nil;
end;
procedure TABRAnovaFrm.GraphMeans;
procedure TABRAnovaForm.GraphMeans;
var
MaxMean : double;
i, j : integer;
@ -967,41 +982,36 @@ begin
GraphFrm.Ypoints := nil;
end;
procedure TABRAnovaFrm.CleanUp;
procedure TABRAnovaForm.Reset;
var
i: integer;
begin
ABCNcnt := nil;
ABCSums := nil;
ColLabels := nil;
RowLabels := nil;
Ccnt := nil;
Bcnt := nil;
Acnt := nil;
SumPSqr := nil;
AMatrix := nil;
BCSums := nil;
ACSums := nil;
ABSums := nil;
CSums := nil;
BSums := nil;
ASums := nil;
ColNoSelected := nil;
end;
inherited;
procedure TABRAnovaFrm.CListSelectionChange(Sender: TObject; User: boolean);
begin
VarList.Items.Clear;
CList.Items.Clear;
ACodesEdit.Text := '';
BCodesEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
PlotChk.Checked := false;
TestChk.Checked := false;
UpdateBtnStates;
end;
procedure TABRAnovaFrm.UpdateBtnStates;
procedure TABRAnovaForm.UpdateBtnStates;
var
lSelected: Boolean;
i: Integer;
begin
AInBtn.Enabled := (VarList.ItemIndex > -1) and (ACodes.Text = '');
AOutBtn.Enabled := (ACodes.Text <> '');
inherited;
AInBtn.Enabled := (VarList.ItemIndex > -1) and (ACodesEdit.Text = '');
AOutBtn.Enabled := (ACodesEdit.Text <> '');
BInBtn.Enabled := (VarList.ItemIndex > -1) and (BCodes.Text = '');
BOutBtn.Enabled := (BCodes.Text <> '');
BInBtn.Enabled := (VarList.ItemIndex > -1) and (BCodesEdit.Text = '');
BOutBtn.Enabled := (BCodesEdit.Text <> '');
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
@ -1022,8 +1032,57 @@ begin
COutBtn.Enabled := lSelected;
end;
initialization
{$I abranovaunit.lrs}
function TABRAnovaForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
begin
Result := false;
if ACodesEdit.Text = '' then
begin
AMsg := 'Factor A variable not specified.';
AControl := ACodesEdit;
exit;
end;
if BCodesEdit.Text = '' then
begin
AMsg := 'Factor B variable not specified.';
AControl := BCodesEdit;
exit;
end;
if CList.Items.Count = 0 then
begin
AMsg := 'No Repeated Measures variables specified.';
AControl := CList;
exit;
end;
Result := true;
end;
procedure TABRAnovaForm.VarListDblClick(Sender: TObject);
var
index: Integer;
s: String;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
s := VarList.Items[index];
if ACodesEdit.Text = '' then
ACodesEdit.Text := s
else
if BCodesEdit.Text = '' then
BCodesEdit.Text := s
else
CList.Items.Add(s);
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
end.

View File

@ -89,9 +89,8 @@ uses
constructor TBlkMregForm.Create(AOwner: TComponent);
begin
inherited;
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
if DictionaryFrm = nil then
Application.CreateForm(TDictionaryFrm, DictionaryFrm);
end;

View File

@ -1096,9 +1096,9 @@ end;
// Menu "Analysis" > "Comparisons" > "A x B x S mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_ABSAnovaClick(Sender: TObject);
begin
if ABRAnovaFrm = nil then
Application.CreateForm(TABRAnovaFrm, ABRAnovaFrm);
ABRAnovaFrm.ShowModal;
if ABRAnovaForm = nil then
Application.CreateForm(TABRAnovaForm, ABRAnovaForm);
ABRAnovaForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "mnuAnalysisComp_Ancova by Regression"

View File

@ -212,13 +212,14 @@ end;
{ Checks wheter the value in cell at the given column and row is a not-filtered,
non-empty number.
Grid coordinates are in grid units.
NOTE: non-numeric characters in a numeric field are not taken into account! }
function ValidValue(AGrid: TStringGrid; ARow, ACol: integer): boolean;
begin
Result := not (
IsFiltered(AGrid, ARow) or // filtering is active and row is marked to be excluded
IsEmptyNumericValue(AGrid, ARow, aCol) or // column is numeric, but cell is empty
IsMissingValueCode(AGrid, ARow, ACol) // cell contains the "missing value code"
IsFiltered(AGrid, ARow) or // Giltering is active and row is marked to be excluded
IsEmptyNumericValue(AGrid, ARow, aCol) or // Column is numeric, but cell is empty
IsMissingValueCode(AGrid, ARow, ACol) // Cell contains the "missing value code"
);
end;