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

View File

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