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>
<Filename Value="forms\analysis\comparisons\twopropunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="TwoPropFrm"/>
<ComponentName Value="TwoPropForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="TwoPropUnit"/>

View File

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

View File

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

View File

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

View File

@ -911,9 +911,9 @@ end;
// Menu "Analysis" > "Comparisons" > "Difference beween Proportions"
procedure TOS3MainFrm.mnuAnalysisComp_PropDiffClick(Sender: TObject);
begin
if TwoPropFrm = nil then
Application.CreateForm(TTwoPropFrm, TwoPropFrm);
TwoPropFrm.ShowModal;
if TwoPropForm = nil then
Application.CreateForm(TTwoPropForm, TwoPropForm);
TwoPropForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "t-tests"
@ -924,14 +924,6 @@ begin
TTestFrm.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" > "Comparisons" > "Within Subjects mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_WithinAnovaClick(Sender: TObject);
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"
procedure TOS3MainFrm.mnuAnalysisComp_GLMClick(Sender: TObject);
begin
@ -1717,14 +1701,6 @@ begin
LatinSqrsFrm.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;
procedure TOS3MainFrm.MatManMnuClick(Sender: TObject);
begin
if MatManFrm = nil then
@ -1919,6 +1895,30 @@ begin
SRHTestForm.Show;
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 }