LazStats: Inherit WicoxonUnit from TBasicStatsReportForm. Rename some more *Frm forms to *Form.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7809 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-26 14:02:37 +00:00
parent 42b9a85a01
commit eb11d1eda2
8 changed files with 537 additions and 602 deletions

View File

@ -705,7 +705,7 @@
<Unit75> <Unit75>
<Filename Value="forms\analysis\nonparametric\chisqrunit.pas"/> <Filename Value="forms\analysis\nonparametric\chisqrunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="ChiSqrFrm"/> <ComponentName Value="ChiSqrForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="ChiSqrUnit"/> <UnitName Value="ChiSqrUnit"/>
@ -713,7 +713,7 @@
<Unit76> <Unit76>
<Filename Value="forms\analysis\nonparametric\spearmanunit.pas"/> <Filename Value="forms\analysis\nonparametric\spearmanunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="SpearmanFrm"/> <ComponentName Value="SpearmanForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="SpearmanUnit"/> <UnitName Value="SpearmanUnit"/>
@ -753,7 +753,7 @@
<Unit81> <Unit81>
<Filename Value="forms\analysis\nonparametric\wilcoxonunit.pas"/> <Filename Value="forms\analysis\nonparametric\wilcoxonunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="WilcoxonFrm"/> <ComponentName Value="WilcoxonForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="WilcoxonUnit"/> <UnitName Value="WilcoxonUnit"/>

View File

@ -1,4 +1,4 @@
inherited ChiSqrFrm: TChiSqrFrm inherited ChiSqrForm: TChiSqrForm
Left = 425 Left = 425
Height = 503 Height = 503
Top = 216 Top = 216

View File

