LazStats: Use ReportFrame in DescriptiveUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7671 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2020-09-19 16:36:44 +00:00
parent a06c6498ba
commit a67c29af62
5 changed files with 430 additions and 359 deletions

View File

@ -1,307 +1,323 @@
object DescriptiveFrm: TDescriptiveFrm object DescriptiveFrm: TDescriptiveFrm
Left = 626 Left = 526
Height = 393 Height = 384
Top = 226 Top = 202
Width = 453 Width = 900
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/DistributionStatistics.htm' HelpKeyword = 'html/DistributionStatistics.htm'
AutoSize = True
Caption = 'Descriptive Statistics' Caption = 'Descriptive Statistics'
ClientHeight = 393 ClientHeight = 384
ClientWidth = 453 ClientWidth = 900
OnActivate = FormActivate OnActivate = FormActivate
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
Position = poMainFormCenter Position = poMainFormCenter
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
object CloseBtn: TButton object ReportPanel: TPanel
AnchorSideRight.Control = Owner Left = 343
AnchorSideRight.Side = asrBottom Height = 384
AnchorSideBottom.Control = Owner Top = 0
AnchorSideBottom.Side = asrBottom Width = 557
Left = 390 Align = alClient
Height = 25 Anchors = [akTop, akLeft, akRight]
Top = 360 BevelOuter = bvNone
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 9
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 244
Height = 25
Top = 360
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
object HelpBtn: TButton
Tag = 119
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 185
Height = 25
Top = 360
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 Label1: TLabel
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = CIEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CIEdit
Left = 8
Height = 15
Top = 325
Width = 174
BorderSpacing.Right = 8
Caption = 'Confidence Interval for the Mean'
ParentColor = False
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 15
Top = 8
Width = 46
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Owner
Left = 257
Height = 15
Top = 8
Width = 44
BorderSpacing.Top = 8
Caption = 'Selected'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = GroupBox1
Left = 8
Height = 208
Top = 25
Width = 187
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Constraints.MinHeight = 200
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object SelList: TListBox object ParamsPanel: TPanel
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 257
Height = 208
Top = 25
Width = 188
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object CIEdit: TEdit
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 190
Height = 23
Top = 321
Width = 41
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
TabOrder = 6
Text = '95.0'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = CIEdit
Left = 8 Left = 8
Height = 72 Height = 368
Top = 241 Top = 8
Width = 306 Width = 322
Anchors = [akLeft, akBottom] Align = alLeft
AutoSize = True BorderSpacing.Around = 8
BorderSpacing.Left = 8 BevelOuter = bvNone
BorderSpacing.Right = 8 ClientHeight = 368
BorderSpacing.Bottom = 8 ClientWidth = 322
Caption = 'Options' TabOrder = 1
ChildSizing.LeftRightSpacing = 12 object Label2: TLabel
ChildSizing.TopBottomSpacing = 6 AnchorSideLeft.Control = ParamsPanel
ChildSizing.HorizontalSpacing = 24 AnchorSideTop.Control = ParamsPanel
ChildSizing.VerticalSpacing = 2 Left = 0
ChildSizing.Layout = cclLeftToRightThenTopToBottom Height = 15
ChildSizing.ControlsPerLine = 2 Top = 0
ClientHeight = 52 Width = 46
ClientWidth = 302 Caption = 'Variables'
TabOrder = 5 ParentColor = False
object CaseChk: TCheckBox end
Left = 12 object VarList: TListBox
Height = 19 AnchorSideLeft.Control = ParamsPanel
Top = 6 AnchorSideTop.Control = Label2
Width = 138 AnchorSideTop.Side = asrBottom
BorderSpacing.Left = 12 AnchorSideRight.Control = AllBtn
BorderSpacing.Right = 12 AnchorSideBottom.Control = OptionsGroup
Caption = 'Casewise Deletion' Left = 0
Height = 199
Top = 17
Width = 130
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object CheckBox1: TCheckBox object Label3: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = ParamsPanel
Left = 192
Height = 15
Top = 0
Width = 44
Caption = 'Selected'
ParentColor = False
end
object SelList: TListBox
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 174 AnchorSideRight.Control = ParamsPanel
Height = 19 AnchorSideRight.Side = asrBottom
Top = 6 AnchorSideBottom.Control = VarList
Width = 116 AnchorSideBottom.Side = asrBottom
BorderSpacing.Left = 12 Left = 192
BorderSpacing.Right = 12 Height = 199
Caption = 'z Scores to Grid' Top = 17
Width = 130
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object InBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
AnchorSideRight.Side = asrBottom
Left = 147
Height = 28
Top = 17
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1 TabOrder = 1
end end
object PcntileChk: TCheckBox object OutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 AnchorSideRight.Side = asrBottom
Height = 19 Left = 147
Top = 27 Height = 28
Width = 138 Top = 49
BorderSpacing.Left = 12 Width = 28
BorderSpacing.Right = 12 BorderSpacing.Top = 4
Caption = 'Show Percentile Ranks' Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2 TabOrder = 2
end end
object AltQrtilesChk: TCheckBox object AllBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 174 Left = 138
Height = 19 Height = 25
Top = 27 Top = 109
Width = 116 Width = 46
BorderSpacing.Left = 12 AutoSize = True
BorderSpacing.Right = 12 BorderSpacing.Top = 32
Caption = 'Show All Quartiles' Caption = 'ALL'
OnClick = AllBtnClick
TabOrder = 3 TabOrder = 3
end end
object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 267
Height = 25
Top = 343
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 9
end
object HelpBtn: TButton
Tag = 119
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 62
Height = 25
Top = 343
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 7
end
object Label1: TLabel
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = CIEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CIEdit
Left = 0
Height = 15
Top = 308
Width = 174
BorderSpacing.Right = 8
Caption = 'Confidence Interval for the Mean'
ParentColor = False
end
object OptionsGroup: TGroupBox
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CIEdit
Left = 0
Height = 72
Top = 224
Width = 306
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Bottom = 8
Caption = 'Options'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 52
ClientWidth = 302
TabOrder = 5
object CaseChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 138
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Casewise Deletion'
TabOrder = 0
end
object ZScoresToGridChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 174
Height = 19
Top = 6
Width = 116
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'z Scores to Grid'
TabOrder = 1
end
object PcntileChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 27
Width = 138
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Show Percentile Ranks'
TabOrder = 2
end
object AllQrtilesChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 174
Height = 19
Top = 27
Width = 116
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Caption = 'Show All Quartiles'
TabOrder = 3
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 327
Width = 322
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 183
Height = 25
Top = 343
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
end
object CIEdit: TEdit
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 182
Height = 23
Top = 304
Width = 41
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
TabOrder = 6
Text = '95.0'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 121
Height = 25
Top = 343
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 8
end
end end
object InBtn: TBitBtn object Splitter1: TSplitter
AnchorSideLeft.Control = Owner Left = 338
AnchorSideLeft.Side = asrCenter Height = 384
AnchorSideTop.Control = VarList Top = 0
AnchorSideRight.Side = asrBottom Width = 5
Left = 212 ResizeStyle = rsPattern
Height = 28
Top = 25
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 212
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 2
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom
Left = 203
Height = 25
Top = 117
Width = 46
AutoSize = True
BorderSpacing.Top = 32
Caption = 'ALL'
OnClick = AllBtnClick
TabOrder = 3
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 344
Width = 453
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 306
Height = 25
Top = 360
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
end end
end end

