LazStats: Inherit TwoPropUnit from TBasicStatsReportForm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7842 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-03 23:54:55 +00:00
parent 4805815adb
commit 7613b7da31
5 changed files with 816 additions and 716 deletions

View File

@@ -315,7 +315,7 @@
<Unit26> <Unit26>
<Filename Value="forms\analysis\comparisons\twopropunit.pas"/> <Filename Value="forms\analysis\comparisons\twopropunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="TwoPropFrm"/> <ComponentName Value="TwoPropForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TwoPropUnit"/> <UnitName Value="TwoPropUnit"/>

View File

@@ -1,138 +1,57 @@
object TwoPropFrm: TTwoPropFrm inherited TwoPropForm: TTwoPropForm
Left = 603 Left = 603
Height = 427 Height = 410
Top = 225 Top = 225
Width = 455 Width = 793
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/DifferencebetweenProportions.htm' HelpKeyword = 'html/DifferencebetweenProportions.htm'
Caption = 'Test of Equality for two Proportions' Caption = 'Test of Equality for two Proportions'
ClientHeight = 427 ClientHeight = 410
ClientWidth = 455 ClientWidth = 793
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 394
OnShow = FormShow Width = 416
LCLVersion = '2.1.0.0' ClientHeight = 394
object ConfLabel: TLabel ClientWidth = 416
AnchorSideLeft.Control = Owner inherited CloseBtn: TButton
AnchorSideTop.Control = CInterval Left = 361
AnchorSideTop.Side = asrCenter Top = 369
AnchorSideRight.Control = CInterval
Left = 8
Height = 15
Top = 359
Width = 149
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Percent Confidence Interval:'
ParentColor = False
end end
object CInterval: TEdit inherited ComputeBtn: TButton
AnchorSideLeft.Control = ConfLabel Left = 277
AnchorSideLeft.Side = asrBottom Top = 369
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel4
Left = 165
Height = 23
Top = 355
Width = 41
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Right = 8
TabOrder = 1
Text = '95.0'
end end
object ResetBtn: TButton inherited ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn Left = 215
AnchorSideBottom.Control = Owner Top = 369
AnchorSideBottom.Side = asrBottom
Left = 242
Height = 25
Top = 394
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end end
object ComputeBtn: TButton inherited HelpBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 304
Height = 25
Top = 394
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 388
Height = 25
Top = 394
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 5
end
object HelpBtn: TButton
Tag = 152 Tag = 152
AnchorSideRight.Control = ResetBtn Left = 156
AnchorSideBottom.Control = Owner Top = 369
AnchorSideBottom.Side = asrBottom
Left = 183
Height = 25
Top = 394
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 2
end end
object Notebook1: TNotebook inherited ButtonBevel: TBevel
AnchorSideLeft.Control = Owner Top = 353
AnchorSideTop.Control = Panel1 Width = 416
end
object Notebook: TNotebook[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = RadioGroup1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CInterval AnchorSideBottom.Control = CIntervalEdit
Left = 8 Left = 8
Height = 259 Height = 242
Top = 88 Top = 80
Width = 439 Width = 400
PageIndex = 0 PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
TabOrder = 0 TabOrder = 4
object Page1: TPage object Page1: TPage
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
object Label11: TLabel object Label11: TLabel
@@ -145,24 +64,24 @@ object TwoPropFrm: TTwoPropFrm
Caption = 'Select Variables:' Caption = 'Select Variables:'
ParentColor = False ParentColor = False
end end
object FirstVarLabel: TLabel object Var1Label: TLabel
AnchorSideLeft.Control = Bevel1 AnchorSideLeft.Control = Var1Edit
AnchorSideLeft.Side = asrBottom AnchorSideBottom.Control = Var1Edit
AnchorSideTop.Control = VarList Left = 219
Left = 223
Height = 15 Height = 15
Top = 17 Top = 21
Width = 66 Width = 66
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'First Variable' Caption = 'First Variable'
ParentColor = False ParentColor = False
end end
object SecdVarLabel: TLabel object Var2Label: TLabel
AnchorSideLeft.Control = Bevel1 AnchorSideLeft.Control = Var2Edit
AnchorSideLeft.Side = asrBottom AnchorSideBottom.Control = Var2Edit
AnchorSideBottom.Control = Var2 Left = 219
Left = 223
Height = 15 Height = 15
Top = 110 Top = 101
Width = 83 Width = 83
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
@@ -170,12 +89,11 @@ object TwoPropFrm: TTwoPropFrm
ParentColor = False ParentColor = False
end end
object GrpLabel: TLabel object GrpLabel: TLabel
AnchorSideLeft.Control = Bevel1 AnchorSideLeft.Control = GrpEdit
AnchorSideLeft.Side = asrBottom AnchorSideBottom.Control = GrpEdit
AnchorSideBottom.Control = Grp Left = 219
Left = 223
Height = 15 Height = 15
Top = 219 Top = 181
Width = 64 Width = 64
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
@@ -186,77 +104,167 @@ object TwoPropFrm: TTwoPropFrm
AnchorSideLeft.Control = Page1 AnchorSideLeft.Control = Page1
AnchorSideTop.Control = Label11 AnchorSideTop.Control = Label11
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel1 AnchorSideRight.Control = Var1In
AnchorSideBottom.Control = Page1 AnchorSideBottom.Control = Page1
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 242 Height = 225
Top = 17 Top = 17
Width = 215 Width = 181
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
Constraints.MinHeight = 220 BorderSpacing.Right = 6
ItemHeight = 0 ItemHeight = 0
OnClick = VarListClick OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object Var1: TEdit object Var1Edit: TEdit
AnchorSideLeft.Control = Bevel1 AnchorSideLeft.Control = Var1In
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FirstVarLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Page1 AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 223 AnchorSideBottom.Control = Var1Out
Height = 23
Top = 34
Width = 216
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
ReadOnly = True
TabOrder = 1
Text = 'Var1'
end
object Var2: TEdit
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = VarList
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
Left = 223
Height = 23
Top = 127
Width = 216
Anchors = [akTop, akLeft, akRight]
ReadOnly = True
TabOrder = 2
Text = 'Var2'
end
object Grp: TEdit
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 223 Left = 219
Height = 23 Height = 23
Top = 236 Top = 38
Width = 216 Width = 181
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 2
BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 3 TabOrder = 3
Text = 'Grp' Text = 'Var1Edit'
end end
object Bevel1: TBevel object Var2Edit: TEdit
AnchorSideLeft.Control = Var1Edit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var2Out
AnchorSideBottom.Side = asrBottom
Left = 219
Height = 23
Top = 118
Width = 181
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'Var2Edit'
end
object GrpEdit: TEdit
AnchorSideLeft.Control = Var1Edit
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GrpOut
AnchorSideBottom.Side = asrBottom
Left = 219
Height = 23
Top = 198
Width = 181
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 9
Text = 'GrpEdit'
end
object Var1In: TBitBtn
AnchorSideLeft.Control = Page1 AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
Left = 215 AnchorSideTop.Control = VarList
Height = 49 Left = 187
Top = 53 Height = 26
Width = 8 Top = 17
Shape = bsSpacer Width = 26
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var1InClick
Spacing = 0
TabOrder = 1
end
object Var1Out: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1In
AnchorSideTop.Side = asrBottom
Left = 187
Height = 26
Top = 47
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var1OutClick
Spacing = 0
TabOrder = 2
end
object Var2In: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1Out
AnchorSideTop.Side = asrBottom
Left = 187
Height = 26
Top = 97
Width = 26
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var2InClick
Spacing = 0
TabOrder = 4
end
object Var2Out: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2In
AnchorSideTop.Side = asrBottom
Left = 187
Height = 26
Top = 127
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var2OutClick
Spacing = 0
TabOrder = 5
end
object GrpIn: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2Out
AnchorSideTop.Side = asrBottom
Left = 187
Height = 26
Top = 177
Width = 26
BorderSpacing.Top = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = GrpInClick
Spacing = 0
TabOrder = 7
end
object GrpOut: TBitBtn
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = GrpIn
AnchorSideTop.Side = asrBottom
Left = 187
Height = 26
Top = 207
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = GrpOutClick
Spacing = 0
TabOrder = 8
end end
end end
object Page2: TPage object Page2: TPage
@@ -486,44 +494,45 @@ object TwoPropFrm: TTwoPropFrm
end end
end end
end end
object Bevel4: TBevel object ConfLabel: TLabel[6]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = Owner AnchorSideTop.Control = CIntervalEdit
AnchorSideRight.Side = asrBottom AnchorSideTop.Side = asrCenter
AnchorSideBottom.Control = CloseBtn AnchorSideRight.Control = CIntervalEdit
Left = 0 Left = 8
Height = 8 Height = 15
Top = 378 Top = 334
Width = 455 Width = 149
Anchors = [akLeft, akRight, akBottom] BorderSpacing.Left = 8
Shape = bsBottomLine BorderSpacing.Right = 8
Caption = 'Percent Confidence Interval:'
ParentColor = False
end end
object Panel1: TPanel object CIntervalEdit: TEdit[7]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ConfLabel
AnchorSideTop.Control = Owner AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 AnchorSideBottom.Control = ButtonBevel
Height = 80 Left = 165
Top = 0 Height = 23
Width = 455 Top = 330
Anchors = [akTop, akLeft, akRight] Width = 41
AutoSize = True Alignment = taRightJustify
BevelOuter = bvNone Anchors = [akLeft, akBottom]
ClientHeight = 80 BorderSpacing.Right = 8
ClientWidth = 455 TabOrder = 5
TabOrder = 6 Text = '95.0'
object RadioGroup1: TRadioGroup end
AnchorSideTop.Control = Panel1 object RadioGroup1: TRadioGroup[8]
AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = Bevel5 AnchorSideRight.Control = Bevel5
Left = 16 Left = -3
Height = 72 Height = 72
Top = 8 Top = 0
Width = 203 Width = 203
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Top = 8
Caption = 'Data Entry By:' Caption = 'Data Entry By:'
ChildSizing.LeftRightSpacing = 16 ChildSizing.LeftRightSpacing = 16
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
@@ -541,19 +550,18 @@ object TwoPropFrm: TTwoPropFrm
'Values in the Data Grid' 'Values in the Data Grid'
) )
OnClick = RadioGroup1Click OnClick = RadioGroup1Click
TabOrder = 0 TabOrder = 6
end end
object RadioGroup2: TRadioGroup object DepIndepGroup: TRadioGroup[9]
AnchorSideLeft.Control = Bevel5 AnchorSideLeft.Control = Bevel5
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1 AnchorSideTop.Control = ParamsPanel
Left = 235 Left = 216
Height = 72 Height = 72
Top = 8 Top = 0
Width = 188 Width = 188
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Top = 8
Caption = 'Test Assumptions:' Caption = 'Test Assumptions:'
ChildSizing.LeftRightSpacing = 16 ChildSizing.LeftRightSpacing = 16
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
@@ -570,18 +578,22 @@ object TwoPropFrm: TTwoPropFrm
'Independent Proportions' 'Independent Proportions'
'Dependent Proportions' 'Dependent Proportions'
) )
OnClick = RadioGroup2Click OnClick = DepIndepGroupClick
TabOrder = 1 TabOrder = 7
end end
object Bevel5: TBevel object Bevel5: TBevel[10]
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel1 AnchorSideTop.Control = ParamsPanel
Left = 219 Left = 200
Height = 41 Height = 41
Top = 0 Top = 0
Width = 16 Width = 16
Shape = bsSpacer Shape = bsSpacer
end end
end end
inherited ParamsSplitter: TSplitter
Left = 428
Height = 410
end
end end

