LazStats: Integrate report output into the form of BreakDownUnit. Begin refactoring of Compute routine. Fix TabOrder of MultXvsYUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7704 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-09-27 22:43:10 +00:00
parent bd95521f4b
commit 697e7ba4f8
4 changed files with 410 additions and 328 deletions

View File

@ -1,74 +1,147 @@
object BreakDownFrm: TBreakDownFrm inherited BreakDownFrm: TBreakDownFrm
Left = 400 Left = 400
Height = 367 Height = 363
Top = 248 Top = 248
Width = 428 Width = 873
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/Breakdown.htm' HelpKeyword = 'html/Breakdown.htm'
AutoSize = True
Caption = 'Breakdown' Caption = 'Breakdown'
ClientHeight = 367 ClientHeight = 363
ClientWidth = 428 ClientWidth = 873
OnActivate = FormActivate OnActivate = FormActivate
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter Position = poMainFormCenter
LCLVersion = '2.1.0.0' object ParamsPanel: TPanel[0]
object CheckGroup1: TCheckGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8 Left = 8
Height = 51 Height = 347
Top = 267 Top = 8
Width = 140 Width = 344
Anchors = [akLeft, akBottom] Align = alLeft
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 4
Caption = 'Option' BorderSpacing.Bottom = 8
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 31
ClientWidth = 136
Items.Strings = (
'One Way ANOVA'
)
TabOrder = 1
Data = {
0100000002
}
end
object Panel2: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CheckGroup1
Left = 8
Height = 251
Top = 8
Width = 412
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 8
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 251 ClientHeight = 347
ClientWidth = 412 ClientWidth = 344
Constraints.MinHeight = 200
TabOrder = 0 TabOrder = 0
object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 289
Height = 25
Top = 322
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Close'
ModalResult = 11
OnClick = CloseBtnClick
TabOrder = 11
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 143
Height = 25
Top = 322
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 9
end
object HelpBtn: TButton
Tag = 109
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 84
Height = 25
Top = 322
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 8
end
object Bevel1: TBevel
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 306
Width = 344
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 205
Height = 25
Top = 322
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
end
object CheckGroup1: TCheckGroup
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 0
Height = 51
Top = 255
Width = 140
Anchors = [akLeft, akBottom]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Option'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 31
ClientWidth = 136
Items.Strings = (
'One Way ANOVA'
)
TabOrder = 7
Data = {
0100000002
}
end
object AvailLabel: TLabel object AvailLabel: TLabel
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Panel2 AnchorSideTop.Control = ParamsPanel
Left = 0 Left = 0
Height = 15 Height = 15
Top = 0 Top = 0
@ -78,8 +151,8 @@ object BreakDownFrm: TBreakDownFrm
end end
object AnalLabel: TLabel object AnalLabel: TLabel
AnchorSideLeft.Control = SelList AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Panel2 AnchorSideTop.Control = ParamsPanel
Left = 228 Left = 194
Height = 15 Height = 15
Top = 0 Top = 0
Width = 104 Width = 104
@ -89,9 +162,9 @@ object BreakDownFrm: TBreakDownFrm
object SelLabel: TLabel object SelLabel: TLabel
AnchorSideLeft.Control = SelList AnchorSideLeft.Control = SelList
AnchorSideBottom.Control = DepVar AnchorSideBottom.Control = DepVar
Left = 228 Left = 194
Height = 15 Height = 15
Top = 199 Top = 195
Width = 153 Width = 153
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
@ -99,16 +172,15 @@ object BreakDownFrm: TBreakDownFrm
ParentColor = False ParentColor = False
end end
object VarList: TListBox object VarList: TListBox
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = AvailLabel AnchorSideTop.Control = AvailLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = Panel2 AnchorSideBottom.Control = CheckGroup1
AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 234 Height = 230
Top = 17 Top = 17
Width = 184 Width = 150
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 8
@ -122,13 +194,13 @@ object BreakDownFrm: TBreakDownFrm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = AnalLabel AnchorSideTop.Control = AnalLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2 AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SelVarInBtn AnchorSideBottom.Control = SelVarInBtn
Left = 228 Left = 194
Height = 166 Height = 162
Top = 17 Top = 17
Width = 184 Width = 150
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
@ -145,10 +217,10 @@ object BreakDownFrm: TBreakDownFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SelVarOutBtn AnchorSideBottom.Control = SelVarOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 228 Left = 194
Height = 23 Height = 23
Top = 216 Top = 212
Width = 184 Width = 150
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
@ -157,10 +229,10 @@ object BreakDownFrm: TBreakDownFrm
Text = 'DepVar' Text = 'DepVar'
end end
object InBtn: TBitBtn object InBtn: TBitBtn
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
Left = 192 Left = 158
Height = 28 Height = 28
Top = 17 Top = 17
Width = 28 Width = 28
@ -171,11 +243,11 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 1 TabOrder = 1
end end
object OutBtn: TBitBtn object OutBtn: TBitBtn
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 192 Left = 158
Height = 28 Height = 28
Top = 49 Top = 49
Width = 28 Width = 28
@ -187,12 +259,12 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 2 TabOrder = 2
end end
object SelVarInBtn: TBitBtn object SelVarInBtn: TBitBtn
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = SelVarOutBtn AnchorSideBottom.Control = SelVarOutBtn
Left = 192 Left = 158
Height = 28 Height = 28
Top = 191 Top = 187
Width = 28 Width = 28
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4 BorderSpacing.Bottom = 4
@ -203,13 +275,13 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 4 TabOrder = 4
end end
object SelVarOutBtn: TBitBtn object SelVarOutBtn: TBitBtn
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 192 Left = 158
Height = 28 Height = 28
Top = 223 Top = 219
Width = 28 Width = 28
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
@ -219,89 +291,32 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 5 TabOrder = 5
end end
end end
object CloseBtn: TButton object ParamsSplitter: TSplitter[1]
AnchorSideRight.Control = Owner Left = 356
AnchorSideRight.Side = asrBottom Height = 363
AnchorSideBottom.Control = Owner Top = 0
AnchorSideBottom.Side = asrBottom Width = 5
Left = 361 ResizeStyle = rsPattern
Height = 25
Top = 334
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 4
end end
object ResetBtn: TButton object PageControl1: TPageControl[2]
AnchorSideRight.Control = ComputeBtn Left = 365
AnchorSideBottom.Control = Owner Height = 347
AnchorSideBottom.Side = asrBottom Top = 8
Left = 215 Width = 500
Height = 25 ActivePage = BreakDownPage
Top = 334 Align = alClient
Width = 54 BorderSpacing.Left = 4
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Reset' TabIndex = 0
OnClick = ResetBtnClick
TabOrder = 3
end
object HelpBtn: TButton
Tag = 109
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 156
Height = 25
Top = 334
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 TabOrder = 2
end object BreakDownPage: TTabSheet
object Bevel1: TBevel Caption = 'Report'
AnchorSideLeft.Control = Owner end
AnchorSideRight.Control = Owner object AnovaPage: TTabSheet
AnchorSideRight.Side = asrBottom Caption = 'Analaxis of Variance'
AnchorSideBottom.Control = CloseBtn TabVisible = False
Left = 0 end
Height = 8
Top = 318
Width = 428
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 277
Height = 25
Top = 334
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
end end
end end