@ -12,9 +12,9 @@ uses
type type
{ TChiSqrFrm } { TChiSqrForm }
TChiSqrFrm = class(TBasicStatsReportForm) TChiSqrForm = class(TBasicStatsReportForm)
ObsChk: TCheckBox; ObsChk: TCheckBox;
ExpChk: TCheckBox; ExpChk: TCheckBox;
PageControl: TPageControl; PageControl: TPageControl;
@ -111,7 +111,7 @@ type
end; end;
var var
ChiSqrFrm: TChiSqrFrm; ChiSqrForm: TChiSqrForm;
implementation implementation
@ -121,9 +121,9 @@ uses
Math, Math,
Utils, GridProcs, MatrixUnit; Utils, GridProcs, MatrixUnit;
{ TChiSqrFrm } { TChiSqrForm }
constructor TChiSqrFrm.Create(AOwner: TComponent); constructor TChiSqrForm.Create(AOwner: TComponent);
begin begin
inherited; inherited;
if DictionaryFrm = nil then if DictionaryFrm = nil then
@ -170,7 +170,7 @@ begin
end; end;
procedure TChiSqrFrm.AdjustConstraints; procedure TChiSqrForm.AdjustConstraints;
begin begin
inherited; inherited;
@ -185,7 +185,7 @@ begin
end; end;
function TChiSqrFrm.CalcGStatistic(const AFrequencies: IntDyneMat; function TChiSqrForm.CalcGStatistic(const AFrequencies: IntDyneMat;
const AExpected: DblDyneMat): Double; const AExpected: DblDyneMat): Double;
var var
numRows, numCols: Integer; numRows, numCols: Integer;
@ -201,7 +201,7 @@ begin
end; end;
function TChiSqrFrm.CalcLikelihoodRatio(const AFrequencies: IntDyneMat; function TChiSqrForm.CalcLikelihoodRatio(const AFrequencies: IntDyneMat;
const AExpected: DblDyneMat): Double; const AExpected: DblDyneMat): Double;
var var
numRows, numCols: Integer; numRows, numCols: Integer;
@ -217,7 +217,7 @@ begin
end; end;
function TChiSqrFrm.CalcPearsonR(const AFrequencies: IntDyneMat): Double; function TChiSqrForm.CalcPearsonR(const AFrequencies: IntDyneMat): Double;
var var
numRows, numCols, numCases: Integer; numRows, numCols, numCases: Integer;
sumX, sumY: Double; sumX, sumY: Double;
@ -254,7 +254,7 @@ begin
Result := Result / sqrt(varX * varY); Result := Result / sqrt(varX * varY);
end; end;
procedure TChiSqrFrm.ColInClick(Sender: TObject); procedure TChiSqrForm.ColInClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
@ -268,7 +268,7 @@ begin
end; end;
procedure TChiSqrFrm.ColOutClick(Sender: TObject); procedure TChiSqrForm.ColOutClick(Sender: TObject);
begin begin
if ColEdit.Text <> '' then if ColEdit.Text <> '' then
begin begin
@ -279,7 +279,7 @@ begin
end; end;
procedure TChiSqrFrm.Compute; procedure TChiSqrForm.Compute;
var var
ColNoSelected: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil;
Freq: IntDyneMat = nil; Freq: IntDyneMat = nil;
@ -434,7 +434,7 @@ begin
end; end;
procedure TChiSqrFrm.DepInClick(Sender: TObject); procedure TChiSqrForm.DepInClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
@ -448,7 +448,7 @@ begin
end; end;
procedure TChiSqrFrm.DepOutClick(Sender: TObject); procedure TChiSqrForm.DepOutClick(Sender: TObject);
begin begin
if DepEdit.Text <> '' then if DepEdit.Text <> '' then
begin begin
@ -459,7 +459,7 @@ begin
end; end;
procedure TChiSqrFrm.FrequenciesToGrid(const AFrequencies: IntDyneMat); procedure TChiSqrForm.FrequenciesToGrid(const AFrequencies: IntDyneMat);
var var
numRows, numCols: Integer; numRows, numCols: Integer;
row, col: Integer; row, col: Integer;
@ -514,7 +514,7 @@ begin
end; end;
procedure TChiSqrFrm.GetExpectedAndCellChiSqr(const AFrequencies: IntDyneMat; procedure TChiSqrForm.GetExpectedAndCellChiSqr(const AFrequencies: IntDyneMat;
out AExpected, ACellChiSqr: DblDyneMat; out AExpected, ACellChiSqr: DblDyneMat;
out AChiSqr: Double); out AChiSqr: Double);
var var
@ -547,7 +547,7 @@ begin
end; end;
procedure TChiSqrFrm.GetFrequencies(const AColNoSelected: IntDyneVec; procedure TChiSqrForm.GetFrequencies(const AColNoSelected: IntDyneVec;
ARowIndex, AColIndex, ADepIndex: Integer; out ANumRows, ANumCols, ANumCases: Integer; ARowIndex, AColIndex, ADepIndex: Integer; out ANumRows, ANumCols, ANumCases: Integer;
out AFrequencies: IntDyneMat); out AFrequencies: IntDyneMat);
var var
@ -636,7 +636,7 @@ end;
// 2 x 2 corrected chi-square // 2 x 2 corrected chi-square
procedure TChiSqrFrm.GetYatesCorrection(const AFrequencies: IntDyneMat; procedure TChiSqrForm.GetYatesCorrection(const AFrequencies: IntDyneMat;
out AdjChiSqr: Double); out AdjChiSqr: Double);
var var
n, m, numCases: Integer; n, m, numCases: Integer;
@ -650,7 +650,7 @@ begin
end; end;
procedure TChiSqrFrm.GetColProportions(const AFrequencies: IntDyneMat; procedure TChiSqrForm.GetColProportions(const AFrequencies: IntDyneMat;
out AProportions: DblDyneMat); out AProportions: DblDyneMat);
var var
numRows, numCols: Integer; numRows, numCols: Integer;
@ -676,7 +676,7 @@ begin
end; end;
procedure TChiSqrFrm.GetRowProportions(const AFrequencies: IntDyneMat; procedure TChiSqrForm.GetRowProportions(const AFrequencies: IntDyneMat;
out AProportions: DblDyneMat); out AProportions: DblDyneMat);
var var
numRows, numCols: Integer; numRows, numCols: Integer;
@ -702,7 +702,7 @@ begin
end; end;
procedure TChiSqrFrm.GetTotalProportions(const AFrequencies: IntDyneMat; procedure TChiSqrForm.GetTotalProportions(const AFrequencies: IntDyneMat;
out AProportions: DblDyneMat); out AProportions: DblDyneMat);
var var
numRows, numCols, numCases: Integer; numRows, numCols, numCases: Integer;
@ -720,7 +720,7 @@ begin
end; end;
procedure TChiSqrFrm.InputGrpClick(Sender: TObject); procedure TChiSqrForm.InputGrpClick(Sender: TObject);
begin begin
// InputGrp = 0: have to count cases in each row and col combination // InputGrp = 0: have to count cases in each row and col combination
// = 1: frequencies available for each row and column combo // = 1: frequencies available for each row and column combo
@ -735,7 +735,7 @@ begin
end; end;
procedure TChiSqrFrm.ProcessAndReportCellChiSqr(const ACellChiSqr: DblDyneMat; procedure TChiSqrForm.ProcessAndReportCellChiSqr(const ACellChiSqr: DblDyneMat;
const ARowLabels, AColLabels: StrDyneVec; ANumCases: Integer); const ARowLabels, AColLabels: StrDyneVec; ANumCases: Integer);
var var
lReport: TStrings; lReport: TStrings;
@ -755,7 +755,7 @@ begin
end; end;
procedure TChiSqrFrm.ProcessAndReportFrequencies(const AFrequencies: IntDyneMat; procedure TChiSqrForm.ProcessAndReportFrequencies(const AFrequencies: IntDyneMat;
const AExpected: DblDyneMat; const ARowLabels, AColLabels: StrDyneVec); const AExpected: DblDyneMat; const ARowLabels, AColLabels: StrDyneVec);
var var
lReport: TStrings; lReport: TStrings;
@ -789,7 +789,7 @@ begin
end; end;
procedure TChiSqrFrm.ProcessAndReportProportions(const AFrequencies: IntDyneMat; procedure TChiSqrForm.ProcessAndReportProportions(const AFrequencies: IntDyneMat;
const ARowLabels, AColLabels: StrDyneVec); const ARowLabels, AColLabels: StrDyneVec);
var var
lReport: TStrings; lReport: TStrings;
@ -826,7 +826,7 @@ begin
end; end;
procedure TChiSqrFrm.Reset; procedure TChiSqrForm.Reset;
var var
i: integer; i: integer;
begin begin
@ -868,7 +868,7 @@ begin
end; end;
procedure TChiSqrFrm.RowInClick(Sender: TObject); procedure TChiSqrForm.RowInClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
@ -882,7 +882,7 @@ begin
end; end;
procedure TChiSqrFrm.RowOutClick(Sender: TObject); procedure TChiSqrForm.RowOutClick(Sender: TObject);
begin begin
if RowEdit.Text <> '' then if RowEdit.Text <> '' then
begin begin
@ -893,7 +893,7 @@ begin
end; end;
procedure TChiSqrFrm.UpdateBtnStates; procedure TChiSqrForm.UpdateBtnStates;
begin begin
inherited; inherited;
@ -914,7 +914,7 @@ begin
end; end;
function TChiSqrFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; function TChiSqrForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var var
n: Integer; n: Integer;
begin begin
@ -962,7 +962,7 @@ begin
end; end;
procedure TChiSqrFrm.VarListDblClick(Sender: TObject); procedure TChiSqrForm.VarListDblClick(Sender: TObject);
var var
index: Integer; index: Integer;
s: String; s: String;
@ -983,7 +983,7 @@ begin
end; end;
procedure TChiSqrFrm.VarListSelectionChange(Sender: TObject; User: boolean); procedure TChiSqrForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin begin
UpdateBtnStates; UpdateBtnStates;
end; end;

