LazStats: Inherit form of ChiSqrUnit from TBasicStatsReportForm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7803 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-25 18:33:42 +00:00
parent 832551eb29
commit f60e4c0a67
2 changed files with 561 additions and 558 deletions

View File

@ -1,109 +1,65 @@
object ChiSqrFrm: TChiSqrFrm inherited ChiSqrFrm: TChiSqrFrm
Left = 425 Left = 425
Height = 566 Height = 503
Top = 216 Top = 216
Width = 474 Width = 1014
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/ContingencyChi-Square.htm' HelpKeyword = 'html/ContingencyChi-Square.htm'
AutoSize = True
Caption = 'Contingency Chi Squared' Caption = 'Contingency Chi Squared'
ClientHeight = 566 ClientHeight = 503
ClientWidth = 474 ClientWidth = 1014
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 487
OnShow = FormShow Width = 424
Position = poMainFormCenter ClientHeight = 487
LCLVersion = '2.1.0.0' ClientWidth = 424
object Label1: TLabel inherited CloseBtn: TButton
AnchorSideLeft.Control = Owner Left = 369
AnchorSideTop.Control = InputGrp Top = 462
AnchorSideTop.Side = asrBottom TabOrder = 16
Left = 8
Height = 15
Top = 109
Width = 97
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Available Variables'
ParentColor = False
end end
object Label2: TLabel inherited ComputeBtn: TButton
AnchorSideLeft.Control = RowEdit Left = 285
AnchorSideBottom.Control = RowEdit Top = 462
Left = 265 TabOrder = 15
Height = 15
Top = 134
Width = 67
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Row Variable'
ParentColor = False
end end
object Label3: TLabel inherited ResetBtn: TButton
AnchorSideLeft.Control = ColEdit Left = 223
AnchorSideBottom.Control = ColEdit Top = 462
Left = 265 TabOrder = 14
Height = 15
Top = 214
Width = 87
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Column Variable'
ParentColor = False
end end
object AnalyzeLabel: TLabel inherited HelpBtn: TButton
AnchorSideLeft.Control = DepEdit Left = 164
AnchorSideBottom.Control = DepEdit Top = 462
Left = 265 TabOrder = 13
Height = 15
Top = 294
Width = 99
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable to Analyze'
ParentColor = False
end end
object NCasesLabel: TLabel inherited ButtonBevel: TBevel
AnchorSideLeft.Control = Owner Top = 446
AnchorSideTop.Control = NCasesEdit Width = 424
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NCasesEdit
Left = 8
Height = 15
Top = 498
Width = 97
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Total No. of Cases:'
ParentColor = False
end end
object InputGrp: TRadioGroup object InputGrp: TRadioGroup[5]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Owner AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 0
Height = 93 Height = 89
Top = 8 Top = 0
Width = 458 Width = 424
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Input Options' Caption = 'Input Options'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 73 ClientHeight = 69
ClientWidth = 454 ClientWidth = 420
Items.Strings = ( Items.Strings = (
'Count vases classified by row and column vectors in the data grid' 'Count vases classified by row and column vectors in the data grid'
'Use frequencies recorded in the data grid for row and column variables' 'Use frequencies recorded in the data grid for row and column variables'
@ -112,45 +68,109 @@ object ChiSqrFrm: TChiSqrFrm
OnClick = InputGrpClick OnClick = InputGrpClick
TabOrder = 0 TabOrder = 0
end end
object VarList: TListBox object Label1: TLabel[6]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = InputGrp
AnchorSideTop.Side = asrBottom
Left = 0
Height = 15
Top = 97
Width = 97
BorderSpacing.Top = 8
Caption = 'Available Variables'
ParentColor = False
end
object Label2: TLabel[7]
AnchorSideLeft.Control = RowEdit
AnchorSideBottom.Control = RowEdit
Left = 233
Height = 15
Top = 118
Width = 67
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Row Variable'
ParentColor = False
end
object Label3: TLabel[8]
AnchorSideLeft.Control = ColEdit
AnchorSideBottom.Control = ColEdit
Left = 233
Height = 15
Top = 194
Width = 87
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Column Variable'
ParentColor = False
end
object AnalyzeLabel: TLabel[9]
AnchorSideLeft.Control = DepEdit
AnchorSideBottom.Control = DepEdit
Left = 233
Height = 15
Top = 270
Width = 99
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable to Analyze'
ParentColor = False
end
object NCasesLabel: TLabel[10]
AnchorSideLeft.Control = DepOut
AnchorSideTop.Control = NCasesEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NCasesEdit
Left = 199
Height = 15
Top = 342
Width = 97
BorderSpacing.Top = 12
BorderSpacing.Right = 8
Caption = 'Total No. of Cases:'
ParentColor = False
end
object VarList: TListBox[11]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = RowIn AnchorSideRight.Control = RowIn
AnchorSideBottom.Control = NCasesEdit AnchorSideBottom.Control = OptionsGroup
Left = 8 Left = 0
Height = 360 Height = 235
Top = 126 Top = 114
Width = 213 Width = 191
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 8
ItemHeight = 0 ItemHeight = 0
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 1 TabOrder = 1
end end
object RowIn: TBitBtn object RowIn: TBitBtn[12]
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
Left = 229 Left = 199
Height = 28 Height = 26
Top = 126 Top = 114
Width = 28 Width = 26
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
OnClick = RowInClick OnClick = RowInClick
Spacing = 0 Spacing = 0
TabOrder = 2 TabOrder = 2
end end
object RowOut: TBitBtn object RowOut: TBitBtn[13]
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowIn AnchorSideTop.Control = RowIn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 229 Left = 199
Height = 28 Height = 26
Top = 158 Top = 144
Width = 28 Width = 26
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
@ -158,14 +178,15 @@ object ChiSqrFrm: TChiSqrFrm
Spacing = 0 Spacing = 0
TabOrder = 3 TabOrder = 3
end end
object ColIn: TBitBtn object ColIn: TBitBtn[14]
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowOut AnchorSideTop.Control = RowOut
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 229 Left = 199
Height = 28 Height = 26
Top = 206 Top = 190
Width = 28 Width = 26
BorderSpacing.Top = 20 BorderSpacing.Top = 20
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
@ -173,14 +194,15 @@ object ChiSqrFrm: TChiSqrFrm
Spacing = 0 Spacing = 0
TabOrder = 5 TabOrder = 5
end end
object ColOut: TBitBtn object ColOut: TBitBtn[15]
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColIn AnchorSideTop.Control = ColIn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 229 Left = 199
Height = 28 Height = 26
Top = 238 Top = 220
Width = 28 Width = 26
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
@ -188,14 +210,15 @@ object ChiSqrFrm: TChiSqrFrm
Spacing = 0 Spacing = 0
TabOrder = 6 TabOrder = 6
end end
object DepIn: TBitBtn object DepIn: TBitBtn[16]
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColOut AnchorSideTop.Control = ColOut
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 229 Left = 199
Height = 28 Height = 26
Top = 286 Top = 266
Width = 28 Width = 26
BorderSpacing.Top = 20 BorderSpacing.Top = 20
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
@ -203,14 +226,15 @@ object ChiSqrFrm: TChiSqrFrm
Spacing = 0 Spacing = 0
TabOrder = 8 TabOrder = 8
end end
object DepOut: TBitBtn object DepOut: TBitBtn[17]
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepIn AnchorSideTop.Control = DepIn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 229 Left = 199
Height = 28 Height = 26
Top = 318 Top = 296
Width = 28 Width = 26
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
@ -218,101 +242,99 @@ object ChiSqrFrm: TChiSqrFrm
Spacing = 0 Spacing = 0
TabOrder = 9 TabOrder = 9
end end
object RowEdit: TEdit object RowEdit: TEdit[18]
AnchorSideLeft.Control = RowOut AnchorSideLeft.Control = RowOut
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = RowOut AnchorSideBottom.Control = RowOut
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 265 Left = 233
Height = 23 Height = 23
Top = 151 Top = 135
Width = 201 Width = 191
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 4 TabOrder = 4
Text = 'RowEdit' Text = 'RowEdit'
end end
object ColEdit: TEdit object ColEdit: TEdit[19]
AnchorSideLeft.Control = ColIn AnchorSideLeft.Control = ColIn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ColOut AnchorSideBottom.Control = ColOut
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 265 Left = 233
Height = 23 Height = 23
Top = 231 Top = 211
Width = 201 Width = 191
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 7 TabOrder = 7
Text = 'ColEdit' Text = 'ColEdit'
end end
object DepEdit: TEdit object DepEdit: TEdit[20]
AnchorSideLeft.Control = DepIn AnchorSideLeft.Control = DepIn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOut AnchorSideBottom.Control = DepOut
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 265 Left = 233
Height = 23 Height = 23
Top = 311 Top = 287
Width = 201 Width = 191
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 10 TabOrder = 10
Text = 'DepEdit' Text = 'DepEdit'
end end
object NCasesEdit: TEdit object NCasesEdit: TEdit[21]
AnchorSideLeft.Control = NCasesLabel AnchorSideLeft.Control = NCasesLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OptionsGroup AnchorSideTop.Control = DepOut
AnchorSideBottom.Control = Bevel1 AnchorSideTop.Side = asrBottom
Left = 113 AnchorSideBottom.Control = ButtonBevel
Left = 304
Height = 23 Height = 23
Top = 494 Top = 338
Width = 69 Width = 69
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akLeft, akBottom] BorderSpacing.Top = 16
BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 11 TabOrder = 11
Text = 'NCasesEdit' Text = 'NCasesEdit'
end end
object OptionsGroup: TGroupBox object OptionsGroup: TGroupBox[22]
AnchorSideTop.Control = DepOut AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 229 AnchorSideBottom.Control = ButtonBevel
Height = 152 Left = 0
Top = 362 Height = 89
Width = 237 Top = 357
Anchors = [akTop, akRight] Width = 421
Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Top = 16 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Output Options:' Caption = 'Output Options:'
ChildSizing.LeftRightSpacing = 12 ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 4 ChildSizing.TopBottomSpacing = 4
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 2 ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 2
ClientHeight = 132 ClientHeight = 69
ClientWidth = 233 ClientWidth = 417
TabOrder = 12 TabOrder = 12
object ObsChk: TCheckBox object ObsChk: TCheckBox
Left = 12 Left = 12
@ -323,26 +345,26 @@ object ChiSqrFrm: TChiSqrFrm
TabOrder = 0 TabOrder = 0
end end
object ExpChk: TCheckBox object ExpChk: TCheckBox
Left = 12 Left = 227
Height = 19 Height = 19
Top = 25 Top = 4
Width = 209 Width = 178
Caption = 'Show Expected Frequencies' Caption = 'Show Expected Frequencies'
TabOrder = 1 TabOrder = 1
end end
object PropsChk: TCheckBox object PropsChk: TCheckBox
Left = 12 Left = 12
Height = 19 Height = 19
Top = 46 Top = 25
Width = 209 Width = 209
Caption = 'Show Row and Column Proportions' Caption = 'Show Row and Column Proportions'
TabOrder = 2 TabOrder = 2
end end
object CellChiChk: TCheckBox object CellChiChk: TCheckBox
Left = 12 Left = 227
Height = 19 Height = 19
Top = 67 Top = 25
Width = 209 Width = 178
Caption = 'Show Cell Chi-Squared Values' Caption = 'Show Cell Chi-Squared Values'
TabOrder = 3 TabOrder = 3
end end
@ -350,81 +372,23 @@ object ChiSqrFrm: TChiSqrFrm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 12
Height = 19 Height = 19
Top = 88 Top = 46
Width = 209 Width = 209
Caption = 'Use Yates Correction' Caption = 'Use Yates Correction'
TabOrder = 5
end
object SaveFChk: TCheckBox
Left = 12
Height = 19
Top = 109
Width = 209
Caption = 'Save a File of Frequency Data'
TabOrder = 4 TabOrder = 4
end end
end object SaveFChk: TCheckBox
object ResetBtn: TButton Left = 227
AnchorSideRight.Control = ComputeBtn Height = 19
AnchorSideBottom.Control = Owner Top = 46
AnchorSideBottom.Side = asrBottom Width = 178
Left = 265 Caption = 'Save a File of Frequency Data'
Height = 25 TabOrder = 5
Top = 533 end
Width = 54 end
Anchors = [akRight, akBottom] end
AutoSize = True inherited ParamsSplitter: TSplitter
BorderSpacing.Left = 8 Left = 436
BorderSpacing.Right = 8 Height = 503
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 13
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 327
Height = 25
Top = 533
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 14
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 411
Height = 25
Top = 533
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 15
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 517
Width = 474
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end end
end end

View File

@ -5,20 +5,16 @@ unit ChiSqrUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Buttons, ExtCtrls, StdCtrls, Buttons,
MainUnit, OutputUnit, FunctionsLib, GraphLib, Globals, MatrixLib, MainUnit, FunctionsLib, GraphLib, Globals, MatrixLib, DataProcs,
DataProcs, DictionaryUnit; DictionaryUnit, BasicStatsReportFormUnit;
type type
{ TChiSqrFrm } { TChiSqrFrm }
TChiSqrFrm = class(TForm) TChiSqrFrm = class(TBasicStatsReportForm)
Bevel1: TBevel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
ObsChk: TCheckBox; ObsChk: TCheckBox;
ExpChk: TCheckBox; ExpChk: TCheckBox;
PropsChk: TCheckBox; PropsChk: TCheckBox;
@ -45,23 +41,24 @@ type
VarList: TListBox; VarList: TListBox;
procedure ColInClick(Sender: TObject); procedure ColInClick(Sender: TObject);
procedure ColOutClick(Sender: TObject); procedure ColOutClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure DepInClick(Sender: TObject); procedure DepInClick(Sender: TObject);
procedure DepOutClick(Sender: TObject); procedure DepOutClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure InputGrpClick(Sender: TObject); procedure InputGrpClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure RowInClick(Sender: TObject); procedure RowInClick(Sender: TObject);
procedure RowOutClick(Sender: TObject); procedure RowOutClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean); procedure VarListSelectionChange(Sender: TObject; User: boolean);
private private
{ private declarations }
FAutoSized: Boolean; protected
procedure UpdateBtnStates; procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end; end;
var var
@ -69,62 +66,34 @@ var
implementation implementation
{$R *.lfm}
uses uses
Math; Math;
{ TChiSqrFrm } { TChiSqrFrm }
procedure TChiSqrFrm.ResetBtnClick(Sender: TObject); constructor TChiSqrFrm.Create(AOwner: TComponent);
var
i: integer;
begin begin
VarList.Clear; inherited;
RowEdit.Text := ''; if DictionaryFrm = nil then
ColEdit.Text := ''; Application.CreateForm(TDictionaryFrm, DictionaryFrm);
DepEdit.Text := '';
DepEdit.Enabled := false;
NCasesLabel.Enabled := false;
AnalyzeLabel.Enabled := false;
NCasesEdit.Text := '';
NCasesEdit.Enabled := false;
InputGrp.ItemIndex := 0;
ObsChk.Checked := false;
ExpChk.Checked := false;
PropsChk.Checked := false;
CellChiChk.Checked := false;
SaveFChk.Checked := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end; end;
procedure TChiSqrFrm.RowInClick(Sender: TObject); procedure TChiSqrFrm.AdjustConstraints;
var
index: integer;
begin begin
index := VarList.ItemIndex; inherited;
if (index > -1) and (RowEdit.Text = '') then
begin ParamsPanel.Constraints.MinWidth := MaxValue([
RowEdit.Text := VarList.Items[index]; 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
VarList.Items.Delete(index); OptionsGroup.Width,
end; InputGrp.Width
UpdateBtnStates; ]);
ParamsPanel.Constraints.MinHeight := NCasesEdit.Top + NCasesEdit.Height +
OptionsGroup.BorderSpacing.Top + OptionsGroup.Height +
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
end; end;
procedure TChiSqrFrm.RowOutClick(Sender: TObject);
begin
if RowEdit.Text <> '' then
begin
VarList.Items.Add(RowEdit.Text);
RowEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TChiSqrFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TChiSqrFrm.ColInClick(Sender: TObject); procedure TChiSqrFrm.ColInClick(Sender: TObject);
var var
@ -139,6 +108,7 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TChiSqrFrm.ColOutClick(Sender: TObject); procedure TChiSqrFrm.ColOutClick(Sender: TObject);
begin begin
if ColEdit.Text <> '' then if ColEdit.Text <> '' then
@ -149,15 +119,19 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TChiSqrFrm.ComputeBtnClick(Sender: TObject);
procedure TChiSqrFrm.Compute;
var var
ColNoSelected: IntDyneVec = nil;
Freq: IntDyneMat = nil;
Prop: DblDyneMat = nil;
Expected: DblDyneMat = nil;
CellChi: DblDyneMat = nil;
i, j, RowNo, ColNo, DepNo, MinRow, MaxRow, MinCol, MaxCol : integer; i, j, RowNo, ColNo, DepNo, MinRow, MaxRow, MinCol, MaxCol : integer;
Row, Col, NoSelected, Ncases, Nrows, Ncols, FObs, df : integer; Row, Col, NoSelected, Ncases, Nrows, Ncols, FObs, df : integer;
RowLabels, ColLabels : StrDyneVec; RowLabels, ColLabels : StrDyneVec;
ColNoSelected : IntDyneVec;
cellstring: string; cellstring: string;
Freq : IntDyneMat;
Prop, Expected, CellChi : DblDyneMat;
PObs, ChiSquare, ProbChi, phi, SumX, SumY, VarX, VarY, liklihood : double; PObs, ChiSquare, ProbChi, phi, SumX, SumY, VarX, VarY, liklihood : double;
yates : boolean; yates : boolean;
title : string; title : string;
@ -165,37 +139,6 @@ var
Adjprobchi, CoefCont, CramerV : double; Adjprobchi, CoefCont, CramerV : double;
lReport: TStrings; lReport: TStrings;
begin begin
if RowEdit.Text = '' then
begin
MessageDlg('Row variable not selected.', mtError, [mbOK], 0);
exit;
end;
if ColEdit.Text = '' then
begin
MessageDlg('Column variable not selected.', mtError, [mbOK], 0);
exit;
end;
if DepEdit.Text = '' then
begin
MessageDlg('Variable to analyze is not selected', mtError, [mbOK], 0);
exit;
end;
if InputGrp.ItemIndex = 2 then
begin
if NCasesEdit.Text = '' then
begin
NCasesEdit.SetFocus;
MessageDlg('Total number of cases not selected.', mtError, [mbOk], 0);
exit;
end;
if not TryStrToInt(NCasesEdit.Text, i) then
begin
NCasesEdit.SetFocus;
Messagedlg('Numberical input expected for total number of cases.', mtError, [mbOK], 0);
exit;
end;
end;
SetLength(ColNoSelected, NoVariables); SetLength(ColNoSelected, NoVariables);
yates := false; yates := false;
RowNo := 0; RowNo := 0;
@ -223,7 +166,7 @@ begin
MaxCol := 0; MaxCol := 0;
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if NOT GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
Row := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[RowNo,i]))); Row := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[RowNo,i])));
Col := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNo,i]))); Col := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNo,i])));
if Row > MaxRow then MaxRow := Row; if Row > MaxRow then MaxRow := Row;
@ -466,7 +409,7 @@ begin
lReport.Add(''); lReport.Add('');
end; end;
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
end; end;
@ -525,9 +468,9 @@ begin
Prop := nil; Prop := nil;
Freq := nil; Freq := nil;
ColNoSelected := nil; ColNoSelected := nil;
ResetBtnClick(self);
end; end;
procedure TChiSqrFrm.DepInClick(Sender: TObject); procedure TChiSqrFrm.DepInClick(Sender: TObject);
var var
index: integer; index: integer;
@ -541,6 +484,7 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TChiSqrFrm.DepOutClick(Sender: TObject); procedure TChiSqrFrm.DepOutClick(Sender: TObject);
begin begin
if DepEdit.Text <> '' then if DepEdit.Text <> '' then
@ -551,32 +495,6 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TChiSqrFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
VarList.Constraints.MinHeight :=
OptionsGroup.Top + OptionsGroup.Height - VarList.Top - NCasesEdit.Height - NCasesEdit.BorderSpacing.Top;
Constraints.MinWidth := OptionsGroup.Width * 2 + 3 * VarList.BorderSpacing.Left;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TChiSqrFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then
Application.CreateForm(TDictionaryFrm, DictionaryFrm);
end;
procedure TChiSqrFrm.InputGrpClick(Sender: TObject); procedure TChiSqrFrm.InputGrpClick(Sender: TObject);
begin begin
@ -584,15 +502,11 @@ begin
0: begin // have to count cases in each row and col. combination 0: begin // have to count cases in each row and col. combination
NCasesLabel.Enabled := false; NCasesLabel.Enabled := false;
NCasesEdit.Enabled := false; NCasesEdit.Enabled := false;
DepIn.Enabled := false;
DepOut.Enabled := false;
DepEdit.Enabled := false; DepEdit.Enabled := false;
end; end;
1: begin // frequencies available for each row and column combo 1: begin // frequencies available for each row and column combo
NCasesLabel.Enabled := false; NCasesLabel.Enabled := false;
NCasesEdit.Enabled := false; NCasesEdit.Enabled := false;
DepIn.Enabled := true;
DepEdit.Enabled := true;
AnalyzeLabel.Enabled := true; AnalyzeLabel.Enabled := true;
end; end;
2: begin // only proportions available - get N size 2: begin // only proportions available - get N size
@ -600,32 +514,157 @@ begin
AnalyzeLabel.Enabled := true; AnalyzeLabel.Enabled := true;
NCasesEdit.Enabled := true; NCasesEdit.Enabled := true;
NCasesEdit.SetFocus; NCasesEdit.SetFocus;
DepIn.Enabled := true;
DepOut.Enabled := false;
DepEdit.Enabled := true; DepEdit.Enabled := true;
end; end;
end; end;
UpdateBtnStates;
end; end;
procedure TChiSqrFrm.Reset;
var
i: integer;
begin
inherited;
InputGrp.ItemIndex := 0;
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
RowEdit.Clear;
ColEdit.Clear;
DepEdit.Clear;
AnalyzeLabel.Enabled := false;
NCasesLabel.Enabled := false;
NCasesEdit.Text := '';
NCasesEdit.Enabled := false;
ObsChk.Checked := false;
ExpChk.Checked := false;
PropsChk.Checked := false;
CellChiChk.Checked := false;
SaveFChk.Checked := false;
UpdateBtnStates;
end;
procedure TChiSqrFrm.RowInClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (RowEdit.Text = '') then
begin
RowEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TChiSqrFrm.RowOutClick(Sender: TObject);
begin
if RowEdit.Text <> '' then
begin
VarList.Items.Add(RowEdit.Text);
RowEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TChiSqrFrm.UpdateBtnStates; procedure TChiSqrFrm.UpdateBtnStates;
begin begin
inherited;
RowIn.Enabled := (VarList.Items.Count > 0) and (RowEdit.Text = ''); RowIn.Enabled := (VarList.Items.Count > 0) and (RowEdit.Text = '');
ColIn.Enabled := (VarList.Items.Count > 0) and (ColEdit.Text = ''); ColIn.Enabled := (VarList.Items.Count > 0) and (ColEdit.Text = '');
DepIn.Enabled := (VarList.Items.Count > 0) and (DepEdit.Text = ''); DepIn.Enabled := (VarList.Items.Count > 0) and (DepEdit.Text = '') and (InputGrp.ItemIndex > 0);
RowOut.Enabled := (RowEdit.Text <> ''); RowOut.Enabled := (RowEdit.Text <> '');
ColOut.Enabled := (ColEdit.Text <> ''); ColOut.Enabled := (ColEdit.Text <> '');
DepOut.Enabled := (DepEdit.Text <> ''); DepOut.Enabled := (DepEdit.Text <> '') and (InputGrp.ItemIndex > 0);
end; end;
function TChiSqrFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
n: Integer;
begin
Result := false;
if RowEdit.Text = '' then
begin
AMsg := 'Row variable not selected.';
AControl := RowEdit;
exit;
end;
if ColEdit.Text = '' then
begin
AMsg := 'Column variable not selected.';
AControl := ColEdit;
exit;
end;
if (DepEdit.Text = '') and (InputGrp.ItemIndex > 0) then
begin
AMsg := 'Variable to analyze is not selected';
AControl := DepEdit;
exit;
end;
if InputGrp.ItemIndex = 2 then
begin
if NCasesEdit.Text = '' then
begin
AControl := NCasesEdit;
AMsg := 'Total number of cases not selected.';
exit;
end;
if not TryStrToInt(NCasesEdit.Text, n) then
begin
AControl := NCasesEdit;
AMsg := 'Numberical input expected for total number of cases.';
exit;
end;
end;
Result := True;
end;
procedure TChiSqrFrm.VarListDblClick(Sender: TObject);
var
index: Integer;
s: String;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
s := VarList.Items[index];
if RowEdit.Text = '' then
RowEdit.Text := s
else if ColEdit.Text = '' then
ColEdit.Text := s
else if (DepEdit.Text = '') and (InputGrp.ItemIndex > 0) then
DepEdit.Text := s;
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TChiSqrFrm.VarListSelectionChange(Sender: TObject; User: boolean); procedure TChiSqrFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin begin
UpdateBtnStates; UpdateBtnStates;
end; end;
initialization
{$I chisqrunit.lrs}
end. end.