LazStats: Inherit SensUnit from TBasicStatsReportAndChartForm. Change layout to be similar that of to the other forms.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7833 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-01 00:18:38 +00:00
parent 8b234a114e
commit 67a0005f1a
4 changed files with 382 additions and 412 deletions

View File

@ -67,3 +67,4 @@ correlation, means, standard deviations and confidence interval for each correla
163=The Resistant Line procedure creates three equal groups by sorting on the X variable and obtaining the median value of each group.\n\nThe median values for these three groups on both the X and Y variables are then plotted. The line from the low group median to the middle group median is plotted as well as the line from the middle group to the top group median. A comparison of the slope of these two lines gives an indication of the degree to which the data fit a straight line. Enter the X and Y variables to be analyzed and click the compute button.
164=This procedure smooths data by averaging every three data points starting with the first three to the last three. The data smoothing can be repeated multiple times. The first and last data points are unchanged.
165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button.
166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis.

View File

@ -1,62 +1,168 @@
object SensForm: TSensForm
Left = 288
Height = 579
Top = 161
Width = 478
inherited SensForm: TSensForm
Left = 414
Height = 416
Top = 163
Width = 936
HelpType = htKeyword
HelpKeyword = 'html/SensSlopeAnalysis.htm'
AutoSize = True
Caption = 'Sens Trend Analysis'
ClientHeight = 579
ClientWidth = 478
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = ResetBtnClick
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object GroupBox1: TGroupBox
AnchorSideTop.Control = Memo1
ClientHeight = 416
ClientWidth = 936
inherited ParamsPanel: TPanel
Height = 400
Width = 344
ClientHeight = 400
ClientWidth = 344
inherited CloseBtn: TButton
Left = 289
Top = 375
end
inherited ComputeBtn: TButton
Left = 205
Top = 375
end
inherited ResetBtn: TButton
Left = 143
Top = 375
end
inherited HelpBtn: TButton
Tag = 166
Left = 84
Top = 375
end
inherited ButtonBevel: TBevel
Top = 359
Width = 344
end
object Label2: TLabel[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object VarList: TListBox[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
Left = 43
Height = 72
Top = 129
Width = 182
Anchors = [akTop, akRight]
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = GroupBox1
Left = 0
Height = 162
Top = 17
Width = 146
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 6
BorderSpacing.Bottom = 12
ItemHeight = 0
MultiSelect = True
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object InBtn: TBitBtn[7]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 159
Height = 26
Top = 17
Width = 26
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 5
end
object OutBtn: TBitBtn[8]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 159
Height = 26
Top = 47
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 6
end
object AllBtn: TBitBtn[9]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom
Left = 152
Height = 25
Top = 89
Width = 40
AutoSize = True
BorderSpacing.Top = 16
Caption = 'If more than one variable:'
Caption = 'All'
OnClick = AllBtnClick
Spacing = 0
TabOrder = 7
end
object GroupBox3: TGroupBox[10]
AnchorSideTop.Control = GroupBox1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = ButtonBevel
Left = 35
Height = 101
Top = 254
Width = 124
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 12
BorderSpacing.Bottom = 4
Caption = 'Report'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.TopBottomSpacing = 8
ChildSizing.VerticalSpacing = 4
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 52
ClientWidth = 178
TabOrder = 0
object StandardizeChk: TCheckBox
ClientHeight = 81
ClientWidth = 120
TabOrder = 8
object PrtDataChk: TCheckBox
Left = 12
Height = 19
Top = 6
Width = 154
Caption = 'Standardize the measures'
Top = 8
Width = 96
Caption = 'Data'
TabOrder = 0
end
object AvgSlopeChk: TCheckBox
object PrtSlopesChk: TCheckBox
Left = 12
Height = 19
Top = 27
Width = 154
Caption = 'Calculate Average Slope'
Top = 31
Width = 96
Caption = 'Slopes Matrix'
TabOrder = 1
end
object PrtRanksChk: TCheckBox
Left = 12
Height = 19
Top = 54
Width = 96
Caption = 'Ranked Slopes'
TabOrder = 2
end
object GroupBox2: TGroupBox
end
object GroupBox2: TGroupBox[11]
AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox1
Left = 253
AnchorSideTop.Control = GroupBox3
Left = 185
Height = 72
Top = 129
Top = 254
Width = 124
AutoSize = True
Caption = 'Plot'
@ -66,7 +172,7 @@ object SensForm: TSensForm
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 52
ClientWidth = 120
TabOrder = 1
TabOrder = 9
object PlotChk: TCheckBox
Left = 12
Height = 19
@ -84,268 +190,111 @@ object SensForm: TSensForm
TabOrder = 1
end
end
object GroupBox3: TGroupBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
object GroupBox1: TGroupBox[12]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
Left = 43
Height = 93
Top = 217
Width = 182
Anchors = [akTop, akLeft, akRight]
AnchorSideBottom.Control = GroupBox2
Left = 0
Height = 51
Top = 191
Width = 341
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Top = 16
Caption = 'Print'
BorderSpacing.Bottom = 12
Caption = 'If more than one variable:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 12
ChildSizing.VerticalSpacing = 2
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ClientHeight = 73
ClientWidth = 178
TabOrder = 2
object PrtDataChk: TCheckBox
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 337
TabOrder = 10
object StandardizeChk: TRadioButton
Left = 12
Height = 19
Top = 6
Width = 96
Caption = 'Data'
Width = 154
Caption = 'Standardize the measures'
TabOrder = 0
end
object PrtSlopesChk: TCheckBox
Left = 12
object AvgSlopeChk: TRadioButton
Left = 178
Height = 19
Top = 27
Width = 96
Caption = 'Slopes Matrix'
Top = 6
Width = 147
Caption = 'Calculate Average Slope'
TabOrder = 1
end
object PrtRanksChk: TCheckBox
Left = 12
Height = 19
Top = 48
Width = 96
Caption = 'Ranked Slopes'
TabOrder = 2
end
end
object Label1: TLabel
AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom
object Label1: TLabel[13]
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = AlphaEdit
AnchorSideTop.Side = asrCenter
Left = 253
Left = 185
Height = 15
Top = 221
Top = 338
Width = 64
Caption = 'Alpha Level:'
ParentColor = False
end
object AlphaEdit: TEdit
object AlphaEdit: TEdit[14]
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox3
Left = 325
AnchorSideTop.Control = GroupBox2
AnchorSideTop.Side = asrBottom
Left = 257
Height = 23
Top = 217
Top = 334
Width = 47
Alignment = taRightJustify
BorderSpacing.Left = 8
TabOrder = 3
BorderSpacing.Top = 8
TabOrder = 11
Text = '0.05'
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = GroupBox3
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 318
Width = 100
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Available Variables:'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 200
Top = 335
Width = 200
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinHeight = 200
ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 225
Height = 28
Top = 335
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = InBtnClick
Spacing = 0
TabOrder = 5
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 225
Height = 28
Top = 367
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = OutBtnClick
Spacing = 0
TabOrder = 6
end
object AllBtn: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom
Left = 216
Height = 25
Top = 411
Width = 46
AutoSize = True
BorderSpacing.Top = 16
Caption = 'ALL'
OnClick = AllBtnClick
Spacing = 0
TabOrder = 7
end
object Label3: TLabel
object Label3: TLabel[15]
AnchorSideLeft.Control = SelectedList
AnchorSideTop.Control = Label2
Left = 270
Left = 198
Height = 15
Top = 318
Top = 0
Width = 107
Caption = 'Variables to Analyze:'
ParentColor = False
end
object SelectedList: TListBox
object SelectedList: TListBox[16]
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 270
Height = 195
Top = 335
Width = 200
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 198
Height = 162
Top = 17
Width = 146
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Left = 6
BorderSpacing.Top = 2
BorderSpacing.Right = 8
ItemHeight = 0
MultiSelect = True
OnDblClick = SelectedListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 8
TabOrder = 12
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 269
Height = 25
Top = 546
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 9
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 331
Height = 25
Top = 546
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
inherited ParamsSplitter: TSplitter
Left = 356
Height = 416
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 415
Height = 25
Top = 546
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 11
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 105
Top = 8
Width = 462
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time. First, select one or more series variables to analyze. Next, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized '#13#10'(z scores with mean of 0 and standard deviation of 1.) Finally, select the options desired and click the compute button to complete the analysis.'
ParentColor = False
WordWrap = True
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 530
Width = 478
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
inherited PageControl: TPageControl
Left = 365
Height = 400
Width = 563
end
end

View File

@ -9,29 +9,26 @@ unit SensUnit;
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls,
MainUnit, Globals, FunctionsLib, OutputUnit,
ContextHelpUnit, MatrixLib, GraphLib;
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls, ComCtrls,
MainUnit, Globals, FunctionsLib,
ContextHelpUnit, MatrixLib, GraphLib, BasicStatsReportAndChartFormUnit;
type
{ TSensForm }
TSensForm = class(TForm)
TSensForm = class(TBasicStatsReportAndChartForm)
AllBtn: TBitBtn;
AlphaEdit: TEdit;
Bevel1: TBevel;
Memo1: TLabel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
AvgSlopeChk: TRadioButton;
InBtn: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
SelectedList: TListBox;
OutBtn: TBitBtn;
StandardizeChk: TRadioButton;
VarList: TListBox;
PrtRanksChk: TCheckBox;
PrtSlopesChk: TCheckBox;
@ -40,23 +37,23 @@ type
SlopesChk: TCheckBox;
PlotChk: TCheckBox;
GroupBox2: TGroupBox;
StandardizeChk: TCheckBox;
AvgSlopeChk: TCheckBox;
GroupBox1: TGroupBox;
procedure AllBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure SelectedListDblClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure UpdateBtnStates;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
public
{ public declarations }
constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end;
var
@ -65,16 +62,52 @@ var
implementation
{$R *.lfm}
uses
Math,
Utils, MatrixUnit;
{ TSensForm }
procedure TSensForm.ResetBtnClick(Sender: TObject);
constructor TSensForm.Create(AOwner: TComponent);
begin
inherited;
if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TSensForm.AdjustConstraints;
begin
inherited;
ParamsPanel.Constraints.MinWidth := Max(
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
GroupBox1.Width
);
ParamsPanel.Constraints.MinHeight := AllBtn.Top + AllBtn.Height +
VarList.BorderSpacing.Bottom + GroupBox1.Height + GroupBox1.BorderSpacing.Bottom +
GroupBox3.Height + GroupBox3.BorderSpacing.Bottom +
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
end;
procedure TSensForm.AllBtnClick(Sender: TObject);
var
i: integer;
begin
for i := 0 to VarList.Items.Count-1 do
SelectedList.Items.Add(VarList.Items[i]);
VarList.Clear;
UpdateBtnStates;
end;
procedure TSensForm.Reset;
var
i: integer;
begin
inherited;
AlphaEdit.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL);
StandardizeChk.Checked := false;
PlotChk.Checked := false;
@ -87,6 +120,7 @@ begin
UpdateBtnStates;
end;
procedure TSensForm.InBtnClick(Sender: TObject);
var
i: integer;
@ -105,17 +139,8 @@ begin
UpdateBtnStates;
end;
procedure TSensForm.AllBtnClick(Sender: TObject);
var
i: integer;
begin
for i := 0 to VarList.Items.Count-1 do
SelectedList.Items.Add(VarList.Items[i]);
VarList.Clear;
UpdateBtnStates;
end;
procedure TSensForm.ComputeBtnClick(Sender: TObject);
procedure TSensForm.Compute;
var
//NoVars,
noselected, count, half, q, tp, low, hi, col: integer;
@ -538,45 +563,13 @@ begin
lReport.Add('Corresponding lower and upper slopes: (%8.3f, %8.3f)', [RankedQ[low],RankedQ[hi]]);
end; // end if average slope
DisplayReport(lReport);
FReportFrame.DisplayReport(lReport);
finally
lReport.Free;
AvgSlopes := nil;
Sorted := nil;
RankedQ := nil;
Slopes := nil;
Values := nil;
selected := nil;
ColLabels := nil;
RowLabels := nil;
end;
end;
procedure TSensForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TSensForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm);
end;
procedure TSensForm.OutBtnClick(Sender: TObject);
var
@ -596,20 +589,47 @@ begin
UpdateBtnStates;
end;
procedure TSensForm.SelectedListDblClick(Sender: TObject);
var
index: Integer;
begin
index := SelectedList.ItemIndex;
if index > -1 then
begin
VarList.Items.Add(SelectedList.Items[index]);
SelectedList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TSensForm.UpdateBtnStates;
begin
inherited;
InBtn.Enabled := AnySelected(VarList);
OutBtn.Enabled := AnySelected(SelectedList);
AllBtn.Enabled := Varlist.Items.Count > 0;
end;
procedure TSensForm.VarListDblClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
SelectedList.Items.Add(VarList.Items[index]);
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TSensForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I sensunit.lrs}
end.

View File

@ -1844,7 +1844,7 @@ procedure TOS3MainFrm.mnuAnalysisNonPar_SignTestClick(Sender: TObject);
begin
if SignTestFrm = nil then
Application.CreateForm(TSignTestFrm, SignTestFrm);
SignTestFrm.ShowModal;
SignTestFrm.Show;
end;
// Menu "Analysis" > "Nonparametric" > "Friedman Two-Way mnuAnalysisComp_Anova"
@ -1852,7 +1852,7 @@ procedure TOS3MainFrm.mnuAnalysisNonPar_FriedmanClick(Sender: TObject);
begin
if FriedmanFrm = nil then
Application.CreateForm(TFriedmanFrm, FriedmanFrm);
FriedmanFrm.ShowModal;
FriedmanFrm.Show;
end;
// Menu "Analysis" > "Nonparametric" > "Probability of a Binomial Event"
@ -1900,7 +1900,7 @@ procedure TOS3MainFrm.mnuAnalysisNonPar_SensClick(Sender: TObject);
begin
if SensForm = nil then
Application.CreateForm(TSensForm, SensForm);
SensForm.ShowModal;
SensForm.Show;
end;
// Menu "Analysis" > "Nonparametric" > "Simple Chi Square for Categories"