View File

@ -1,4 +1,4 @@
inherited SpearmanFrm: TSpearmanFrm inherited SpearmanForm: TSpearmanForm
Left = 531 Left = 531
Height = 347 Height = 347
Top = 246 Top = 246

View File

@ -11,9 +11,9 @@ uses
type type
{ TSpearmanFrm } { TSpearmanForm }
TSpearmanFrm = class(TBasicStatsReportForm) TSpearmanForm = class(TBasicStatsReportForm)
Bevel1: TBevel; Bevel1: TBevel;
XIn: TBitBtn; XIn: TBitBtn;
XOut: TBitBtn; XOut: TBitBtn;
@ -37,13 +37,14 @@ type
procedure AdjustConstraints; override; procedure AdjustConstraints; override;
procedure Compute; override; procedure Compute; override;
procedure UpdateBtnStates; override; procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): boolean; override;
public public
procedure Reset; override; procedure Reset; override;
end; end;
var var
SpearmanFrm: TSpearmanFrm; SpearmanForm: TSpearmanForm;
implementation implementation
@ -53,9 +54,9 @@ implementation
uses uses
Math, MathUnit; Math, MathUnit;
{ TSpearmanFrm } { TSpearmanForm }
procedure TSpearmanFrm.AdjustConstraints; procedure TSpearmanForm.AdjustConstraints;
begin begin
inherited; inherited;
@ -66,7 +67,7 @@ begin
end; end;
procedure TSpearmanFrm.Compute; procedure TSpearmanForm.Compute;
var var
index: IntDyneMat = nil; index: IntDyneMat = nil;
Ranks: DblDyneMat = nil; Ranks: DblDyneMat = nil;
@ -82,15 +83,6 @@ var
VarX, VarY, SDX, SDY, MeanX, MeanY, Rxy: double; VarX, VarY, SDX, SDY, MeanX, MeanY, Rxy: double;
lReport: TStrings; lReport: TStrings;
begin begin
if (XEdit.Text = '') then begin
MessageDlg('X variable is not selected.', mtError, [mbOK], 0);
exit;
end;
if (YEdit.Text = '') then begin
MessageDlg('Y variable is not selected.', mtError, [mbOK], 0);
exit;
end;
// Allocate memory // Allocate memory
SetLength(ColNoSelected, NoVariables); SetLength(ColNoSelected, NoVariables);
SetLength(index, NoCases, 2); SetLength(index, NoCases, 2);
@ -368,7 +360,7 @@ begin
end; end;
procedure TSpearmanFrm.Reset; procedure TSpearmanForm.Reset;
var var
i: integer; i: integer;
begin begin
@ -384,7 +376,7 @@ begin
end; end;
procedure TSpearmanFrm.UpdateBtnStates; procedure TSpearmanForm.UpdateBtnStates;
begin begin
inherited; inherited;
@ -395,13 +387,33 @@ begin
end; end;
procedure TSpearmanFrm.VarListSelectionChange(Sender: TObject; User: boolean); function TSpearmanForm.Validate(out AMsg: String; out AControl: TWinControl): boolean;
begin
Result := false;
if (XEdit.Text = '') then begin
AMsg := 'X variable is not selected.';
AControl := XEdit;
exit;
end;
if (YEdit.Text = '') then begin
AMsg := 'Y variable is not selected.';
AControl := YEdit;
exit;
end;
Result := true;
end;
procedure TSpearmanForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TSpearmanFrm.VarListDblClick(Sender: TObject); procedure TSpearmanForm.VarListDblClick(Sender: TObject);
var var
index: Integer; index: Integer;
s: String; s: String;
@ -420,7 +432,7 @@ begin
end; end;
procedure TSpearmanFrm.XInClick(Sender: TObject); procedure TSpearmanForm.XInClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
@ -434,7 +446,7 @@ begin
end; end;
procedure TSpearmanFrm.XOutClick(Sender: TObject); procedure TSpearmanForm.XOutClick(Sender: TObject);
begin begin
if XEdit.Text <> '' then if XEdit.Text <> '' then
begin begin
@ -445,7 +457,7 @@ begin
end; end;
procedure TSpearmanFrm.YInClick(Sender: TObject); procedure TSpearmanForm.YInClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
@ -459,7 +471,7 @@ begin
end; end;
procedure TSpearmanFrm.YOutClick(Sender: TObject); procedure TSpearmanForm.YOutClick(Sender: TObject);
begin begin
if YEdit.Text <> '' then if YEdit.Text <> '' then
begin begin