View File

@ -5,9 +5,9 @@ unit DescriptiveUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, DictionaryUnit, ContextHelpUnit; MainUnit, Globals, FunctionsLib, ReportFrameUnit, DataProcs, DictionaryUnit, ContextHelpUnit;
type type
@ -18,13 +18,15 @@ type
Bevel1: TBevel; Bevel1: TBevel;
ComputeBtn: TButton; ComputeBtn: TButton;
CaseChk: TCheckBox; CaseChk: TCheckBox;
CheckBox1: TCheckBox; ZScoresToGridChk: TCheckBox;
AltQrtilesChk: TCheckBox; AllQrtilesChk: TCheckBox;
HelpBtn: TButton; HelpBtn: TButton;
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
ReportPanel: TPanel;
ParamsPanel: TPanel;
PcntileChk: TCheckBox; PcntileChk: TCheckBox;
GroupBox1: TGroupBox; OptionsGroup: TGroupBox;
InBtn: TBitBtn; InBtn: TBitBtn;
OutBtn: TBitBtn; OutBtn: TBitBtn;
AllBtn: TBitBtn; AllBtn: TBitBtn;
@ -32,6 +34,7 @@ type
CloseBtn: TButton; CloseBtn: TButton;
CIEdit: TEdit; CIEdit: TEdit;
Label1: TLabel; Label1: TLabel;
Splitter1: TSplitter;
VarList: TListBox; VarList: TListBox;
SelList: TListBox; SelList: TListBox;
procedure AllBtnClick(Sender: TObject); procedure AllBtnClick(Sender: TObject);
@ -47,14 +50,10 @@ type
private private
{ private declarations } { private declarations }
FReportFrame: TReportFrame;
FAutoSized: Boolean; FAutoSized: Boolean;
sum, variance, stddev, value, mean, min, max, range, skew, prob, df, CI : double; sum, variance, stddev, value, mean, min, max, range, skew, prob, df, CI : double;
kurtosis, z, semean, seskew, sekurtosis, deviation, devsqr, M2, M3, M4 : double; kurtosis, z, semean, seskew, sekurtosis, deviation, devsqr, M2, M3, M4 : double;
Q1, Q2, Q3, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q22, Q23, Q24, Q25, Q26 : double;
Q27, Q28, Q32, Q33, Q34, Q35, Q36, Q37, Q38, IQrange : double;
ncases, noselected : integer;
cellstring, gridstring: string;
selected : IntDyneVec;
procedure UpdateBtnStates; procedure UpdateBtnStates;
public public
@ -64,26 +63,27 @@ type
var var
DescriptiveFrm: TDescriptiveFrm; DescriptiveFrm: TDescriptiveFrm;
implementation implementation
{$R *.lfm}
uses uses
Math; Math;
{ TDescriptiveFrm } { TDescriptiveFrm }
procedure TDescriptiveFrm.ResetBtnClick(Sender: TObject); procedure TDescriptiveFrm.AllBtnClick(Sender: TObject);
var var
i: integer; i : integer;
begin begin
CIEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT); for i := 0 to VarList.Items.Count-1 do
SelList.Items.Add(VarList.Items.Strings[i]);
VarList.Clear; VarList.Clear;
SelList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Selected := nil;
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TDescriptiveFrm.FormActivate(Sender: TObject); procedure TDescriptiveFrm.FormActivate(Sender: TObject);
var var
w: Integer; w: Integer;
@ -91,69 +91,65 @@ begin
if FAutoSized then if FAutoSized then
exit; exit;
ParamsPanel.AutoSize := true;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w; HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w; ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w; ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w; CloseBtn.Constraints.MinWidth := w;
ParamsPanel.Constraints.MinHeight := AllBtn.Top + AllBtn.Height + OptionsGroup.Height +
CIEdit.Height + Bevel1.Height + CloseBtn.Height + VarList.BorderSpacing.Bottom +
OptionsGroup.BorderSpacing.Bottom + CloseBtn.BorderSpacing.Top;
ParamsPanel.Constraints.MinWidth := OptionsGroup.Width;
ParamsPanel.AutoSize := false;
Constraints.MinWidth := Width; Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Around*2;
Constraints.MinHeight := Height; Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + ParamsPanel.BorderSpacing.Around*2;
FAutoSized := true; FAutoSized := true;
end; end;
procedure TDescriptiveFrm.FormCreate(Sender: TObject); procedure TDescriptiveFrm.FormCreate(Sender: TObject);
begin begin
Assert(OS3MainFrm <> nil); Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm); if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
FReportFrame := TReportFrame.Create(self);
FReportFrame.Parent := ReportPanel;
FReportFrame.Align := alClient;
FReportFrame.ReportToolBar.Align := alRight;
FReportFrame.ReportToolbar.EdgeBorders := [];
end; end;
procedure TDescriptiveFrm.FormShow(Sender: TObject); procedure TDescriptiveFrm.FormShow(Sender: TObject);
begin begin
ResetBtnClick(self); ResetBtnClick(self);
end; end;
procedure TDescriptiveFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TDescriptiveFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TDescriptiveFrm.ComputeBtnClick(Sender: TObject); procedure TDescriptiveFrm.ComputeBtnClick(Sender: TObject);
var var
i, j, k, m: integer; i, j, k, m: integer;
nCases, noSelected: integer;
Q1, Q2, Q3, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q22, Q23, Q24, Q25, Q26: double;
Q27, Q28, Q32, Q33, Q34, Q35, Q36, Q37, Q38, IQrange: double;
num, den, cases: double; num, den, cases: double;
values, pcntrank: DblDyneVec; values: DblDyneVec = nil;
pcntRank: DblDyneVec = nil;
selected: IntDyneVec = nil;
cellString: String;
lReport: TStrings; lReport: TStrings;
begin begin
noselected := SelList.Items.Count; NoSelected := SelList.Items.Count;
if noSelected = 0 then if noSelected = 0 then
begin begin
MessageDlg('No variables selected.', mtError, [mbOK], 0); MessageDlg('No variables selected.', mtError, [mbOK], 0);
exit; exit;
end; end;
SetLength(Selected, noselected); SetLength(selected, noSelected);
// Get selected variables // Get selected variables
for i := 1 to noselected do for i := 1 to noselected do
@ -169,9 +165,9 @@ begin
lReport.Add(''); lReport.Add('');
SetLength(Values, NoCases); SetLength(Values, NoCases);
SetLength(pcntrank, NoCases); SetLength(pcntRank, NoCases);
for j := 1 to noselected do for j := 1 to noSelected do
begin begin
deviation := 0.0; deviation := 0.0;
devsqr := 0.0; devsqr := 0.0;
@ -195,13 +191,12 @@ begin
CI := (1.0 - CI) / 2.0; CI := (1.0 - CI) / 2.0;
CI := 1.0 - CI; CI := 1.0 - CI;
if CheckBox1.Checked then // add a new column to the grid if ZScoresToGridChk.Checked then // add a new column to the grid
begin begin
gridstring := OS3MainFrm.DataGrid.Cells[k,0]; cellstring := OS3MainFrm.DataGrid.Cells[k,0] + 'z';
gridstring := Gridstring + 'z'; DictionaryFrm.NewVar(NoVariables + 1);
DictionaryFrm.NewVar(NoVariables+1); DictionaryFrm.DictGrid.Cells[1, NoVariables] := cellstring;
DictionaryFrm.DictGrid.Cells[1,NoVariables] := gridstring; OS3MainFrm.DataGrid.Cells[NoVariables, 0] := cellstring;
OS3MainFrm.DataGrid.Cells[NoVariables,0] := gridstring;
end; end;
// Accumulate sums of squares, sums, etc. for variable j // Accumulate sums of squares, sums, etc. for variable j
@ -209,15 +204,15 @@ begin
max := -1.0e308; max := -1.0e308;
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,noselected,selected) then if not GoodRecord(i, noSelected, selected) then
continue; continue;
if CaseChk.Checked then if CaseChk.Checked then
begin begin
if not ValidValue(i,selected[j-1]) then if not ValidValue(i, selected[j-1]) then
continue; continue;
end end
else if not GoodRecord(i,noselected,selected) then else if not GoodRecord(i, noselected, selected) then
continue; continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]); value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]);
@ -261,9 +256,9 @@ begin
begin begin
if CaseChk.Checked then if CaseChk.Checked then
begin begin
if not ValidValue(i,selected[j-1]) then continue; if not ValidValue(i, selected[j-1]) then continue;
end else end else
if not GoodRecord(i,noselected,selected) then continue; if not GoodRecord(i, noselected, selected) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]); value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]);
if stddev > 0.0 then if stddev > 0.0 then
@ -274,7 +269,7 @@ begin
M3 := M3 + (deviation * devsqr); M3 := M3 + (deviation * devsqr);
M4 := M4 + (devsqr * devsqr); M4 := M4 + (devsqr * devsqr);
z := (value - mean) / stddev; z := (value - mean) / stddev;
if CheckBox1.Checked then if ZScoresToGridChk.Checked then
begin begin
cellstring := format('%8.5f',[z]); cellstring := format('%8.5f',[z]);
OS3MainFrm.DataGrid.Cells[NoVariables,i] := cellstring; OS3MainFrm.DataGrid.Cells[NoVariables,i] := cellstring;
@ -349,7 +344,7 @@ begin
lReport.Add(''); lReport.Add('');
end; end;
if (AltQrtilesChk.Checked) then if (AllQrtilesChk.Checked) then
begin begin
lReport.Add('Alternative Methods for Obtaining Quartiles'); lReport.Add('Alternative Methods for Obtaining Quartiles');
lReport.Add(' Method 1 2 3 4 5 6 7 8'); lReport.Add(' Method 1 2 3 4 5 6 7 8');
@ -381,8 +376,10 @@ begin
Q37 := Quartiles(7,0.75,ncases,values); Q37 := Quartiles(7,0.75,ncases,values);
Q38 := Quartiles(8,0.75,ncases,values); Q38 := Quartiles(8,0.75,ncases,values);
lReport.Add('Q3 %8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f', [Q3,Q32,Q33,Q34,Q35,Q36,Q37,Q38]); lReport.Add('Q3 %8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f', [Q3,Q32,Q33,Q34,Q35,Q36,Q37,Q38]);
lReport.Add('');
lReport.Add('NOTES:'); lReport.Add('NOTES:');
lReport.Add('Method 1 is the weighted average at X[np] where n is no. of cases, p is percentile / 100'); lReport.Add('Method 1 is the weighted average at X[np] where ');
lReport.Add(' n is no. of cases, p is percentile / 100');
lReport.Add('Method 2 is the weighted average at X[(n+1)p] This is used in this program.'); lReport.Add('Method 2 is the weighted average at X[(n+1)p] This is used in this program.');
lReport.Add('Method 3 is the empirical distribution function.'); lReport.Add('Method 3 is the empirical distribution function.');
lReport.Add('Method 4 is called the empirical distribution function - averaging.'); lReport.Add('Method 4 is called the empirical distribution function - averaging.');
@ -393,10 +390,10 @@ begin
lReport.Add('See the internet site http://www.xycoon.com/ for the above.'); lReport.Add('See the internet site http://www.xycoon.com/ for the above.');
lReport.Add(''); lReport.Add('');
end; // end of experimental alternatives end; // end of experimental alternatives
lReport.Add('--------------------------------------------------------------'); lReport.Add(DIVIDER_AUTO);
end; // next j variable end; // next j variable
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
@ -406,6 +403,34 @@ begin
end; end;
end; end;
procedure TDescriptiveFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TDescriptiveFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TDescriptiveFrm.OutBtnClick(Sender: TObject); procedure TDescriptiveFrm.OutBtnClick(Sender: TObject);
var var
i: integer; i: integer;
@ -424,14 +449,17 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TDescriptiveFrm.AllBtnClick(Sender: TObject); procedure TDescriptiveFrm.ResetBtnClick(Sender: TObject);
var var
i : integer; i: integer;
begin begin
for i := 0 to VarList.Items.Count-1 do CIEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
SelList.Items.Add(VarList.Items.Strings[i]);
VarList.Clear; VarList.Clear;
SelList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates; UpdateBtnStates;
FReportFrame.Clear;
end; end;
procedure TDescriptiveFrm.UpdateBtnStates; procedure TDescriptiveFrm.UpdateBtnStates;
@ -460,14 +488,12 @@ begin
AllBtn.Enabled := VarList.Count > 0; AllBtn.Enabled := VarList.Count > 0;
end; end;
procedure TDescriptiveFrm.VarListSelectionChange(Sender: TObject; User: boolean); procedure TDescriptiveFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin begin
UpdateBtnStates; UpdateBtnStates;
end; end;
initialization
{$I descriptiveunit.lrs}
end. end.