View File

@@ -5,43 +5,41 @@ unit TwoPropUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Classes, SysUtils, Forms, Controls,
Graphics, Dialogs, ExtCtrls, StdCtrls, ComCtrls, MainUnit, Globals, Graphics, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, MainUnit, Globals,
FunctionsLib, OutPutUnit, DataProcs, contexthelpunit; FunctionsLib, DataProcs, BasicStatsReportFormUnit;
type type
{ TTwoPropFrm } { TTwoPropForm }
TTwoPropFrm = class(TForm) TTwoPropForm = class(TBasicStatsReportForm)
Bevel1: TBevel;
Bevel2: TBevel; Bevel2: TBevel;
Bevel3: TBevel; Bevel3: TBevel;
Bevel4: TBevel;
Bevel5: TBevel; Bevel5: TBevel;
HelpBtn: TButton;
LabelCorner: TLabel; LabelCorner: TLabel;
Notebook1: TNotebook; Notebook: TNotebook;
Page1: TPage; Page1: TPage;
Page2: TPage; Page2: TPage;
Page3: TPage; Page3: TPage;
Panel1: TPanel;
Panel3: TPanel; Panel3: TPanel;
Panel4: TPanel; Panel4: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
DepFreq00: TEdit; DepFreq00: TEdit;
DepFreq10: TEdit; DepFreq10: TEdit;
DepFreq01: TEdit; DepFreq01: TEdit;
DepFreq11: TEdit; DepFreq11: TEdit;
CInterval: TEdit; CIntervalEdit: TEdit;
Grp: TEdit; GrpEdit: TEdit;
GrpLabel: TLabel; GrpLabel: TLabel;
ConfLabel: TLabel; ConfLabel: TLabel;
Var2: TEdit; Var1In: TBitBtn;
SecdVarLabel: TLabel; Var2In: TBitBtn;
Var1: TEdit; Var1Out: TBitBtn;
GrpIn: TBitBtn;
Var2Out: TBitBtn;
Var2Edit: TEdit;
Var2Label: TLabel;
Var1Edit: TEdit;
IndSize2: TEdit; IndSize2: TEdit;
IndSize1: TEdit; IndSize1: TEdit;
IndFreq2: TEdit; IndFreq2: TEdit;
@@ -49,7 +47,7 @@ type
Samp1Label: TLabel; Samp1Label: TLabel;
Samp21Label: TLabel; Samp21Label: TLabel;
Label11: TLabel; Label11: TLabel;
FirstVarLabel: TLabel; Var1Label: TLabel;
Samp2Label: TLabel; Samp2Label: TLabel;
Samp1SizeLabel: TLabel; Samp1SizeLabel: TLabel;
Samp2SizeLabel: TLabel; Samp2SizeLabel: TLabel;
@@ -58,106 +56,70 @@ type
Samp10Label: TLabel; Samp10Label: TLabel;
Samp11Label: TLabel; Samp11Label: TLabel;
Samp20Label: TLabel; Samp20Label: TLabel;
GrpOut: TBitBtn;
VarList: TListBox; VarList: TListBox;
RadioGroup1: TRadioGroup; RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup; DepIndepGroup: TRadioGroup;
procedure ComputeBtnClick(Sender: TObject); procedure GrpInClick(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure GrpOutClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject); procedure RadioGroup1Click(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject); procedure DepIndepGroupClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject); procedure Var1InClick(Sender: TObject);
procedure VarListClick(Sender: TObject); procedure Var1OutClick(Sender: TObject);
procedure Var2InClick(Sender: TObject);
procedure Var2OutClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private private
{ private declarations }
FAutoSized: Boolean;
independent: boolean; independent: boolean;
griddata: boolean; griddata: boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
protected
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
TwoPropFrm: TTwoPropFrm; TwoPropForm: TTwoPropForm;
implementation implementation
{$R *.lfm}
uses uses
Math; Math;
{ TTwoPropFrm }
procedure TTwoPropFrm.ResetBtnClick(Sender: TObject); { TTwoPropForm }
var
i: integer; constructor TTwoPropForm.Create(AOwner: TComponent);
begin begin
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT); inherited;
CIntervalEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
RadioGroup1.ItemIndex := 0;
RadioGroup2.ItemIndex := 0;
VarList.Clear;
Var1.Text := '';
Var2.Text := '';
independent := true;
griddata := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
GrpLabel.Visible := true;
Grp.Visible := true;
Grp.Text := '';
Var2.Visible := false;
SecdVarLabel.Visible := false;
DepFreq00.Text := '';
DepFreq01.Text := '';
DepFreq10.Text := '';
DepFreq11.Text := '';
IndFreq1.Text := '';
IndFreq2.Text := '';
IndSize1.Text := '';
IndSize2.Text := '';
Notebook1.PageIndex := 1;
end; end;
procedure TTwoPropFrm.VarListClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if not independent then
begin
if Var1.Text <> '' then
Var2.Text := VarList.Items[index]
else
Var1.Text := VarList.Items[index];
end;
if independent then procedure TTwoPropForm.AdjustConstraints;
begin begin
if Var1.Text <> '' then inherited;
Grp.Text := VarList.Items[index] ParamsPanel.Constraints.MinWidth := Max(
else 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
Var1.Text := VarList.Items[index]; RadioGroup1.Width + Bevel5.Width + DepIndepGroup.Width
end; );
ParamsPanel.Constraints.MinHeight := GrpOut.Top + GrpOut.Height +
Notebook.BorderSpacing.Bottom + CIntervalEdit.Height + ButtonBevel.Height +
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
end; end;
procedure TTwoPropFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TTwoPropFrm.HelpBtnClick(Sender: TObject); procedure TTwoPropForm.Compute;
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TTwoPropFrm.ComputeBtnClick(Sender: TObject);
var var
ConfInt, Prop1, Prop2, zstatistic, zprobability: double; ConfInt, Prop1, Prop2, zstatistic, zprobability: double;
PropDif, stderr, UCL, LCL, value1, value2, ztest: double; PropDif, stderr, UCL, LCL, value1, value2, ztest: double;
@@ -165,18 +127,8 @@ var
i, v1, v2, NoSelected, f1, f2, f3, f4, ncases1, ncases2: integer; i, v1, v2, NoSelected, f1, f2, f3, f4, ncases1, ncases2: integer;
min, max, group, AB, AC, CD, BD: integer; min, max, group, AB, AC, CD, BD: integer;
ColNoSelected: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil;
msg: String;
C: TWinControl;
lReport: TStrings; lReport: TStrings;
begin begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
// Initialize output form // Initialize output form
stderr := 0.0; stderr := 0.0;
PropDif := 0.0; PropDif := 0.0;
@@ -193,7 +145,7 @@ begin
SetLength(ColNoSelected,NoVariables); SetLength(ColNoSelected,NoVariables);
ConfInt := (100.0 - StrToFloat(CInterval.Text)) / 2.0 ; ConfInt := (100.0 - StrToFloat(CIntervalEdit.Text)) / 2.0 ;
ConfInt := (100.0 - ConfInt) / 100.0; // one tail ConfInt := (100.0 - ConfInt) / 100.0; // one tail
ncases1 := 0; ncases1 := 0;
ncases2 := 0; ncases2 := 0;
@@ -202,19 +154,19 @@ begin
f3 := 0; f3 := 0;
f4 := 0; f4 := 0;
if independent then if independent then
Var2.Text := Grp.Text; Var2Edit.Text := GrpEdit.Text;
if griddata then // data read from grid if griddata then // data read from grid
begin begin
for i := 1 to NoVariables do for i := 1 to NoVariables do
begin begin
if Var1.Text = OS3MainFrm.DataGrid.Cells[i,0] then if Var1Edit.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin begin
v1 := i; v1 := i;
ColNoSelected[0] := i; ColNoSelected[0] := i;
end; end;
if Var2.Text = OS3MainFrm.DataGrid.Cells[i,0] then if Var2Edit.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin begin
v2 := i; v2 := i;
ColNoSelected[1] := i; ColNoSelected[1] := i;
@@ -244,7 +196,7 @@ begin
PropDif := Prop1 - Prop2; PropDif := Prop1 - Prop2;
zstatistic := PropDif / stderr; zstatistic := PropDif / stderr;
ztest := inversez(ConfInt); ztest := inversez(ConfInt);
zprobability := 1.0 - probz(abs(zstatistic)); zprobability := 1.0 - ProbZ(abs(zstatistic));
UCL := PropDif + stderr * ztest; UCL := PropDif + stderr * ztest;
LCL := PropDif - stderr * ztest; LCL := PropDif - stderr * ztest;
end; // if not independent end; // if not independent
@@ -355,13 +307,14 @@ begin
lReport.Add(' --------|-------|------'); lReport.Add(' --------|-------|------');
lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]); lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]);
lReport.Add(''); lReport.Add('');
lReport.Add('Confidence Level selected: %s', [CInterval.Text]); lReport.Add('Confidence Level selected: %s', [CIntervalEdit.Text]);
lReport.Add('Proportion 1 = %.3f and Proportion 2 = %.3f with %d cases', [Prop1, Prop2, ncases1]); lReport.Add('Proportion 1 = %.3f and Proportion 2 = %.3f with %d cases', [Prop1, Prop2, ncases1]);
lReport.Add('Difference in proportions: %9.3f', [PropDif]); lReport.Add('Difference in proportions: %9.3f', [PropDif]);
lReport.Add('Standard Error of Difference: %9.3f', [stderr]); lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
lReport.Add('z test statistic: %9.3f with probability = %.4f', [zstatistic, zprobability]); lReport.Add('z test statistic: %9.3f', [zStatistic]);
lReport.Add('z value for confidence interval: %9.3f', [ztest]); lReport.Add(' with probability %9.4f', [zProbability]);
lReport.Add('Confidence Interval: (%.3f, %.3f)', [LCL, UCL]); lReport.Add('z value for confidence interval: %9.3f', [zTest]);
lReport.Add('Confidence Interval: %9.3f ... %.3f', [LCL, UCL]);
end; end;
if independent then if independent then
@@ -377,114 +330,217 @@ begin
lReport.Add('Proportion 2: %9.3f', [Prop2]); lReport.Add('Proportion 2: %9.3f', [Prop2]);
lReport.Add('Difference: %9.3f', [PropDif]); lReport.Add('Difference: %9.3f', [PropDif]);
lReport.Add('Standard Error of Difference: %9.3f', [stderr]); lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
lReport.Add('Confidence Level selected: %9s', [CInterval.Text]); lReport.Add('Confidence Level selected: %-9s', [CIntervalEdit.Text]);
lReport.Add('z test statistic: %9.3f with probability = %.4f', [zstatistic, zprobability]); lReport.Add('z test statistic: %9.3f', [zStatistic]);
lReport.Add(' with probability %9.4f', [zProbability]);
lReport.Add('z value for confidence interval: %9.3f', [ztest]); lReport.Add('z value for confidence interval: %9.3f', [ztest]);
lReport.Add('Confidence Interval: (%.3f, %.3f)', [LCL, UCL]); lReport.Add('Confidence Interval: %9.3f ... %.3f', [LCL, UCL]);
end; end;
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
ColNoSelected := nil;
end; end;
end; end;
procedure TTwoPropFrm.FormActivate(Sender: TObject);
procedure TTwoPropForm.GrpInClick(Sender: TObject);
var var
w: Integer; index: Integer;
begin begin
if FAutoSized then index := VarList.ItemIndex;
exit; if (index > -1) and (GrpEdit.Text = '') then
begin
RadioGroup2.Constraints.MinWidth := RadioGroup1.Width; GrpEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); UpdateBtnStates;
HelpBtn.Constraints.MinWidth := w; end;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Width := Max(
RadioGroup2.Left + RadioGroup2.Width + RadioGroup2.BorderSpacing.Right,
Width - HelpBtn.Left + HelpBtn.BorderSpacing.Left
);
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end; end;
procedure TTwoPropFrm.FormCreate(Sender: TObject);
procedure TTwoPropForm.GrpOutClick(Sender: TObject);
begin begin
Assert(OS3MainFrm <> nil); if GrpEdit.Text <> '' then
begin
VarList.Items.Add(GrpEdit.Text);
GrpEdit.Text := '';
UpdateBtnStates;
end;
end; end;
procedure TTwoPropFrm.RadioGroup1Click(Sender: TObject);
procedure TTwoPropForm.RadioGroup1Click(Sender: TObject);
begin begin
griddata := RadioGroup1.ItemIndex = 1; griddata := (RadioGroup1.ItemIndex = 1);
RadioGroup2Click(nil); DepIndepGroupClick(nil);
end; end;
procedure TTwoPropFrm.RadioGroup2Click(Sender: TObject);
procedure TTwoPropForm.DepIndepGroupClick(Sender: TObject);
begin begin
case RadioGroup2.ItemIndex of case DepIndepGroup.ItemIndex of
0: begin 0: begin
independent := true; independent := true;
if griddata then begin if griddata then
Notebook1.PageIndex := 0; Notebook.PageIndex := 0
Var2.Visible := false; else
Grp.Visible := true; Notebook.PageIndex := 1;
SecdVarLabel.Visible := Var2.Visible;
GrpLabel.Visible := Grp.Visible;
end else
Notebook1.PageIndex := 1;
end; end;
1: begin 1: begin
independent := false; independent := false;
if griddata then begin if griddata then
Notebook1.PageIndex := 0; Notebook.PageIndex := 0
Var2.Visible := true; else
Grp.Visible := false; Notebook.PageIndex := 2;
SecdVarLabel.Visible := Var2.Visible;
GrpLabel.Visible := Grp.Visible;
end else
Notebook1.PageIndex := 2;
end; end;
end; end;
Var2Edit.Visible := independent;
Var2Label.Visible := independent;
Var2In.Visible := independent;
Var2Out.Visible := independent;
GrpEdit.Visible := not independent;
GrpLabel.Visible := not independent;
GrpIn.Visible := not independent;
GrpOut.Visible := not independent;
end;
procedure TTwoPropForm.Reset;
var
i: integer;
begin
inherited;
RadioGroup1.ItemIndex := 0;
DepIndepGroup.ItemIndex := 0;
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Var1Edit.Clear;
Var2Edit.Clear;
independent := true;
griddata := false;
GrpLabel.Visible := true;
GrpEdit.Visible := true;
GrpIn.Visible := true;
GrpOut.Visible := true;
GrpEdit.Clear;
Var2Edit.Visible := false;
Var2Label.Visible := false;
Var2In.Visible := false;
Var2Out.Visible := false;
DepFreq00.Clear;
DepFreq01.Clear;
DepFreq10.Clear;
DepFreq11.Clear;
IndFreq1.Clear;
IndFreq2.Clear;
IndSize1.Clear;
IndSize2.Clear;
Notebook.PageIndex := 1;
end;
procedure TTwoPropForm.Var1InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var1Edit.Text = '') then
begin
Var1Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end; end;
function TTwoPropFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
procedure TTwoPropForm.Var1OutClick(Sender: TObject);
begin
if Var1Edit.Text <> '' then
begin
VarList.Items.Add(Var1Edit.Text);
Var1Edit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTwoPropForm.Var2InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var2Edit.Text = '') then
begin
Var2Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TTwoPropForm.Var2OutClick(Sender: TObject);
begin
if Var2Edit.Text <> '' then
begin
VarList.Items.Add(Var2Edit.Text);
Var2Edit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTwoPropForm.UpdateBtnStates;
begin
inherited;
Var1In.Enabled := (VarList.ItemIndex > -1) and (Var1Edit.Text = '');
Var2In.Enabled := (VarList.ItemIndex > -1) and (Var2Edit.Text = '');
GrpIn.Enabled := (VarList.ItemIndex > -1) and (GrpEdit.Text = '');
Var1Out.Enabled := Var1Edit.Text <> '';
Var2Out.Enabled := Var2Edit.Text <> '';
GrpOut.Enabled := GrpEdit.Text <> '';
end;
function TTwoPropForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var var
n: Integer; n: Integer;
begin begin
Result := false; Result := false;
AControl := nil; AControl := nil;
AMsg := ''; AMsg := '';
if Notebook1.PageIndex = 0 then if Notebook.PageIndex = 0 then
begin begin
if Var1.Text = '' then if Var1Edit.Text = '' then
begin begin
AControl := Var1; AControl := Var1Edit;
AMsg := 'First variable not specified.'; AMsg := 'First variable not specified.';
exit; exit;
end; end;
case RadioGroup2.ItemIndex of case DepIndepGroup.ItemIndex of
0: if (Grp.Text = '') then 0: if (GrpEdit.Text = '') then
begin begin
AControl := Grp; AControl := GrpEdit;
AMsg := 'Group code not specified'; AMsg := 'Group code not specified';
exit; exit;
end; end;
1: if (Var2.Text = '') then begin 1: if (Var2Edit.Text = '') then begin
AControl := Var2; AControl := Var2Edit;
AMsg := 'Second variable not specified.'; AMsg := 'Second variable not specified.';
exit; exit;
end; end;
end; end;
end else end else
if Notebook1.PageIndex = 1 then if Notebook.PageIndex = 1 then
begin begin
if (IndFreq1.Text = '') or not TryStrToInt(IndFreq1.Text, n) or (n < 0) then if (IndFreq1.Text = '') or not TryStrToInt(IndFreq1.Text, n) or (n < 0) then
begin begin
@@ -511,7 +567,7 @@ begin
exit; exit;
end; end;
end else end else
if Notebook1.PageIndex = 2 then if Notebook.PageIndex = 2 then
begin begin
if (DepFreq00.Text = '') or not TryStrToInt(DepFreq00.Text, n) or (n < 0) then if (DepFreq00.Text = '') or not TryStrToInt(DepFreq00.Text, n) or (n < 0) then
AControl := DepFreq00 AControl := DepFreq00
@@ -534,8 +590,40 @@ begin
end; end;
initialization procedure TTwoPropForm.VarListDblClick(Sender: TObject);
{$I twopropunit.lrs} var
index: integer;
s: String;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
s := VarList.Items[index];
if Var1Edit.Text = '' then
Var1Edit.Text := s
else
begin
if independent then
begin
if GrpEdit.Text = '' then
GrpEdit.Text := s;
end else
begin
if Var2Edit.Text = '' then
Var2Edit.Text := s;
end;
end;
UpdateBtnStates;
end;
end;
procedure TTwoPropForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
end. end.