View File

@ -7,21 +7,23 @@ unit BreakDownUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, StdCtrls, ExtCtrls, Buttons, ComCtrls,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit; MainUnit, Globals, FunctionsLib, DataProcs, ContextHelpUnit,
BasicStatsFormUnit, ReportFrameUnit;
type type
{ TBreakDownFrm } { TBreakDownFrm }
TBreakDownFrm = class(TForm) TBreakDownFrm = class(TBasicStatsForm)
Bevel1: TBevel; Bevel1: TBevel;
ComputeBtn: TButton; ComputeBtn: TButton;
HelpBtn: TButton; HelpBtn: TButton;
InBtn: TBitBtn; InBtn: TBitBtn;
OutBtn: TBitBtn; OutBtn: TBitBtn;
Panel2: TPanel; PageControl1: TPageControl;
ParamsPanel: TPanel;
SelVarInBtn: TBitBtn; SelVarInBtn: TBitBtn;
SelVarOutBtn: TBitBtn; SelVarOutBtn: TBitBtn;
ResetBtn: TButton; ResetBtn: TButton;
@ -32,11 +34,14 @@ type
AnalLabel: TLabel; AnalLabel: TLabel;
SelLabel: TLabel; SelLabel: TLabel;
SelList: TListBox; SelList: TListBox;
ParamsSplitter: TSplitter;
BreakDownPage: TTabSheet;
AnovaPage: TTabSheet;
VarList: TListBox; VarList: TListBox;
procedure CloseBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject); procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject); procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject); procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject); procedure OutBtnClick(Sender: TObject);
@ -48,12 +53,13 @@ type
private private
{ private declarations } { private declarations }
FBreakdownReportFrame: TReportFrame;
FANOVAReportFrame: TReportFrame;
FAutoSized: Boolean; FAutoSized: Boolean;
Minimum, Maximum, levels, displace, subscript : IntDyneVec; Minimum, Maximum, levels, displace, subscript : IntDyneVec;
Freq : IntDyneVec; Freq : IntDyneVec;
Selected : IntDyneVec; Selected : IntDyneVec;
mean, variance, Stddev, SS : DblDyneVec; index, ListSize, length_array : integer;
index, NoSelected, ListSize, Dependentvar, X, length_array : integer;
ptr1, ptr2, sum, grandsum : integer; ptr1, ptr2, sum, grandsum : integer;
xsumtotal, xsqrtotal, grandsumx, grandsumx2, value, SD : double; xsumtotal, xsqrtotal, grandsumx, grandsumx2, value, SD : double;
SST, SSW, SSB, MSW, MSB, F, FProb, DF1, DF2 : double; SST, SSW, SSB, MSW, MSB, F, FProb, DF1, DF2 : double;
@ -61,130 +67,46 @@ type
outline : string; outline : string;
valstr : string; valstr : string;
dataread : boolean; dataread : boolean;
function Index_Pos(var X1: IntDyneVec; var displace1: IntDyneVec; ListSize1: integer): Integer; function Index_Pos(const X, ADisplace: IntDyneVec; AListSize: integer): Integer;
procedure UpdateBtnStates; procedure UpdateBtnStates;
public public
{ public declarations } { public declarations }
procedure Reset; override;
end; end;
var var
BreakDownFrm: TBreakDownFrm; BreakDownFrm: TBreakDownFrm;
implementation implementation
{$R *.lfm}
uses uses
Math; Math, Utils;
{ TBreakDownFrm } { TBreakDownFrm }
procedure TBreakDownFrm.ResetBtnClick(Sender: TObject); procedure TBreakDownFrm.CloseBtnClick(Sender: TObject);
var
i: integer;
begin begin
VarList.Clear; Close;
SelList.Clear;
DepVar.Text := '';
InBtn.Enabled := true;
OutBtn.Enabled := false;
SelVarInBtn.Enabled := true;
SelVarOutBtn.Enabled := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end; end;
procedure TBreakDownFrm.SelListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarInBtnClick(Sender: TObject);
var
index1 : integer;
begin
index1 := VarList.ItemIndex;
if (index1 > -1) and (DepVar.Text = '') then
begin
DepVar.Text := VarList.Items[index1];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarOutBtnClick(Sender: TObject);
begin
if DepVar.Text <> '' then
VarList.Items.Add(DepVar.Text);
UpdateBtnStates;
end;
procedure TBreakDownFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBreakDownFrm.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;
//Panel2.Constraints.MinWidth := SelLabel.Width * 2 + InBtn.Width + 2 * VarList.BorderSpacing.Right;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TBreakDownFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TBreakDownFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TBreakDownFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if (VarList.Selected[i]) then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.ComputeBtnClick(Sender: TObject); procedure TBreakDownFrm.ComputeBtnClick(Sender: TObject);
label label
Label1, Label3, Label4, NextStep, FirstOne, SecondOne, ThirdOne, LastStep; Label1, Label3, Label4, NextStep, FirstOne, SecondOne, ThirdOne, LastStep;
var var
mean: DblDyneVec = nil;
variance: DblDyneVec = nil;
stddev: DblDyneVec = nil;
SS: DblDyneVec = nil;
X: Integer;
i, j: integer; i, j: integer;
Dependentvar, NoSelected: Integer;
tempval: string; tempval: string;
lReport: TStrings; lReport: TStrings;
begin begin
@ -306,16 +228,19 @@ begin
// setup the output // setup the output
lReport := TStringList.Create; lReport := TStringList.Create;
try try
BreakdownPage.Caption := 'Breakdown Analysis';
lReport.Add('BREAKDOWN ANALYSIS PROGRAM'); lReport.Add('BREAKDOWN ANALYSIS PROGRAM');
lReport.Add(''); lReport.Add('');
lReport.Add('VARIABLE SEQUENCE FOR THE BREAKDOWN:'); lReport.Add('VARIABLE SEQUENCE FOR THE BREAKDOWN:');
for i := 1 to ListSize do for i := 1 to ListSize do
begin begin
index := Selected[i-1]; index := Selected[i-1];
lReport.Add('%-10s (Variable %3d) Lowest level = %2d Highest level = %2d', [ lReport.Add('%-10s (Variable %3d) Lowest level: %2d Highest level: %2d', [
OS3MainFrm.DataGrid.Cells[index,0],i, Minimum[i-1], Maximum[i-1] OS3MainFrm.DataGrid.Cells[index,0],i, Minimum[i-1], Maximum[i-1]
]); ]);
end; end;
lReport.Add('');
// Breakdown the data // Breakdown the data
ptr1 := ListSize - 1; ptr1 := ListSize - 1;
@ -335,7 +260,7 @@ begin
for i := 1 to ListSize do for i := 1 to ListSize do
begin begin
j := Selected[i-1]; j := Selected[i-1];
lReport.Add('%-10s level = %3d', [ lReport.Add('%-10s level %3d', [
OS3MainFrm.DataGrid.Cells[j,0], Minimum[i-1] + subscript[i-1] - 1 OS3MainFrm.DataGrid.Cells[j,0], Minimum[i-1] + subscript[i-1] - 1
]); ]);
end; end;
@ -345,15 +270,17 @@ begin
xsumtotal := xsumtotal + mean[index]; xsumtotal := xsumtotal + mean[index];
xsqrtotal := xsqrtotal + variance[index]; xsqrtotal := xsqrtotal + variance[index];
lReport.Add('Freq. Mean Std. Dev.'); lReport.Add(' Freq. Mean Std. Dev.');
outline := Format('%3d', [Freq[index]]); lReport.Add('-------- -------- ---------');
// xxxxxxx xxxxxxxx xxxxxxxx
outline := Format('%7d', [Freq[index]]);
if Freq[index] > 0 then if Freq[index] > 0 then
begin begin
valstr := Format(' %8.3f ',[mean[index] / Freq[index]]); valstr := Format(' %8.3f ',[mean[index] / Freq[index]]);
outline := outline + valstr; outline := outline + valstr;
end end
else else
outline := outline +' ******** '; outline := outline +' ******** ';
if Freq[index] > 1 then if Freq[index] > 1 then
begin begin
@ -371,18 +298,19 @@ begin
subscript[ptr2-1] := subscript[ptr2-1] + 1; subscript[ptr2-1] := subscript[ptr2-1] + 1;
if subscript[ptr2-1] <= levels[ptr2-1] then goto Label1; if subscript[ptr2-1] <= levels[ptr2-1] then goto Label1;
lReport.Add('Number of observations across levels = %d',[sum]);
lReport.Add ('Number of observations across levels: %8d',[sum]);
if sum > 0 then if sum > 0 then
lReport.Add('Mean across levels = %8.3f',[ xsumtotal / sum]) lReport.Add('Mean across levels: %8.3f',[ xsumtotal / sum])
else else
lReport.Add('Mean across levels = ********'); lReport.Add('Mean across levels: ********');
if sum > 1 then if sum > 1 then
begin begin
SD := sqrt( (xsqrtotal - (xsumtotal * xsumtotal) / sum) / (sum - 1)); SD := sqrt( (xsqrtotal - (xsumtotal * xsumtotal) / sum) / (sum - 1));
lReport.Add('Std. Dev. across levels = %8.3f', [SD]); lReport.Add('Std. Dev. across levels: %8.3f', [SD]);
end else end else
lReport.Add('Std. Dev. across levels = *******'); lReport.Add('Std. Dev. across levels: ********');
lReport.Add(''); lReport.Add('');
lReport.Add('==============================================================='); lReport.Add('===============================================================');
@ -422,24 +350,23 @@ begin
goto Label1; goto Label1;
NextStep: NextStep:
lReport.Add('Grand number of observations across all categories = %3d', [grandsum]); lReport.Add ('Grand number of observations across all categories: %8d', [grandsum]);
if grandsum > 0 then if grandsum > 0 then
lReport.Add('Overall Mean = %8.3f', [grandsumx / grandsum]); lReport.Add('Overall Mean: %8.3f', [grandsumx / grandsum]);
if grandsum > 1 then if grandsum > 1 then
begin begin
SD := sqrt((grandsumx2 - (grandsumx * grandsumx) / grandsum) / (grandsum - 1)); SD := sqrt((grandsumx2 - sqr(grandsumx) / grandsum) / (grandsum - 1));
lReport.Add('Overall standard deviation = %8.3f', [SD]); lReport.Add('Overall Standard Deviation: %8.3f', [SD]);
end; end;
lReport.Add(''); FBreakdownReportFrame.DisplayReport(lReport);
lReport.Add('==============================================================='); lReport.Clear;
lReport.Add('');
//OutputFrm.ShowModal;
//OutputFrm.Clear;
// Do ANOVA's if requested // Do ANOVA's if requested
if CheckGroup1.CheckEnabled[0] then if CheckGroup1.Checked[0] then
begin begin
AnovaPage.Caption := 'Analysis of Variance';
AnovaPage.TabVisible := true;
lReport.Add('ANALYSES OF VARIANCE SUMMARY TABLES'); lReport.Add('ANALYSES OF VARIANCE SUMMARY TABLES');
lReport.Add(''); lReport.Add('');
ptr1 := ListSize - 1; ptr1 := ListSize - 1;
@ -582,28 +509,111 @@ begin
begin begin
lReport.Add('Only 1 group. No ANOVA possible.'); lReport.Add('Only 1 group. No ANOVA possible.');
end; end;
// Show ANOVA in pagecontrol
FANovaReportFrame.DisplayReport(lReport);
end; end;
// Show report in output form
DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
SS := nil;
Stddev := nil;
variance := nil;
mean := nil;
Freq := nil;
selected := nil;
subscript := nil;
displace := nil;
levels := nil;
Maximum := nil;
Minimum := nil;
end; end;
end; end;
procedure TBreakDownFrm.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;
ParamsPanel.Constraints.MinWidth := Max(
4*w + 3*CloseBtn.BorderSpacing.Left,
SelLabel.Width * 2 + InBtn.Width + VarList.BorderSpacing.Right * 2);
ParamsPanel.Constraints.MinHeight := InBtn.Top +
4*InBtn.Height + 3*OutBtn.BorderSpacing.Bottom +
CheckGroup1.BorderSpacing.Top + CheckGroup1.Height + Bevel1.Height +
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Left*2;
if Width < Constraints.MinWidth then Width := 1; // enforce constraints
if Height < Constraints.MinHeight then Height := 1;
Position := poDesigned;
FAutoSized := true;
end;
procedure TBreakDownFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
InitForm(self);
FBreakDownReportFrame := TReportFrame.Create(self);
with FBreakdownReportFrame do
begin
Parent := BreakDownPage;
Align := alClient;
end;
FANOVAReportFrame := TReportFrame.Create(ANOVAPage);
with FANOVAReportFrame do
begin
Parent := ANOVAPage;
Align := alClient;
end;
Reset;
end;
procedure TBreakDownFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBreakDownFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if (VarList.Selected[i]) then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
function TBreakDownFrm.Index_Pos(const X, ADisplace: IntDyneVec;
AListSize: integer): integer;
var
i: integer;
begin
Result := X[AListSize-1];
for i := 1 to AListSize - 1 do
Result := Result + (X[i-1] - 1) * ADisplace[i-1];
end;
procedure TBreakDownFrm.OutBtnClick(Sender: TObject); procedure TBreakDownFrm.OutBtnClick(Sender: TObject);
var var
i: integer; i: integer;
@ -622,16 +632,65 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
function TBreakDownFrm.Index_Pos(var X1: IntDyneVec; var displace1: IntDyneVec;
ListSize1: integer): integer; procedure TBreakDownFrm.Reset;
var var
i: integer; i: integer;
begin begin
Result := X1[ListSize-1]; VarList.Clear;
for i := 1 to ListSize - 1 do SelList.Clear;
Result := Result + ((X1[i-1] - 1) * displace[i-1]); DepVar.Text := '';
InBtn.Enabled := true;
OutBtn.Enabled := false;
SelVarInBtn.Enabled := true;
SelVarOutBtn.Enabled := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
FBreakdownReportFrame.Clear;
FAnovaReportFrame.Clear;
BreakdownPage.Caption := 'Report';
AnovaPage.TabVisible := false;
UpdateBtnStates;
end; end;
procedure TBreakDownFrm.ResetBtnClick(Sender: TObject);
begin
Reset;
end;
procedure TBreakDownFrm.SelListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarInBtnClick(Sender: TObject);
var
index1 : integer;
begin
index1 := VarList.ItemIndex;
if (index1 > -1) and (DepVar.Text = '') then
begin
DepVar.Text := VarList.Items[index1];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarOutBtnClick(Sender: TObject);
begin
if DepVar.Text <> '' then
VarList.Items.Add(DepVar.Text);
UpdateBtnStates;
end;
procedure TBreakDownFrm.UpdateBtnStates; procedure TBreakDownFrm.UpdateBtnStates;
var var
lSelected: Boolean; lSelected: Boolean;
@ -657,10 +716,17 @@ begin
SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = ''); SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = '');
SelVarOutBtn.Enabled := (DepVar.Text <> ''); SelVarOutBtn.Enabled := (DepVar.Text <> '');
FBreakdownReportFrame.UpdateBtnStates;
FAnovaReportFrame.UpdateBtnStates;
end;
procedure TBreakDownFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end; end;
initialization
{$I breakdownunit.lrs}
end. end.