View File

@ -879,7 +879,7 @@ procedure TOS3MainFrm.MultXvsYClick(Sender: TObject);
begin begin
if MultXvsYFrm = nil then if MultXvsYFrm = nil then
Application.CreateForm(TMultXvsYFrm, MultXvsYFrm); Application.CreateForm(TMultXvsYFrm, MultXvsYFrm);
MultXvsYFrm.ShowModal; MultXvsYFrm.Show;
end; end;
// Menu "Analysis" > "Comparisons" > "ABC ANOVA with B Nested in A" // Menu "Analysis" > "Comparisons" > "ABC ANOVA with B Nested in A"
@ -1051,7 +1051,7 @@ procedure TOS3MainFrm.DistributionsClick(Sender: TObject);
begin begin
if DescriptiveFrm = nil then if DescriptiveFrm = nil then
Application.CreateForm(TDescriptiveFrm, DescriptiveFrm); Application.CreateForm(TDescriptiveFrm, DescriptiveFrm);
DescriptiveFrm.ShowModal; DescriptiveFrm.Show;
end; end;

View File

@ -26,6 +26,8 @@ type
procedure tbSaveReportClick(Sender: TObject); procedure tbSaveReportClick(Sender: TObject);
private private
FPrintY: Integer; FPrintY: Integer;
FMaxLen: Integer;
function LongestLine(AReport: TStrings): Integer;
protected protected
procedure PrintText; virtual; procedure PrintText; virtual;
@ -33,7 +35,7 @@ type
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure Clear; virtual; procedure Clear; virtual;
procedure DisplayReport(AReport: TStrings); virtual; procedure DisplayReport(AReport: TStrings; Add: Boolean = false); virtual;
procedure UpdateBtnStates; virtual; procedure UpdateBtnStates; virtual;
end; end;
@ -43,8 +45,9 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Graphics, Graphics, StrUtils,
Printers, OSPrinters; Printers, OSPrinters,
Globals;
const const
LEFT_MARGIN = 200; LEFT_MARGIN = 200;
@ -56,6 +59,7 @@ const
constructor TReportFrame.Create(AOwner: TComponent); constructor TReportFrame.Create(AOwner: TComponent);
begin begin
inherited; inherited;
ReportPanel.Color := ReportMemo.Color;
UpdateBtnStates; UpdateBtnStates;
end; end;
@ -67,13 +71,37 @@ begin
end; end;
procedure TReportFrame.DisplayReport(AReport: TStrings); procedure TReportFrame.DisplayReport(AReport: TStrings; Add: Boolean = false);
var
maxLen: Integer;
s: String;
begin begin
ReportMemo.Lines.AddStrings(AReport); if not Add then
ReportMemo.Clear;
maxLen := Longestline(AReport);
for s in AReport do
if s = DIVIDER_AUTO then
ReportMemo.Lines.Add(AddChar('-', '', maxLen))
else
ReportMemo.Lines.Add(s);
UpdateBtnStates; UpdateBtnStates;
end; end;
function TReportFrame.LongestLine(AReport: TStrings): Integer;
var
len: Integer;
s: String;
begin
len := 0;
for s in AReport do
if Length(s) > len then len := Length(s);
Result := len;
end;
procedure TReportFrame.PrintText; procedure TReportFrame.PrintText;
var var
i: Integer; i: Integer;

View File

@ -83,6 +83,7 @@ const
DIVIDER = '==========================================================================='; DIVIDER = '===========================================================================';
DIVIDER_SMALL = '---------------------------------------------------------------------------'; DIVIDER_SMALL = '---------------------------------------------------------------------------';
DIVIDER_AUTO = '@-';
GRAPH_BACK_COLOR = clCream; GRAPH_BACK_COLOR = clCream;
GRAPH_WALL_COLOR = clGray; GRAPH_WALL_COLOR = clGray;