View File

@ -1,267 +1,184 @@
object WilcoxonFrm: TWilcoxonFrm inherited WilcoxonForm: TWilcoxonForm
Left = 498 Left = 498
Height = 352 Height = 294
Top = 336 Top = 336
Width = 436 Width = 478
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/WilcoxonMatched-PairsSignedRanks.htm' HelpKeyword = 'html/WilcoxonMatched-PairsSignedRanks.htm'
AutoSize = True
BorderStyle = bsDialog
Caption = 'Wilcoxon Matched Pairs Signed Ranks Test' Caption = 'Wilcoxon Matched Pairs Signed Ranks Test'
ClientHeight = 352 ClientHeight = 294
ClientWidth = 436 ClientWidth = 478
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 278
OnShow = FormShow ClientHeight = 278
Position = poMainFormCenter inherited CloseBtn: TButton
LCLVersion = '2.1.0.0' Top = 253
object Label1: TLabel end
AnchorSideLeft.Control = Owner inherited ComputeBtn: TButton
AnchorSideTop.Control = Owner Top = 253
Left = 8 end
inherited ResetBtn: TButton
Top = 253
end
inherited HelpBtn: TButton
Top = 253
end
inherited ButtonBevel: TBevel
Top = 237
end
object Label1: TLabel[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
Left = 0
Height = 15 Height = 15
Top = 8 Top = 0
Width = 97 Width = 97
BorderSpacing.Left = 8 Caption = 'Available Variables'
BorderSpacing.Top = 8
Caption = 'Variables Available'
ParentColor = False ParentColor = False
end end
object Label2: TLabel object Label2: TLabel[6]
AnchorSideLeft.Control = Var1Edit AnchorSideLeft.Control = Var1Edit
AnchorSideBottom.Control = Var1Edit AnchorSideBottom.Control = Var1Edit
Left = 240 Left = 166
Height = 15 Height = 15
Top = 33 Top = 21
Width = 50 Width = 50
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Variable 1' Caption = 'Variable 1'
ParentColor = False ParentColor = False
end end
object Label3: TLabel object Label3: TLabel[7]
AnchorSideLeft.Control = Var2Edit AnchorSideLeft.Control = Var2Edit
AnchorSideBottom.Control = Var2Edit AnchorSideBottom.Control = Var2Edit
Left = 240 Left = 166
Height = 15 Height = 15
Top = 125 Top = 109
Width = 50 Width = 50
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Variable 2' Caption = 'Variable 2'
ParentColor = False ParentColor = False
end end
object VarList: TListBox object VarList: TListBox[8]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Var1In AnchorSideRight.Control = Var1In
AnchorSideBottom.Control = Bevel1 AnchorSideBottom.Control = ButtonBevel
Left = 9 Left = 0
Height = 278 Height = 220
Top = 25 Top = 17
Width = 187 Width = 126
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 9
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 6
Constraints.MinHeight = 200
ItemHeight = 0 ItemHeight = 0
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 4
end end
object Var1In: TBitBtn object Var1In: TBitBtn[9]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
Left = 204 Left = 132
Height = 28 Height = 26
Top = 25 Top = 17
Width = 28 Width = 26
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
OnClick = Var1InClick OnClick = Var1InClick
Spacing = 0 Spacing = 0
TabOrder = 1 TabOrder = 5
end end
object Var1Out: TBitBtn object Var1Out: TBitBtn[10]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1In AnchorSideTop.Control = Var1In
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 204 Left = 132
Height = 28 Height = 26
Top = 57 Top = 47
Width = 28 Width = 26
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
OnClick = Var1OutClick OnClick = Var1OutClick
Spacing = 0 Spacing = 0
TabOrder = 2 TabOrder = 6
end end
object Var2In: TBitBtn object Var2In: TBitBtn[11]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1Out AnchorSideTop.Control = Var1Out
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 204 Left = 132
Height = 28 Height = 26
Top = 117 Top = 105
Width = 28 Width = 26
BorderSpacing.Top = 32 BorderSpacing.Top = 32
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
OnClick = Var2InClick OnClick = Var2InClick
Spacing = 0 Spacing = 0
TabOrder = 4 TabOrder = 7
end end
object Var2Out: TBitBtn object Var2Out: TBitBtn[12]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2In AnchorSideTop.Control = Var2In
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 204 Left = 132
Height = 28 Height = 26
Top = 149 Top = 135
Width = 28 Width = 26
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
OnClick = Var2OutClick OnClick = Var2OutClick
Spacing = 0 Spacing = 0
TabOrder = 5 TabOrder = 8
end end
object Var1Edit: TEdit object Var1Edit: TEdit[13]
AnchorSideLeft.Control = Var1In AnchorSideLeft.Control = Var1In
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var1Out AnchorSideBottom.Control = Var1Out
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 240 Left = 166
Height = 23 Height = 23
Top = 50 Top = 38
Width = 188 Width = 125
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 3 TabOrder = 9
Text = 'Var1Edit' Text = 'Var1Edit'
end end
object Var2Edit: TEdit object Var2Edit: TEdit[14]
AnchorSideLeft.Control = Var2In AnchorSideLeft.Control = Var2In
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var2Out AnchorSideBottom.Control = Var2Out
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 240 Left = 166
Height = 23 Height = 23
Top = 142 Top = 126
Width = 188 Width = 125
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 6 TabOrder = 10
Text = 'Var2Edit' Text = 'Var2Edit'
end end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 227
Height = 25
Top = 319
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 8
end end
object ComputeBtn: TButton inherited ParamsSplitter: TSplitter
AnchorSideRight.Control = CloseBtn Height = 294
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 289
Height = 25
Top = 319
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 9
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 373
Height = 25
Top = 319
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 10
end
object HelpBtn: TButton
Tag = 156
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 168
Height = 25
Top = 319
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 7
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 303
Width = 436
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Bevel2: TBevel
Left = 3
Height = 20
Top = 336
Width = 16
Shape = bsSpacer
end end
end end

View File

@ -5,21 +5,15 @@ unit WilcoxonUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls, StdCtrls, Buttons, ExtCtrls,
MainUnit, OutputUnit, FunctionsLib, Globals, DataProcs, ContextHelpUnit; MainUnit, FunctionsLib, Globals, DataProcs, BasicStatsReportFormUnit;
type type
{ TWilcoxonFrm } { TWilcoxonForm }
TWilcoxonFrm = class(TForm) TWilcoxonForm = class(TBasicStatsReportForm)
Bevel1: TBevel;
Bevel2: TBevel;
HelpBtn: TButton;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
Var1Edit: TEdit; Var1Edit: TEdit;
Var2Edit: TEdit; Var2Edit: TEdit;
Label2: TLabel; Label2: TLabel;
@ -30,170 +24,72 @@ type
Var2Out: TBitBtn; Var2Out: TBitBtn;
Label1: TLabel; Label1: TLabel;
VarList: TListBox; VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure Var1InClick(Sender: TObject); procedure Var1InClick(Sender: TObject);
procedure Var1OutClick(Sender: TObject); procedure Var1OutClick(Sender: TObject);
procedure Var2InClick(Sender: TObject); procedure Var2InClick(Sender: TObject);
procedure Var2OutClick(Sender: TObject); procedure Var2OutClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean); procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; {%H-}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 } procedure Reset; override;
end; end;
var var
WilcoxonFrm: TWilcoxonFrm; WilcoxonForm: TWilcoxonForm;
implementation implementation
{$R *.lfm}
uses uses
Math; Math;
{ TWilcoxonFrm } { TWilcoxonForm }
procedure TWilcoxonFrm.ResetBtnClick(Sender: TObject); procedure TWilcoxonForm.AdjustConstraints;
begin
inherited;
ParamsPanel.Constraints.MinHeight := Var2Out.Top + Var2Out.Height +
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
ParamsPanel.Constraints.MinWidth := 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left;
end;
procedure TWilcoxonForm.Compute;
var var
i: integer; A: DblDyneVec = nil;
begin b: DblDyneVec = nil;
Var1Edit.Text := ''; d: DblDyneVec = nil;
Var2Edit.Text := ''; r: DblDyneVec = nil;
VarList.Items.Clear; index: IntDyneVec = nil;
for i := 1 to NoVariables do ColNoSelected: IntDyneVec = nil;
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TWilcoxonFrm.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);
end;
UpdateBtnStates;
end;
procedure TWilcoxonFrm.Var1OutClick(Sender: TObject);
begin
if Var1Edit.Text <> '' then
begin
VarList.Items.Add(Var1Edit.Text);
Var1Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TWilcoxonFrm.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);
end;
UpdateBtnStates;
end;
procedure TWilcoxonFrm.Var2OutClick(Sender: TObject);
begin
if Var2Edit.Text <> '' then
begin
VarList.Items.Add(Var2Edit.Text);
Var2Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TWilcoxonFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TWilcoxonFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
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;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TWilcoxonFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TWilcoxonFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TWilcoxonFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TWilcoxonFrm.ComputeBtnClick(Sender: TObject);
var
zprob, numerator, denominator, z, negsum : double;
possum, t, sum, Avg : double;
A, b, d, r : DblDyneVec;
M, N, i, j, itemp, col1, col2, NoSelected: integer;
index : IntdyneVec;
ColNoSelected : IntDyneVec;
labelone, labeltwo, cellstring: string;
lReport: TStrings;
negcnt: Integer = 0; negcnt: Integer = 0;
poscnt: Integer = 0; poscnt: Integer = 0;
zprob, numerator, denominator, z, negsum: double;
possum, t, sum, Avg: double;
M, N, i, j, itemp, col1, col2, NoSelected: integer;
labelone, labeltwo, cellstring: string;
lReport: TStrings;
begin begin
if Var1Edit.Text = '' then
begin
MessageDlg('Variable 1 not selected.', mtError, [mbOK], 0);
exit;
end;
if Var2Edit.Text = '' then
begin
MessageDlg('Variable 2 not selected.', mtError, [mbOK], 0);
exit;
end;
negsum := 0.0; negsum := 0.0;
possum := 0.0; possum := 0.0;
NoSelected := 2; NoSelected := 2;
// Allocate memory // Allocate memory
SetLength(ColNoSelected,NoVariables); SetLength(ColNoSelected, NoVariables);
SetLength(A,NoCases); SetLength(A, NoCases);
SetLength(b,NoCases); SetLength(b, NoCases);
SetLength(d,NoCases); SetLength(d, NoCases);
SetLength(index,NoCases); SetLength(index, NoCases);
SetLength(r,NoCases); SetLength(r, NoCases);
// Get column numbers and labels of variables selected // Get column numbers and labels of variables selected
for i := 1 to NoVariables do for i := 1 to NoVariables do
@ -298,7 +194,8 @@ begin
for j := i to (i + M) do r[j-1] := Avg; for j := i to (i + M) do r[j-1] := Avg;
i := i + M + 1; i := i + M + 1;
end end
else i := i + 1; else
i := i + 1;
end; end;
// Assign sign of difference to ranks // Assign sign of difference to ranks
@ -318,8 +215,10 @@ begin
poscnt := poscnt + 1; poscnt := poscnt + 1;
end; end;
end; end;
if (negsum < possum) then t := negsum if (negsum < possum) then
else t := possum; t := negsum
else
t := possum;
numerator := t - ((N * (N + 1)) / 4.0); numerator := t - ((N * (N + 1)) / 4.0);
denominator := sqrt((N * (N + 1) * (2 * N + 1)) / 24.0); denominator := sqrt((N * (N + 1) * (2 * N + 1)) / 24.0);
z := abs(numerator / denominator); z := abs(numerator / denominator);
@ -333,6 +232,7 @@ begin
lReport.Add(''); lReport.Add('');
lReport.Add('Ordered Cases with cases having 0 differences eliminated:'); lReport.Add('Ordered Cases with cases having 0 differences eliminated:');
lReport.Add('Number of cases with absolute differences greater than 0: %d', [N]); lReport.Add('Number of cases with absolute differences greater than 0: %d', [N]);
lReport.Add('');
lReport.Add('CASE %10s %10s Difference Signed Rank', [labelone, labeltwo]); lReport.Add('CASE %10s %10s Difference Signed Rank', [labelone, labeltwo]);
for i := 1 to N do for i := 1 to N do
lReport.Add('%3d %6.2f %6.2f %6.2f %6.2f', [index[i-1], A[i-1], b[i-1], d[i-1], r[i-1]]); lReport.Add('%3d %6.2f %6.2f %6.2f %6.2f', [index[i-1], A[i-1], b[i-1], d[i-1], r[i-1]]);
@ -343,21 +243,34 @@ begin
lReport.Add(''); lReport.Add('');
lReport.Add('NOTE: For N < 25 use tabled values for Wilcoxon Test'); lReport.Add('NOTE: For N < 25 use tabled values for Wilcoxon Test');
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
r := nil;
index := nil;
d := nil;
b := nil;
A := nil;
ColNoSelected := nil;
end; end;
end; end;
procedure TWilcoxonFrm.UpdateBtnStates;
procedure TWilcoxonForm.Reset;
var
i: integer;
begin begin
inherited;
Var1Edit.Text := '';
Var2Edit.Text := '';
VarList.Items.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
procedure TWilcoxonForm.UpdateBtnStates;
begin
inherited;
Var1In.Enabled := (VarList.ItemIndex > -1) and (Var1Edit.Text = ''); Var1In.Enabled := (VarList.ItemIndex > -1) and (Var1Edit.Text = '');
Var2In.Enabled := (VarList.ItemIndex > -1) and (Var2Edit.Text = ''); Var2In.Enabled := (VarList.ItemIndex > -1) and (Var2Edit.Text = '');
Var1Out.Enabled := (Var1Edit.Text <> ''); Var1Out.Enabled := (Var1Edit.Text <> '');
@ -365,8 +278,101 @@ begin
end; end;
initialization procedure TWilcoxonForm.Var1InClick(Sender: TObject);
{$I wilcoxonunit.lrs} var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var1Edit.Text = '') then
begin
Var1Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TWilcoxonForm.Var1OutClick(Sender: TObject);
begin
if Var1Edit.Text <> '' then
begin
VarList.Items.Add(Var1Edit.Text);
Var1Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TWilcoxonForm.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);
end;
UpdateBtnStates;
end;
procedure TWilcoxonForm.Var2OutClick(Sender: TObject);
begin
if Var2Edit.Text <> '' then
begin
VarList.Items.Add(Var2Edit.Text);
Var2Edit.Text := '';
end;
UpdateBtnStates;
end;
function TWilcoxonForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
begin
Result := false;
if Var1Edit.Text = '' then
begin
AMsg := 'Variable 1 not selected.';
AControl := Var1Edit;
exit;
end;
if Var2Edit.Text = '' then
begin
AMsg := 'Variable 2 not selected.';
AControl := Var1Edit;
exit;
end;
Result := true;
end;
procedure TWilcoxonForm.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 if Var2Edit.Text = '' then
Var2Edit.Text := s;
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TWilcoxonForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
end. end.

