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 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 end
Height = 15 inherited ComputeBtn: TButton
Top = 109 Left = 285
Width = 97 Top = 462
BorderSpacing.Left = 8 TabOrder = 15
BorderSpacing.Top = 8 end
Caption = 'Available Variables' inherited ResetBtn: TButton
ParentColor = False Left = 223
end Top = 462
object Label2: TLabel TabOrder = 14
AnchorSideLeft.Control = RowEdit end
AnchorSideBottom.Control = RowEdit inherited HelpBtn: TButton
Left = 265 Left = 164
Height = 15 Top = 462
Top = 134 TabOrder = 13
Width = 67 end
Anchors = [akLeft, akBottom] inherited ButtonBevel: TBevel
BorderSpacing.Bottom = 2 Top = 446
Caption = 'Row Variable' Width = 424
ParentColor = False end
end object InputGrp: TRadioGroup[5]
object Label3: TLabel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Control = ColEdit AnchorSideTop.Control = ParamsPanel
AnchorSideBottom.Control = ColEdit AnchorSideRight.Control = ParamsPanel
Left = 265 AnchorSideRight.Side = asrBottom
Height = 15 Left = 0
Top = 214 Height = 89
Width = 87 Top = 0
Anchors = [akLeft, akBottom] Width = 424
BorderSpacing.Bottom = 2 Anchors = [akTop, akLeft, akRight]
Caption = 'Column Variable' AutoFill = True
ParentColor = False AutoSize = True
end Caption = 'Input Options'
object AnalyzeLabel: TLabel ChildSizing.LeftRightSpacing = 12
AnchorSideLeft.Control = DepEdit ChildSizing.TopBottomSpacing = 6
AnchorSideBottom.Control = DepEdit ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
Left = 265 ChildSizing.EnlargeVertical = crsHomogenousChildResize
Height = 15 ChildSizing.ShrinkHorizontal = crsScaleChilds
Top = 294 ChildSizing.ShrinkVertical = crsScaleChilds
Width = 99 ChildSizing.Layout = cclLeftToRightThenTopToBottom
Anchors = [akLeft, akBottom] ChildSizing.ControlsPerLine = 1
BorderSpacing.Bottom = 2 ClientHeight = 69
Caption = 'Variable to Analyze' ClientWidth = 420
ParentColor = False Items.Strings = (
end 'Count vases classified by row and column vectors in the data grid'
object NCasesLabel: TLabel 'Use frequencies recorded in the data grid for row and column variables'
AnchorSideLeft.Control = Owner 'Use proportions recorded in the data grid for row and column variables'
AnchorSideTop.Control = NCasesEdit )
AnchorSideTop.Side = asrCenter OnClick = InputGrpClick
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'
TabOrder = 0 TabOrder = 0
end end
object ExpChk: TCheckBox object Label1: TLabel[6]
Left = 12 AnchorSideLeft.Control = ParamsPanel
Height = 19 AnchorSideTop.Control = InputGrp
Top = 25 AnchorSideTop.Side = asrBottom
Width = 209 Left = 0
Caption = 'Show Expected Frequencies' 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 TabOrder = 1
end end
object PropsChk: TCheckBox object RowIn: TBitBtn[12]
Left = 12 AnchorSideLeft.Control = ParamsPanel
Height = 19 AnchorSideLeft.Side = asrCenter
Top = 46 AnchorSideTop.Control = VarList
Width = 209 Left = 199
Caption = 'Show Row and Column Proportions' Height = 26
Top = 114
Width = 26
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = RowInClick
Spacing = 0
TabOrder = 2 TabOrder = 2
end end
object CellChiChk: TCheckBox object RowOut: TBitBtn[13]
Left = 12 AnchorSideLeft.Control = ParamsPanel
Height = 19 AnchorSideLeft.Side = asrCenter
Top = 67 AnchorSideTop.Control = RowIn
Width = 209 AnchorSideTop.Side = asrBottom
Caption = 'Show Cell Chi-Squared Values' Left = 199
Height = 26
Top = 144
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = RowOutClick
Spacing = 0
TabOrder = 3 TabOrder = 3
end end
object YatesChk: TCheckBox object ColIn: TBitBtn[14]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowOut
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 199
Height = 19 Height = 26
Top = 88 Top = 190
Width = 209 Width = 26
Caption = 'Use Yates Correction' BorderSpacing.Top = 20
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = ColInClick
Spacing = 0
TabOrder = 5 TabOrder = 5
end end
object SaveFChk: TCheckBox object ColOut: TBitBtn[15]
Left = 12 AnchorSideLeft.Control = ParamsPanel
Height = 19 AnchorSideLeft.Side = asrCenter
Top = 109 AnchorSideTop.Control = ColIn
Width = 209 AnchorSideTop.Side = asrBottom
Caption = 'Save a File of Frequency Data' 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 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
end end
object ResetBtn: TButton inherited ParamsSplitter: TSplitter
AnchorSideRight.Control = ComputeBtn Left = 436
AnchorSideBottom.Control = Owner Height = 503
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
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,54 +119,27 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; 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; yates := false;
RowNo := 0; RowNo := 0;
ColNo := 0; ColNo := 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.