View File

@ -41,7 +41,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Reset' Caption = 'Reset'
OnClick = ResetBtnClick OnClick = ResetBtnClick
TabOrder = 0 TabOrder = 13
end end
object ComputeBtn: TButton object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn AnchorSideRight.Control = CloseBtn
@ -58,7 +58,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Compute' Caption = 'Compute'
OnClick = ComputeBtnClick OnClick = ComputeBtnClick
TabOrder = 1 TabOrder = 14
end end
object CloseBtn: TButton object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel AnchorSideRight.Control = ParamsPanel
@ -76,7 +76,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
Caption = 'Close' Caption = 'Close'
ModalResult = 11 ModalResult = 11
OnClick = CloseBtnClick OnClick = CloseBtnClick
TabOrder = 2 TabOrder = 15
end end
object HelpBtn: TButton object HelpBtn: TButton
Tag = 134 Tag = 134
@ -93,7 +93,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Help' Caption = 'Help'
OnClick = HelpBtnClick OnClick = HelpBtnClick
TabOrder = 3 TabOrder = 12
end end
object ButtonBevel: TBevel object ButtonBevel: TBevel
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -129,7 +129,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
Width = 290 Width = 290
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
TabOrder = 4 TabOrder = 11
TextHint = 'Text above the plot' TextHint = 'Text above the plot'
end end
object Label1: TLabel object Label1: TLabel
@ -157,7 +157,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ItemHeight = 0 ItemHeight = 0
OnDblClick = VarListDblClick OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 5 TabOrder = 0
end end
object XInBtn: TBitBtn object XInBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -171,7 +171,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 1 ImageIndex = 1
OnClick = XInBtnClick OnClick = XInBtnClick
Spacing = 0 Spacing = 0
TabOrder = 6 TabOrder = 1
end end
object XOutBtn: TBitBtn object XOutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -187,7 +187,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 0 ImageIndex = 0
OnClick = XOutBtnClick OnClick = XOutBtnClick
Spacing = 0 Spacing = 0
TabOrder = 7 TabOrder = 2
end end
object YInBtn: TBitBtn object YInBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -203,7 +203,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 1 ImageIndex = 1
OnClick = YInBtnClick OnClick = YInBtnClick
Spacing = 0 Spacing = 0
TabOrder = 8 TabOrder = 4
end end
object YOutBtn: TBitBtn object YOutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -219,7 +219,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 0 ImageIndex = 0
OnClick = YOutBtnClick OnClick = YOutBtnClick
Spacing = 0 Spacing = 0
TabOrder = 9 TabOrder = 5
end end
object GroupInBtn: TBitBtn object GroupInBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -235,7 +235,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 1 ImageIndex = 1
OnClick = GroupInBtnClick OnClick = GroupInBtnClick
Spacing = 0 Spacing = 0
TabOrder = 10 TabOrder = 7
end end
object GroupOutBtn: TBitBtn object GroupOutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@ -252,7 +252,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 0 ImageIndex = 0
OnClick = GroupOutBtnClick OnClick = GroupOutBtnClick
Spacing = 0 Spacing = 0
TabOrder = 11 TabOrder = 8
end end
object OptionsGroup: TGroupBox object OptionsGroup: TGroupBox
AnchorSideLeft.Control = GroupOutBtn AnchorSideLeft.Control = GroupOutBtn
@ -272,7 +272,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ChildSizing.TopBottomSpacing = 2 ChildSizing.TopBottomSpacing = 2
ClientHeight = 29 ClientHeight = 29
ClientWidth = 178 ClientWidth = 178
TabOrder = 12 TabOrder = 10
object LinesChk: TCheckBox object LinesChk: TCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 12
@ -312,7 +312,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 13 TabOrder = 3
Text = 'XEdit' Text = 'XEdit'
end end
object Label3: TLabel object Label3: TLabel
@ -342,7 +342,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 14 TabOrder = 6
Text = 'YEdit' Text = 'YEdit'
end end
object Label4: TLabel object Label4: TLabel
@ -372,7 +372,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 15 TabOrder = 9
Text = 'GroupEdit' Text = 'GroupEdit'
end end
end end

View File

@ -57,6 +57,7 @@ const
constructor TReportFrame.Create(AOwner: TComponent); constructor TReportFrame.Create(AOwner: TComponent);
begin begin
Name := '';
inherited; inherited;
ReportPanel.Color := ReportMemo.Color; ReportPanel.Color := ReportMemo.Color;
UpdateBtnStates; UpdateBtnStates;