You've already forked lazarus-ccr
LazStats: Refactor BartlettTestUnit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7373 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -1,11 +1,11 @@
|
|||||||
object BartlettTestForm: TBartlettTestForm
|
object BartlettTestForm: TBartlettTestForm
|
||||||
Left = 474
|
Left = 474
|
||||||
Height = 374
|
Height = 394
|
||||||
Top = 304
|
Top = 304
|
||||||
Width = 411
|
Width = 411
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Bartlett Test of Sphericity'
|
Caption = 'Bartlett Test of Sphericity'
|
||||||
ClientHeight = 374
|
ClientHeight = 394
|
||||||
ClientWidth = 411
|
ClientWidth = 411
|
||||||
OnActivate = FormActivate
|
OnActivate = FormActivate
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
@ -13,123 +13,78 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
Position = poMainFormCenter
|
Position = poMainFormCenter
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideRight.Control = CancelBtn
|
|
||||||
AnchorSideBottom.Control = Owner
|
|
||||||
AnchorSideBottom.Side = asrBottom
|
|
||||||
Left = 106
|
|
||||||
Height = 25
|
|
||||||
Top = 341
|
|
||||||
Width = 54
|
|
||||||
Anchors = [akRight, akBottom]
|
|
||||||
AutoSize = True
|
|
||||||
BorderSpacing.Left = 12
|
|
||||||
BorderSpacing.Top = 8
|
|
||||||
BorderSpacing.Right = 12
|
|
||||||
BorderSpacing.Bottom = 8
|
|
||||||
Caption = 'Reset'
|
|
||||||
OnClick = ResetBtnClick
|
|
||||||
TabOrder = 3
|
|
||||||
end
|
|
||||||
object CancelBtn: TButton
|
|
||||||
AnchorSideRight.Control = ComputeBtn
|
AnchorSideRight.Control = ComputeBtn
|
||||||
AnchorSideBottom.Control = Owner
|
AnchorSideBottom.Control = Owner
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 172
|
Left = 202
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 341
|
Top = 361
|
||||||
Width = 62
|
Width = 54
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 12
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Cancel = True
|
Caption = 'Reset'
|
||||||
Caption = 'Cancel'
|
OnClick = ResetBtnClick
|
||||||
ModalResult = 2
|
TabOrder = 2
|
||||||
TabOrder = 4
|
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideRight.Control = ReturnBtn
|
AnchorSideRight.Control = CloseBtn
|
||||||
AnchorSideBottom.Control = Owner
|
AnchorSideBottom.Control = Owner
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 246
|
Left = 264
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 341
|
Top = 361
|
||||||
Width = 76
|
Width = 76
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 12
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 5
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object HelpBtn: TButton
|
object HelpBtn: TButton
|
||||||
Tag = 119
|
Tag = 119
|
||||||
AnchorSideRight.Control = ResetBtn
|
AnchorSideRight.Control = ResetBtn
|
||||||
AnchorSideBottom.Control = Owner
|
AnchorSideBottom.Control = Owner
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 43
|
Left = 143
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 341
|
Top = 361
|
||||||
Width = 51
|
Width = 51
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 16
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Help'
|
Caption = 'Help'
|
||||||
OnClick = HelpBtnClick
|
OnClick = HelpBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object Label5: TLabel
|
object CloseBtn: TButton
|
||||||
AnchorSideLeft.Control = Owner
|
|
||||||
AnchorSideTop.Control = DFEdit
|
|
||||||
AnchorSideTop.Side = asrCenter
|
|
||||||
Left = 8
|
|
||||||
Height = 15
|
|
||||||
Top = 65
|
|
||||||
Width = 88
|
|
||||||
BorderSpacing.Left = 8
|
|
||||||
Caption = 'Deg. Freedom = '
|
|
||||||
ParentColor = False
|
|
||||||
end
|
|
||||||
object DFEdit: TEdit
|
|
||||||
AnchorSideLeft.Control = Label5
|
|
||||||
AnchorSideLeft.Side = asrBottom
|
|
||||||
AnchorSideTop.Control = Memo1
|
|
||||||
AnchorSideTop.Side = asrBottom
|
|
||||||
Left = 104
|
|
||||||
Height = 23
|
|
||||||
Top = 61
|
|
||||||
Width = 40
|
|
||||||
BorderSpacing.Left = 8
|
|
||||||
BorderSpacing.Top = 8
|
|
||||||
TabOrder = 0
|
|
||||||
Text = 'DFEdit'
|
|
||||||
end
|
|
||||||
object ReturnBtn: TButton
|
|
||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = Owner
|
AnchorSideBottom.Control = Owner
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 334
|
Left = 348
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 341
|
Top = 361
|
||||||
Width = 61
|
Width = 55
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 12
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 16
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Close'
|
||||||
ModalResult = 1
|
ModalResult = 11
|
||||||
TabOrder = 6
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Memo1: TLabel
|
object Memo1: TLabel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -152,32 +107,32 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = ReturnBtn
|
AnchorSideBottom.Control = CloseBtn
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 8
|
Height = 8
|
||||||
Top = 325
|
Top = 345
|
||||||
Width = 411
|
Width = 411
|
||||||
Anchors = [akLeft, akRight, akBottom]
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
Shape = bsBottomLine
|
Shape = bsBottomLine
|
||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideTop.Control = DFEdit
|
AnchorSideTop.Control = Memo1
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = Bevel1
|
AnchorSideBottom.Control = Bevel1
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 241
|
Height = 292
|
||||||
Top = 84
|
Top = 53
|
||||||
Width = 411
|
Width = 411
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 241
|
ClientHeight = 292
|
||||||
ClientWidth = 411
|
ClientWidth = 411
|
||||||
Constraints.MinHeight = 240
|
Constraints.MinHeight = 240
|
||||||
TabOrder = 1
|
TabOrder = 0
|
||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = Panel1
|
||||||
Left = 8
|
Left = 8
|
||||||
@ -195,7 +150,7 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
AnchorSideRight.Control = AllBtn
|
AnchorSideRight.Control = AllBtn
|
||||||
AnchorSideBottom.Control = ChiSqrEdit
|
AnchorSideBottom.Control = ChiSqrEdit
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 185
|
Height = 198
|
||||||
Top = 25
|
Top = 25
|
||||||
Width = 166
|
Width = 166
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
@ -205,6 +160,7 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
MultiSelect = True
|
MultiSelect = True
|
||||||
|
OnSelectionChange = VarListSelectionChange
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
@ -224,17 +180,19 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = Panel1
|
AnchorSideRight.Control = Panel1
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = ProbEdit
|
AnchorSideBottom.Control = VarList
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 236
|
Left = 236
|
||||||
Height = 185
|
Height = 198
|
||||||
Top = 25
|
Top = 25
|
||||||
Width = 167
|
Width = 167
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 2
|
BorderSpacing.Top = 2
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
|
MultiSelect = True
|
||||||
|
OnSelectionChange = VarListSelectionChange
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object InBtn: TBitBtn
|
object InBtn: TBitBtn
|
||||||
@ -287,26 +245,28 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
AnchorSideTop.Control = ChiSqrEdit
|
AnchorSideTop.Control = ChiSqrEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = ChiSqrEdit
|
AnchorSideRight.Control = ChiSqrEdit
|
||||||
Left = 19
|
Left = 33
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 222
|
Top = 235
|
||||||
Width = 67
|
Width = 60
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
Caption = 'Chisquare = '
|
Caption = 'Chi Square:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ChiSqrEdit: TEdit
|
object ChiSqrEdit: TEdit
|
||||||
|
AnchorSideLeft.Control = DFEdit
|
||||||
AnchorSideRight.Control = VarList
|
AnchorSideRight.Control = VarList
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = Panel1
|
AnchorSideBottom.Control = Panel1
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 94
|
Left = 101
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 218
|
Top = 231
|
||||||
Width = 80
|
Width = 73
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akLeft, akRight]
|
||||||
|
ReadOnly = True
|
||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
Text = 'ChiSqrEdit'
|
Text = 'ChiSqrEdit'
|
||||||
end
|
end
|
||||||
@ -314,27 +274,62 @@ object BartlettTestForm: TBartlettTestForm
|
|||||||
AnchorSideTop.Control = ProbEdit
|
AnchorSideTop.Control = ProbEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = ProbEdit
|
AnchorSideRight.Control = ProbEdit
|
||||||
Left = 252
|
Left = 255
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 222
|
Top = 235
|
||||||
Width = 71
|
Width = 60
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Probability = '
|
BorderSpacing.Right = 8
|
||||||
|
Caption = 'Probability:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbEdit: TEdit
|
object ProbEdit: TEdit
|
||||||
|
AnchorSideTop.Control = ChiSqrEdit
|
||||||
AnchorSideRight.Control = SelList
|
AnchorSideRight.Control = SelList
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = Panel1
|
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 323
|
Left = 323
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 218
|
Top = 231
|
||||||
Width = 80
|
Width = 80
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akTop, akRight]
|
||||||
|
ReadOnly = True
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
Text = 'ProbEdit'
|
Text = 'ProbEdit'
|
||||||
end
|
end
|
||||||
|
object Label5: TLabel
|
||||||
|
AnchorSideLeft.Control = VarList
|
||||||
|
AnchorSideTop.Control = DFEdit
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
AnchorSideRight.Control = DFEdit
|
||||||
|
Left = 16
|
||||||
|
Height = 15
|
||||||
|
Top = 266
|
||||||
|
Width = 77
|
||||||
|
Alignment = taRightJustify
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
Caption = 'Deg. Freedom:'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object DFEdit: TEdit
|
||||||
|
AnchorSideLeft.Control = Label5
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ChiSqrEdit
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = ChiSqrEdit
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 101
|
||||||
|
Height = 23
|
||||||
|
Top = 262
|
||||||
|
Width = 73
|
||||||
|
Alignment = taRightJustify
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
BorderSpacing.Top = 8
|
||||||
|
ReadOnly = True
|
||||||
|
TabOrder = 7
|
||||||
|
Text = 'DFEdit'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,8 +19,7 @@ type
|
|||||||
Bevel1: TBevel;
|
Bevel1: TBevel;
|
||||||
Memo1: TLabel;
|
Memo1: TLabel;
|
||||||
Panel1: TPanel;
|
Panel1: TPanel;
|
||||||
ReturnBtn: TButton;
|
CloseBtn: TButton;
|
||||||
CancelBtn: TButton;
|
|
||||||
ChiSqrEdit: TEdit;
|
ChiSqrEdit: TEdit;
|
||||||
DFEdit: TEdit;
|
DFEdit: TEdit;
|
||||||
Label5: TLabel;
|
Label5: TLabel;
|
||||||
@ -44,9 +43,11 @@ type
|
|||||||
procedure InBtnClick(Sender: TObject);
|
procedure InBtnClick(Sender: TObject);
|
||||||
procedure OutBtnClick(Sender: TObject);
|
procedure OutBtnClick(Sender: TObject);
|
||||||
procedure ResetBtnClick(Sender: TObject);
|
procedure ResetBtnClick(Sender: TObject);
|
||||||
|
procedure VarListSelectionChange(Sender: TObject; User: boolean);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
FAutoSized: Boolean;
|
FAutoSized: Boolean;
|
||||||
|
procedure UpdateBtnStates;
|
||||||
public
|
public
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
end;
|
end;
|
||||||
@ -57,141 +58,144 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math;
|
Math, Utils;
|
||||||
|
|
||||||
{ TBartlettTestForm }
|
{ TBartlettTestForm }
|
||||||
|
|
||||||
procedure TBartlettTestForm.ResetBtnClick(Sender: TObject);
|
procedure TBartlettTestForm.ResetBtnClick(Sender: TObject);
|
||||||
VAR i :integer;
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
ChiSqrEdit.Text := '';
|
ChiSqrEdit.Text := '';
|
||||||
ProbEdit.Text := '';
|
ProbEdit.Text := '';
|
||||||
DFEdit.Text := '';
|
DFEdit.Text := '';
|
||||||
InBtn.Enabled := true;
|
VarList.Clear;
|
||||||
OutBtn.Enabled := false;
|
SelList.Clear;
|
||||||
VarList.Clear;
|
for i := 1 to NoVariables do
|
||||||
SelList.Clear;
|
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||||
for i := 1 to NoVariables do
|
UpdateBtnStates;
|
||||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBartlettTestForm.InBtnClick(Sender: TObject);
|
procedure TBartlettTestForm.InBtnClick(Sender: TObject);
|
||||||
VAR i, index : integer;
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
index := VarList.Items.Count;
|
i := 0;
|
||||||
i := 0;
|
while i < VarList.Items.Count do
|
||||||
while i < index do
|
begin
|
||||||
begin
|
if VarList.Selected[i] then
|
||||||
if (VarList.Selected[i]) then
|
begin
|
||||||
begin
|
SelList.Items.Add(VarList.Items[i]);
|
||||||
SelList.Items.Add(VarList.Items.Strings[i]);
|
VarList.Items.Delete(i);
|
||||||
VarList.Items.Delete(i);
|
i := 0;
|
||||||
index := index - 1;
|
end else
|
||||||
i := 0;
|
inc(i);
|
||||||
end
|
end;
|
||||||
else i := i + 1;
|
UpdateBtnStates;
|
||||||
end;
|
|
||||||
OutBtn.Enabled := true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBartlettTestForm.AllBtnClick(Sender: TObject);
|
procedure TBartlettTestForm.AllBtnClick(Sender: TObject);
|
||||||
VAR i : integer;
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
for i := 0 to VarList.Items.Count-1 do
|
for i := 0 to VarList.Items.Count-1 do
|
||||||
SelList.Items.Add(VarList.Items.Strings[i]);
|
SelList.Items.Add(VarList.Items[i]);
|
||||||
VarList.Clear;
|
VarList.Clear;
|
||||||
OutBtn.Enabled := true;
|
UpdateBtnStates;
|
||||||
InBtn.Enabled := false;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBartlettTestForm.ComputeBtnClick(Sender: TObject);
|
procedure TBartlettTestForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
VAR
|
||||||
matrix, temp, eigenvectors : DblDyneMat;
|
matrix: DblDyneMat;
|
||||||
eigenvalues, means, variances, stddevs : DblDyneVec;
|
means, variances, stddevs: DblDyneVec;
|
||||||
determinant, chisquare, probability, natlogp : double;
|
determinant, chisquare, probability: double;
|
||||||
i, j, df, p, ncases, colno : integer;
|
i, j, df, p, ncases, colno: integer;
|
||||||
aline, strvalue, ytitle, title, probvalue, chivalue : string;
|
aline, strvalue, title, probvalue, chivalue: string;
|
||||||
ColNoSelected : IntDyneVec;
|
ColNoSelected: IntDyneVec;
|
||||||
dblvalue : double;
|
dblvalue: double;
|
||||||
DataGrid : DblDyneMat;
|
DataGrid: DblDyneMat;
|
||||||
RowLabels, ColLabels : StrDyneVec;
|
RowLabels, ColLabels: StrDyneVec;
|
||||||
errorcode : boolean;
|
errorcode: boolean;
|
||||||
|
lReport: TStrings;
|
||||||
begin
|
begin
|
||||||
p := SelList.Count;
|
p := SelList.Count;
|
||||||
SetLength(matrix,p+1,p+1);
|
SetLength(matrix, p+1, p+1);
|
||||||
SetLength(temp,p+1,p+1);
|
SetLength(means, p+1);
|
||||||
SetLength(eigenvectors,p,p);
|
SetLength(stddevs, p+1);
|
||||||
SetLength(eigenvalues,p);
|
SetLength(variances, p+1);
|
||||||
SetLength(means,p+1);
|
SetLength(ColNoSelected, p+1);
|
||||||
SetLength(stddevs,p+1);
|
SetLength(DataGrid, NoCases, p+1);
|
||||||
SetLength(variances,p+1);
|
SetLength(RowLabels, p+1);
|
||||||
SetLength(ColNoSelected,p+1);
|
SetLength(ColLabels, p+1);
|
||||||
SetLength(DataGrid,NoCases,p+1);
|
|
||||||
SetLength(RowLabels,p+1);
|
|
||||||
SetLength(ColLabels,p+1);
|
|
||||||
|
|
||||||
for j := 0 to p-1 do
|
for j := 0 to p-1 do
|
||||||
begin
|
begin
|
||||||
for i := 1 to NoVariables do
|
for i := 1 to NoVariables do
|
||||||
begin
|
begin
|
||||||
if SelList.Items.Strings[j] = OS3MainFrm.DataGrid.Cells[i,0] then
|
if SelList.Items.Strings[j] = OS3MainFrm.DataGrid.Cells[i,0] then
|
||||||
begin
|
begin
|
||||||
ColNoSelected[j] := i;
|
ColNoSelected[j] := i;
|
||||||
RowLabels[j] := OS3MainFrm.DataGrid.Cells[i,0];
|
RowLabels[j] := OS3MainFrm.DataGrid.Cells[i,0];
|
||||||
ColLabels[j] := OS3MainFrm.DataGrid.Cells[i,0];
|
ColLabels[j] := OS3MainFrm.DataGrid.Cells[i,0];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ncases := 0;
|
|
||||||
ytitle := 'Variable';
|
|
||||||
errorcode := false;
|
|
||||||
|
|
||||||
// get data into the datagrid
|
ncases := 0;
|
||||||
for j := 0 to p-1 do
|
errorcode := false;
|
||||||
begin
|
|
||||||
for i := 1 to NoCases do
|
// get data into the datagrid
|
||||||
begin
|
for j := 0 to p-1 do
|
||||||
if not GoodRecord(i,p,ColNoSelected) then continue;
|
begin
|
||||||
colno := ColNoSelected[j];
|
for i := 1 to NoCases do
|
||||||
dblvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[colno,i]);
|
begin
|
||||||
DataGrid[i-1,j] := dblvalue;
|
if not GoodRecord(i, p, ColNoSelected) then continue;
|
||||||
ncases := ncases + 1;
|
colno := ColNoSelected[j];
|
||||||
end;
|
dblvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[colno, i]);
|
||||||
end;
|
DataGrid[i-1,j] := dblvalue;
|
||||||
OutputFrm.RichEdit.Clear;
|
ncases := ncases + 1;
|
||||||
ncases := 0;
|
end;
|
||||||
Correlations(p,ColNoSelected,matrix,means,variances,stddevs,errorcode,ncases);
|
end;
|
||||||
title := 'CORRELATION MATRIX';
|
|
||||||
MAT_PRINT(matrix,p,p,title,RowLabels,ColLabels,ncases);
|
lReport := TStringList.Create;
|
||||||
OutputFrm.RichEdit.Lines.Add('');
|
try
|
||||||
DETERM(matrix,p,p,determinant,errorcode);
|
ncases := 0;
|
||||||
strvalue := format('Determinant of matrix = %8.3f',[determinant]);
|
Correlations(p, ColNoSelected, matrix, means, variances, stddevs, errorcode, ncases);
|
||||||
OutputFrm.RichEdit.Lines.Add(strvalue);
|
|
||||||
OutputFrm.RichEdit.Lines.Add('');
|
title := 'CORRELATION MATRIX';
|
||||||
natlogp := ln(1.0 / p);
|
MatPrint(matrix, p, p, title, RowLabels, ColLabels, ncases, lReport);
|
||||||
chisquare := -((ncases-1) - (2.0*p-5)/6) * ln(determinant);
|
lReport.Add('');
|
||||||
df := ((p * p) - p) div 2;
|
|
||||||
probability := chisquaredprob(chisquare,df);
|
Determ(matrix, p, p, determinant, errorcode);
|
||||||
chivalue := format('%8.3f',[chisquare]);
|
lReport.Add('Determinant of matrix: %8.3f', [determinant]);
|
||||||
probvalue := format('%8.3f',[1.0-probability]);
|
lReport.Add('');
|
||||||
chisqrEdit.Text := chivalue;
|
|
||||||
ProbEdit.Text := probvalue;
|
chisquare := -((ncases-1) - (2.0*p-5)/6) * ln(determinant);
|
||||||
DFEdit.Text := IntToStr(df);
|
df := ((p * p) - p) div 2;
|
||||||
aline := format('chisquare = %s, D.F. = %D, Proabability greater value = %s',
|
probability := chisquaredprob(chisquare,df);
|
||||||
[chivalue,df,probvalue]);
|
|
||||||
OutputFrm.RichEdit.Lines.Add(aline);
|
//chivalue := format('%8.3f',[chisquare]);
|
||||||
ColLabels := nil;
|
ChiSqrEdit.Text := Format('%.3f', [chisquare]);;
|
||||||
RowLabels := nil;
|
ProbEdit.Text := Format('%.3f', [1.0-probability]);
|
||||||
DataGrid := nil;
|
DFEdit.Text := IntToStr(df);
|
||||||
ColNoSelected := nil;
|
|
||||||
variances := nil;
|
lReport.Add('ChiSquare: %8.3f', [chisquare]);
|
||||||
stddevs := nil;
|
lReport.Add('Degrees of Freedom: %8d', [df]);
|
||||||
means := nil;
|
lReport.Add('Probability > value: %8.3f', [1.0 - probability]);
|
||||||
eigenvalues := nil;
|
|
||||||
eigenvectors := nil;
|
DisplayReport(lReport);
|
||||||
temp := nil;
|
|
||||||
matrix := nil;
|
finally
|
||||||
OutputFrm.ShowModal;
|
lReport.Free;
|
||||||
|
ColLabels := nil;
|
||||||
|
RowLabels := nil;
|
||||||
|
DataGrid := nil;
|
||||||
|
ColNoSelected := nil;
|
||||||
|
variances := nil;
|
||||||
|
stddevs := nil;
|
||||||
|
means := nil;
|
||||||
|
matrix := nil;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBartlettTestForm.FormActivate(Sender: TObject);
|
procedure TBartlettTestForm.FormActivate(Sender: TObject);
|
||||||
@ -201,12 +205,12 @@ begin
|
|||||||
if FAutoSized then
|
if FAutoSized then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
w := MaxValue([HelpBtn.Width, ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
|
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
|
||||||
HelpBtn.Constraints.MinWidth := w;
|
HelpBtn.Constraints.MinWidth := w;
|
||||||
ResetBtn.Constraints.MinWidth := w;
|
ResetBtn.Constraints.MinWidth := w;
|
||||||
CancelBtn.Constraints.MinWidth := w;
|
|
||||||
ComputeBtn.Constraints.MinWidth := w;
|
ComputeBtn.Constraints.MinWidth := w;
|
||||||
ReturnBtn.Constraints.MinWidth := w;
|
CloseBtn.Constraints.MinWidth := w;
|
||||||
|
|
||||||
Constraints.MinHeight := Height;
|
Constraints.MinHeight := Height;
|
||||||
Constraints.MinWidth := Width;
|
Constraints.MinWidth := Width;
|
||||||
|
|
||||||
@ -216,8 +220,6 @@ end;
|
|||||||
procedure TBartlettTestForm.FormCreate(Sender: TObject);
|
procedure TBartlettTestForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Assert(OS3MainFrm <> nil);
|
Assert(OS3MainFrm <> nil);
|
||||||
if OutputFrm = nil then
|
|
||||||
Application.CreateForm(TOutputFrm, OutputFrm);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBartlettTestForm.HelpBtnClick(Sender: TObject);
|
procedure TBartlettTestForm.HelpBtnClick(Sender: TObject);
|
||||||
@ -228,16 +230,37 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBartlettTestForm.OutBtnClick(Sender: TObject);
|
procedure TBartlettTestForm.OutBtnClick(Sender: TObject);
|
||||||
VAR index : integer;
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
index := SelList.ItemIndex;
|
i := 0;
|
||||||
VarList.Items.Add(SelList.Items.Strings[index]);
|
while i < SelList.Items.Count do
|
||||||
SelList.Items.Delete(index);
|
begin
|
||||||
InBtn.Enabled := true;
|
if SelList.Selected[i] then
|
||||||
if SelList.Items.Count = 0 then OutBtn.Enabled := false;
|
begin
|
||||||
|
VarList.Items.Add(SelList.Items[i]);
|
||||||
|
SelList.Items.Delete(i);
|
||||||
|
i := 0;
|
||||||
|
end else
|
||||||
|
i := i + 1;
|
||||||
|
end;
|
||||||
|
UpdateBtnStates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBartlettTestForm.UpdateBtnStates;
|
||||||
|
begin
|
||||||
|
InBtn.Enabled := AnySelected(VarList);
|
||||||
|
OutBtn.Enabled := AnySelected(SelList);
|
||||||
|
AllBtn.Enabled := VarList.Items.Count > 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBartlettTestForm.VarListSelectionChange(Sender: TObject;
|
||||||
|
User: boolean);
|
||||||
|
begin
|
||||||
|
UpdateBtnStates;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$I bartletttestunit.lrs}
|
{$I bartletttestunit.lrs}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user