View File

@ -1808,17 +1808,17 @@ end;
// Menu "Analysis" > "Nonparametric" > "Contingency Chi Square" // Menu "Analysis" > "Nonparametric" > "Contingency Chi Square"
procedure TOS3MainFrm.mnuAnalysisNonPar_ContingChiSqClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisNonPar_ContingChiSqClick(Sender: TObject);
begin begin
if ChiSqrFrm = nil then if ChiSqrForm = nil then
Application.CreateForm(TChiSqrFrm, ChiSqrFrm); Application.CreateForm(TChiSqrForm, ChiSqrForm);
ChiSqrFrm.ShowModal; ChiSqrForm.Show;
end; end;
// Menu "Analysis" > "Nonparametric" > "Spearman Rank Correlation" // Menu "Analysis" > "Nonparametric" > "Spearman Rank Correlation"
procedure TOS3MainFrm.mnuAnalysisNonPar_SpearmanClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisNonPar_SpearmanClick(Sender: TObject);
begin begin
if SpearmanFrm = nil then if SpearmanForm = nil then
Application.CreateForm(TSpearmanFrm, SpearmanFrm); Application.CreateForm(TSpearmanForm, SpearmanForm);
SpearmanFrm.ShowModal; SpearmanForm.Show;
end; end;
// Menu "Analysis" > "Nonparametric" > "Mann-Whitney U Test" // Menu "Analysis" > "Nonparametric" > "Mann-Whitney U Test"
@ -1856,9 +1856,9 @@ end;
// Menu "Analysis" > "Nonparametric" > "Matched Pairs Signed Ranks Test" // Menu "Analysis" > "Nonparametric" > "Matched Pairs Signed Ranks Test"
procedure TOS3MainFrm.mnuAnalysisNonPar_WilcoxonClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisNonPar_WilcoxonClick(Sender: TObject);
begin begin
if WilcoxonFrm = nil then if WilcoxonForm = nil then
Application.CreateForm(TWilcoxonFrm, WilcoxonFrm); Application.CreateForm(TWilcoxonForm, WilcoxonForm);
WilcoxonFrm.ShowModal; WilcoxonForm.Show;
end; end;
// Menu "Analysis" > "Financial" > "Loan Amortization Schedule" // Menu "Analysis" > "Financial" > "Loan Amortization Schedule"