View File

@@ -141,7 +141,7 @@ inherited WithinANOVAFrm: TWithinANOVAFrm
Top = 25 Top = 25
Width = 124 Width = 124
Caption = 'Test Assumptions' Caption = 'Test Assumptions'
TabOrder = 1 TabOrder = 2
end end
object PlotChk: TCheckBox object PlotChk: TCheckBox
Left = 156 Left = 156
@@ -149,7 +149,7 @@ inherited WithinANOVAFrm: TWithinANOVAFrm
Top = 6 Top = 6
Width = 79 Width = 79
Caption = 'Plot Means' Caption = 'Plot Means'
TabOrder = 2 TabOrder = 1
end end
end end
object SelList: TListBox[11] object SelList: TListBox[11]

View File

@@ -911,9 +911,9 @@ end;
// Menu "Analysis" > "Comparisons" > "Difference beween Proportions" // Menu "Analysis" > "Comparisons" > "Difference beween Proportions"
procedure TOS3MainFrm.mnuAnalysisComp_PropDiffClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisComp_PropDiffClick(Sender: TObject);
begin begin
if TwoPropFrm = nil then if TwoPropForm = nil then
Application.CreateForm(TTwoPropFrm, TwoPropFrm); Application.CreateForm(TTwoPropForm, TwoPropForm);
TwoPropFrm.ShowModal; TwoPropForm.Show;
end; end;
// Menu "Analysis" > "Comparisons" > "t-tests" // Menu "Analysis" > "Comparisons" > "t-tests"
@@ -924,14 +924,6 @@ begin
TTestFrm.ShowModal; TTestFrm.ShowModal;
end; end;
// Menu "Analysis" > "Nonparametric" > "Kappa and Weighted Kappa"
procedure TOS3MainFrm.mnuAnalysisNonPar_WeightedKappaClick(Sender: TObject);
begin
if WeightedKappaFrm = nil then
Application.CreateForm(TWeightedKappaFrm, WeightedKappaFrm);
WeightedKappaFrm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "Within Subjects mnuAnalysisComp_Anova" // Menu "Analysis" > "Comparisons" > "Within Subjects mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_WithinAnovaClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisComp_WithinAnovaClick(Sender: TObject);
begin begin
@@ -1661,14 +1653,6 @@ end;
// Menu "Analysis" > "Nonparametric" > "Generalized Kappa"
procedure TOS3MainFrm.mnuAnalysisNonPar_GenKappaClick(Sender: TObject);
begin
if GenKappaFrm = nil then
Application.CreateForm(TGenKappaFrm, GenKappaFrm);
GenKappaFrm.ShowModal;
end;
// Menu "Analysis" > "Nonparametric" > "General Linear Model" // Menu "Analysis" > "Nonparametric" > "General Linear Model"
procedure TOS3MainFrm.mnuAnalysisComp_GLMClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisComp_GLMClick(Sender: TObject);
begin begin
@@ -1717,14 +1701,6 @@ begin
LatinSqrsFrm.ShowModal; LatinSqrsFrm.ShowModal;
end; end;
// Menu "Analysis" > "Nonparametric" > "Life table"
procedure TOS3MainFrm.mnuAnalysisNonPar_LifeTableClick(Sender: TObject);
begin
if LifeTableForm = nil then
Application.CreateForm(TLifeTableForm, LifeTableForm);
LifeTableForm.ShowModal;
end;
procedure TOS3MainFrm.MatManMnuClick(Sender: TObject); procedure TOS3MainFrm.MatManMnuClick(Sender: TObject);
begin begin
if MatManFrm = nil then if MatManFrm = nil then
@@ -1919,6 +1895,30 @@ begin
SRHTestForm.Show; SRHTestForm.Show;
end; end;
// Menu "Analysis" > "Nonparametric" > "Generalized Kappa"
procedure TOS3MainFrm.mnuAnalysisNonPar_GenKappaClick(Sender: TObject);
begin
if GenKappaFrm = nil then
Application.CreateForm(TGenKappaFrm, GenKappaFrm);
GenKappaFrm.ShowModal;
end;
// Menu "Analysis" > "Nonparametric" > "Kappa and Weighted Kappa"
procedure TOS3MainFrm.mnuAnalysisNonPar_WeightedKappaClick(Sender: TObject);
begin
if WeightedKappaFrm = nil then
Application.CreateForm(TWeightedKappaFrm, WeightedKappaFrm);
WeightedKappaFrm.ShowModal;
end;
// Menu "Analysis" > "Nonparametric" > "Life table"
procedure TOS3MainFrm.mnuAnalysisNonPar_LifeTableClick(Sender: TObject);
begin
if LifeTableForm = nil then
Application.CreateForm(TLifeTableForm, LifeTableForm);
LifeTableForm.ShowModal;
end;
{ Descriptive statistics commands } { Descriptive statistics commands }