You've already forked lazarus-ccr
LazStats: Inherit form of WithinANOVAUnit from TBasicStatsReportAndChartForm. Minor refactoring.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7793 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,244 +1,198 @@
|
||||
object WithinANOVAFrm: TWithinANOVAFrm
|
||||
inherited WithinANOVAFrm: TWithinANOVAFrm
|
||||
Left = 544
|
||||
Height = 362
|
||||
Height = 329
|
||||
Top = 330
|
||||
Width = 458
|
||||
Width = 722
|
||||
HelpType = htKeyword
|
||||
HelpKeyword = 'html/WithinSubjectsAnalysisofVariance.htm'
|
||||
AutoSize = True
|
||||
Caption = 'Within Subjects ANOVA and Hoyt Reliability Estimates'
|
||||
ClientHeight = 362
|
||||
ClientWidth = 458
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnShow = FormShow
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object Label1: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 8
|
||||
Height = 15
|
||||
Top = 8
|
||||
Width = 97
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Available Variables'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
AnchorSideLeft.Control = SelList
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 251
|
||||
Height = 15
|
||||
Top = 8
|
||||
Width = 96
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Selected Variables:'
|
||||
ParentColor = False
|
||||
end
|
||||
object VarList: TListBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Label1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = InBtn
|
||||
AnchorSideBottom.Control = GroupBox1
|
||||
Left = 8
|
||||
Height = 229
|
||||
Top = 25
|
||||
Width = 199
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Constraints.MinHeight = 220
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 0
|
||||
end
|
||||
object InBtn: TBitBtn
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = VarList
|
||||
Left = 215
|
||||
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
|
||||
Left = 215
|
||||
Height = 28
|
||||
Top = 57
|
||||
Width = 28
|
||||
BorderSpacing.Top = 4
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 0
|
||||
OnClick = OutBtnClick
|
||||
Spacing = 0
|
||||
TabOrder = 2
|
||||
end
|
||||
object SelList: TListBox
|
||||
AnchorSideLeft.Control = InBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Label2
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = GroupBox1
|
||||
Left = 251
|
||||
Height = 229
|
||||
Top = 25
|
||||
Width = 199
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 3
|
||||
end
|
||||
object GroupBox1: TGroupBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideBottom.Control = Bevel1
|
||||
Left = 8
|
||||
Height = 51
|
||||
Top = 262
|
||||
Width = 384
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Options:'
|
||||
ChildSizing.LeftRightSpacing = 12
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.HorizontalSpacing = 20
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 3
|
||||
ClientHeight = 31
|
||||
ClientWidth = 380
|
||||
TabOrder = 4
|
||||
object RelChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 124
|
||||
Caption = 'Reliability Estimates'
|
||||
ClientHeight = 329
|
||||
ClientWidth = 722
|
||||
inherited ParamsPanel: TPanel
|
||||
Height = 313
|
||||
Width = 288
|
||||
ClientHeight = 313
|
||||
ClientWidth = 288
|
||||
inherited CloseBtn: TButton
|
||||
Left = 233
|
||||
Top = 288
|
||||
TabOrder = 8
|
||||
end
|
||||
inherited ComputeBtn: TButton
|
||||
Left = 149
|
||||
Top = 288
|
||||
TabOrder = 7
|
||||
end
|
||||
inherited ResetBtn: TButton
|
||||
Left = 87
|
||||
Top = 288
|
||||
TabOrder = 6
|
||||
end
|
||||
inherited HelpBtn: TButton
|
||||
Left = 28
|
||||
Top = 288
|
||||
TabOrder = 5
|
||||
end
|
||||
inherited ButtonBevel: TBevel
|
||||
Top = 272
|
||||
Width = 288
|
||||
end
|
||||
object Label1: TLabel[5]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 0
|
||||
Width = 97
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'Available Variables'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel[6]
|
||||
AnchorSideLeft.Control = SelList
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
Left = 163
|
||||
Height = 15
|
||||
Top = 0
|
||||
Width = 96
|
||||
Caption = 'Selected Variables:'
|
||||
ParentColor = False
|
||||
end
|
||||
object VarList: TListBox[7]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = Label1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = InBtn
|
||||
AnchorSideBottom.Control = GroupBox1
|
||||
Left = 0
|
||||
Height = 177
|
||||
Top = 17
|
||||
Width = 125
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Bottom = 8
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnDblClick = VarListDblClick
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 0
|
||||
end
|
||||
object AssumpChk: TCheckBox
|
||||
Left = 156
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 113
|
||||
Caption = 'Test Assumptions'
|
||||
object InBtn: TBitBtn[8]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = VarList
|
||||
Left = 131
|
||||
Height = 26
|
||||
Top = 17
|
||||
Width = 26
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 1
|
||||
OnClick = InBtnClick
|
||||
Spacing = 0
|
||||
TabOrder = 1
|
||||
end
|
||||
object PlotChk: TCheckBox
|
||||
Left = 289
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 79
|
||||
Caption = 'Plot Means'
|
||||
object OutBtn: TBitBtn[9]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = InBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 131
|
||||
Height = 26
|
||||
Top = 47
|
||||
Width = 26
|
||||
BorderSpacing.Top = 4
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 0
|
||||
OnClick = OutBtnClick
|
||||
Spacing = 0
|
||||
TabOrder = 2
|
||||
end
|
||||
object GroupBox1: TGroupBox[10]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideBottom.Control = ButtonBevel
|
||||
Left = 0
|
||||
Height = 70
|
||||
Top = 202
|
||||
Width = 251
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Options:'
|
||||
ChildSizing.LeftRightSpacing = 12
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.HorizontalSpacing = 20
|
||||
ChildSizing.Layout = cclTopToBottomThenLeftToRight
|
||||
ChildSizing.ControlsPerLine = 2
|
||||
ClientHeight = 50
|
||||
ClientWidth = 247
|
||||
TabOrder = 4
|
||||
object RelChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 124
|
||||
Caption = 'Reliability Estimates'
|
||||
TabOrder = 0
|
||||
end
|
||||
object AssumpChk: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 25
|
||||
Width = 124
|
||||
Caption = 'Test Assumptions'
|
||||
TabOrder = 1
|
||||
end
|
||||
object PlotChk: TCheckBox
|
||||
Left = 156
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 79
|
||||
Caption = 'Plot Means'
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object SelList: TListBox[11]
|
||||
AnchorSideLeft.Control = InBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Label2
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = GroupBox1
|
||||
Left = 163
|
||||
Height = 177
|
||||
Top = 17
|
||||
Width = 125
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Bottom = 8
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnDblClick = SelListDblClick
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object ResetBtn: TButton
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 245
|
||||
Height = 25
|
||||
Top = 329
|
||||
Width = 54
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 6
|
||||
inherited ParamsSplitter: TSplitter
|
||||
Left = 300
|
||||
Height = 329
|
||||
end
|
||||
object ComputeBtn: TButton
|
||||
AnchorSideRight.Control = CloseBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 307
|
||||
Height = 25
|
||||
Top = 329
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Compute'
|
||||
OnClick = ComputeBtnClick
|
||||
TabOrder = 7
|
||||
end
|
||||
object CloseBtn: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 391
|
||||
Height = 25
|
||||
Top = 329
|
||||
Width = 55
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
TabOrder = 8
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
Tag = 157
|
||||
AnchorSideRight.Control = ResetBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 186
|
||||
Height = 25
|
||||
Top = 329
|
||||
Width = 51
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Help'
|
||||
OnClick = HelpBtnClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = CloseBtn
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 313
|
||||
Width = 458
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
Shape = bsBottomLine
|
||||
inherited PageControl: TPageControl
|
||||
Left = 309
|
||||
Height = 313
|
||||
Width = 405
|
||||
inherited ReportPage: TTabSheet
|
||||
Caption = 'ANOVA Results'
|
||||
end
|
||||
object ReliabilityPage: TTabSheet[1]
|
||||
Caption = 'Reliability Estimates'
|
||||
end
|
||||
object TestAssumptionsPage: TTabSheet[2]
|
||||
Caption = 'Test Assumptions'
|
||||
end
|
||||
inherited ChartPage: TTabSheet[3]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,22 +7,17 @@ unit WithinANOVAUnit;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Buttons, ExtCtrls, Math,
|
||||
MainUnit, FunctionsLib, OutputUnit, MatrixLib, Globals, DataProcs,
|
||||
GraphLib, ContextHelpUnit;
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Buttons, ExtCtrls, ComCtrls, Math,
|
||||
MainUnit, FunctionsLib, MatrixLib, Globals,
|
||||
ReportFrameUnit, BasicStatsReportAndChartFormUnit;
|
||||
|
||||
type
|
||||
|
||||
{ TWithinANOVAFrm }
|
||||
|
||||
TWithinANOVAFrm = class(TForm)
|
||||
TWithinANOVAFrm = class(TBasicStatsReportAndChartForm)
|
||||
AssumpChk: TCheckBox;
|
||||
Bevel1: TBevel;
|
||||
HelpBtn: TButton;
|
||||
ResetBtn: TButton;
|
||||
ComputeBtn: TButton;
|
||||
CloseBtn: TButton;
|
||||
PlotChk: TCheckBox;
|
||||
RelChk: TCheckBox;
|
||||
GroupBox1: TGroupBox;
|
||||
@ -31,137 +26,127 @@ type
|
||||
SelList: TListBox;
|
||||
OutBtn: TBitBtn;
|
||||
Label1: TLabel;
|
||||
ReliabilityPage: TTabSheet;
|
||||
TestAssumptionsPage: TTabSheet;
|
||||
VarList: TListBox;
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure InBtnClick(Sender: TObject);
|
||||
procedure OutBtnClick(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
procedure SelListDblClick(Sender: TObject);
|
||||
procedure VarListDblClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||
|
||||
private
|
||||
{ private declarations }
|
||||
FAutoSized: Boolean;
|
||||
procedure UpdateBtnStates;
|
||||
FReliabilityReportFrame: TReportFrame;
|
||||
FTestAssumptionsReportFrame: TReportFrame;
|
||||
procedure Plot(ColMeans: DblDyneVec; ColLabels: StrDyneVec);
|
||||
|
||||
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
|
||||
WithinANOVAFrm: TWithinANOVAFrm;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
MathUnit;
|
||||
TAChartUtils, TACustomSeries,
|
||||
GridProcs,
|
||||
Utils, MathUnit, ChartFrameUnit;
|
||||
|
||||
|
||||
{ TWithinANOVAFrm }
|
||||
|
||||
procedure TWithinANOVAFrm.ResetBtnClick(Sender: TObject);
|
||||
VAR
|
||||
i: integer;
|
||||
constructor TWithinANOVAFrm.Create(AOwner: TComponent);
|
||||
begin
|
||||
VarList.Clear;
|
||||
SelList.Clear;
|
||||
PlotChk.Checked := false;
|
||||
RelChk.Checked := false;
|
||||
AssumpChk.Checked := false;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
UpdateBtnStates;
|
||||
inherited;
|
||||
|
||||
FReliabilityReportFrame := TReportFrame.Create(self);
|
||||
FReliabilityReportFrame.Name := '';
|
||||
FReliabilityReportFrame.Parent := ReliabilityPage;
|
||||
FReliabilityReportFrame.Align := alClient;
|
||||
FReliabilityReportFrame.BorderSpacing.Left := 0;
|
||||
FReliabilityReportFrame.BorderSpacing.Top := 0;
|
||||
FReliabilityReportFrame.BorderSpacing.Bottom := 0;
|
||||
FReliabilityReportFrame.BorderSpacing.Right := 0;
|
||||
|
||||
FTestAssumptionsReportFrame := TReportFrame.Create(self);
|
||||
FTestAssumptionsReportFrame.Name := '';
|
||||
FTestAssumptionsReportFrame.Parent := TestAssumptionsPage;
|
||||
FTestAssumptionsReportFrame.Align := alClient;
|
||||
FTestAssumptionsReportFrame.BorderSpacing.Left := 0;
|
||||
FTestAssumptionsReportFrame.BorderSpacing.Top := 0;
|
||||
FTestAssumptionsReportFrame.BorderSpacing.Bottom := 0;
|
||||
FTestAssumptionsReportFrame.BorderSpacing.Right := 0;
|
||||
|
||||
FChartFrame.Chart.Margins.Bottom := 0;
|
||||
|
||||
PageControl.ActivePageIndex := 0;
|
||||
end;
|
||||
|
||||
procedure TWithinANOVAFrm.FormActivate(Sender: TObject);
|
||||
var
|
||||
w: Integer;
|
||||
|
||||
procedure TWithinANOVAFrm.AdjustConstraints;
|
||||
begin
|
||||
if FAutoSized then
|
||||
exit;
|
||||
inherited;
|
||||
|
||||
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;
|
||||
ParamsPanel.Constraints.MinWidth := Max(
|
||||
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
|
||||
GroupBox1.Width
|
||||
);
|
||||
ParamsPanel.Constraints.MinHeight := OutBtn.Top + 6*OutBtn.Height +
|
||||
VarList.BorderSpacing.Bottom + GroupBox1.Height + ButtonBevel.Height +
|
||||
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
|
||||
end;
|
||||
|
||||
procedure TWithinANOVAFrm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Assert(OS3MainFrm <> nil);
|
||||
if GraphFrm = nil then
|
||||
Application.CreateForm(TGraphFrm, GraphFrm);
|
||||
end;
|
||||
|
||||
procedure TWithinANOVAFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
ResetBtnClick(self);
|
||||
end;
|
||||
|
||||
procedure TWithinANOVAFrm.HelpBtnClick(Sender: TObject);
|
||||
begin
|
||||
if ContextHelpForm = nil then
|
||||
Application.CreateForm(TContextHelpForm, ContextHelpForm);
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
||||
end;
|
||||
|
||||
procedure TWithinANOVAFrm.ComputeBtnClick(Sender: TObject);
|
||||
procedure TWithinANOVAFrm.Compute;
|
||||
var
|
||||
i, j, k, f3: integer;
|
||||
LabelStr: string;
|
||||
NoSelected, count, row: integer;
|
||||
SSrows, SScols, SSwrows, SSerr, SStot: double;
|
||||
MSrows, MScols, MSwrows, MSerr, MStot: double;
|
||||
dfrows, dfcols, dfwrows, dferr, dftot: double;
|
||||
f1, probf1, GrandMean, Term1, Term2, Term3, Term4: double;
|
||||
r1, r2, r3, r4, X, avgvar, avgcov: double;
|
||||
r1, r2, r3, r4, X, XSq, avgvar, avgcov: double;
|
||||
determ1, determ2, M2, C2, chi2, prob: double;
|
||||
errorfound: boolean;
|
||||
Selected: IntDyneVec;
|
||||
ColLabels: StrDyneVec;
|
||||
ColMeans, ColVar, RowMeans, RowVar, ColStdDev: DblDyneVec;
|
||||
varcovmat, vcmat, workmat: DblDyneMat;
|
||||
Selected: IntDyneVec = nil;
|
||||
ColLabels: StrDyneVec = nil;
|
||||
ColMeans: DblDyneVec = nil;
|
||||
ColVar: DblDyneVec = nil;
|
||||
RowMeans: DblDyneVec = nil;
|
||||
RowVar: DblDyneVec = nil;
|
||||
ColStdDev: DblDyneVec = nil;
|
||||
varcovmat: DblDyneMat = nil;
|
||||
vcmat: dblDyneMat = nil;
|
||||
workmat: DblDyneMat = nil;
|
||||
title: string;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
if SelList.Items.Count = 0 then
|
||||
begin
|
||||
MessageDlg('No variables selected.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
if SelList.Items.Count = 1 then
|
||||
begin
|
||||
MessageDlg('At least two variables must be selected.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
errorfound := false;
|
||||
NoSelected := SelList.Items.Count;
|
||||
Caption := IntToStr(NoSelected);
|
||||
|
||||
SetLength(Selected,NoSelected);
|
||||
SetLength(ColLabels,NoSelected);
|
||||
SetLength(ColMeans,NoSelected);
|
||||
SetLength(ColVar,NoSelected);
|
||||
SetLength(RowMeans,NoCases);
|
||||
SetLength(RowVar,NoCases);
|
||||
SetLength(Selected, NoSelected);
|
||||
SetLength(ColLabels, NoSelected);
|
||||
SetLength(ColMeans, NoSelected);
|
||||
SetLength(ColVar, NoSelected);
|
||||
SetLength(RowMeans, NoCases);
|
||||
SetLength(RowVar, NoCases);
|
||||
|
||||
for i := 0 to NoSelected - 1 do
|
||||
begin
|
||||
LabelStr := SelList.Items[i];
|
||||
for j := 1 to NoVariables do
|
||||
if LabelStr = OS3MainFrm.DataGrid.Cells[j, 0] then
|
||||
begin
|
||||
Selected[i] := j;
|
||||
ColLabels[i] := labelStr;
|
||||
break;
|
||||
end;
|
||||
Selected[i] := GetVariableIndex(OS3MainFrm.DataGrid, SelList.Items[i]);
|
||||
ColLabels[i] := SelList.Items[i];
|
||||
end;
|
||||
|
||||
// Initialize values
|
||||
@ -188,28 +173,31 @@ begin
|
||||
row := 0;
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
if not GoodRecord(i,NoSelected,Selected) then continue;
|
||||
if not GoodRecord(OS3MainFrm.DataGrid, i, Selected) then continue;
|
||||
count := count + 1;
|
||||
for j := 1 to NoSelected do
|
||||
begin
|
||||
k := Selected[j-1];
|
||||
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[k,i]));
|
||||
Xsq := X*X;
|
||||
RowMeans[row] := RowMeans[row] + X;
|
||||
RowVar[row] := RowVar[row] + (X * X);
|
||||
RowVar[row] := RowVar[row] + Xsq;
|
||||
ColMeans[j-1] := ColMeans[j-1] + X;
|
||||
ColVar[j-1] := ColVar[j-1] + (X * X);
|
||||
ColVar[j-1] := ColVar[j-1] + Xsq;
|
||||
GrandMean := GrandMean + X;
|
||||
SStot := SStot + (X * X);
|
||||
SStot := SStot + XSq;
|
||||
end;
|
||||
row := row + 1;
|
||||
end;
|
||||
|
||||
// Calculate ANOVA results
|
||||
Term1 := (GrandMean * GrandMean) / (count * NoSelected);
|
||||
Term1 := sqr(GrandMean) / (count * NoSelected);
|
||||
Term2 := SStot;
|
||||
for i := 1 to count do SSrows := SSrows + (RowMeans[i-1] * RowMeans[i-1]);
|
||||
for i := 0 to count-1 do
|
||||
SSrows := SSrows + sqr(RowMeans[i]);
|
||||
Term4 := SSrows / NoSelected;
|
||||
for i := 1 to NoSelected do SScols := SScols + (ColMeans[i-1] * ColMeans[i-1]);
|
||||
for i := 0 to NoSelected-1 do
|
||||
SScols := SScols + sqr(ColMeans[i]);
|
||||
Term3 := SScols / count;
|
||||
SSrows := Term4 - Term1;
|
||||
SScols := Term3 - Term1;
|
||||
@ -258,9 +246,9 @@ begin
|
||||
lReport := TStringList.Create;
|
||||
try
|
||||
// print results
|
||||
lReport.Add('Treatments by Subjects (AxS) ANOVA Results.');
|
||||
lReport.Add('TREATMENTS BY SUBJECTS (AxS) ANOVA RESULTS');
|
||||
lReport.Add('');
|
||||
lReport.Add('Data File = ' + OS3MainFrm.FileNameEdit.Text);
|
||||
lReport.Add('Data File: ' + OS3MainFrm.FileNameEdit.Text);
|
||||
lReport.Add('');
|
||||
lReport.Add('');
|
||||
lReport.Add('-----------------------------------------------------------');
|
||||
@ -276,27 +264,31 @@ begin
|
||||
lReport.Add('');
|
||||
lReport.Add('');
|
||||
lReport.Add('TREATMENT (COLUMN) MEANS AND STANDARD DEVIATIONS');
|
||||
lReport.Add('VARIABLE MEAN STD.DEV.');
|
||||
lReport.Add('VARIABLE MEAN STD.DEV. ');
|
||||
lReport.Add('-------- ---------- ----------');
|
||||
for i := 1 to NoSelected do
|
||||
lReport.Add('%-8s%10.3f%10.3f', [ColLabels[i-1], ColMeans[i-1], sqrt(ColVar[i-1])]);
|
||||
lReport.Add('');
|
||||
lReport.Add('Mean of all scores = %.3f with standard deviation = %.3f', [GrandMean, sqrt(MStot)]);
|
||||
lReport.Add('');
|
||||
lReport.Add('%-8s %10.3f %10.3f', [ColLabels[i-1], ColMeans[i-1], sqrt(ColVar[i-1])]);
|
||||
lReport.Add('');
|
||||
lReport.Add('Mean of all scores: %8.3f', [GrandMean]);
|
||||
lReport.Add(' with standard deviation: %8.3f', [sqrt(MStot)]);
|
||||
|
||||
FReportFrame.DisplayReport(lReport);
|
||||
|
||||
// Do reliability estimates if requested
|
||||
if RelChk.Checked then
|
||||
begin
|
||||
lReport.Clear;
|
||||
lReport.Add('RELIABILITY ESTIMATES');
|
||||
lReport.Add('');
|
||||
lReport.Add('TYPE OF ESTIMATE VALUE');
|
||||
lReport.Add('TYPE OF ESTIMATE VALUE ');
|
||||
lReport.Add('---------------------------- -------');
|
||||
lReport.Add('Unadjusted total reliability %7.3f', [r1]);
|
||||
lReport.Add('Unadjusted item reliability %7.3f', [r2]);
|
||||
lReport.Add('Adjusted total (Cronbach) %7.3f', [r3]);
|
||||
lReport.Add('Adjusted item reliability %7.3f', [r4]);
|
||||
lReport.Add('');
|
||||
lReport.Add('');
|
||||
FReliabilityReportFrame.DisplayReport(lReport);
|
||||
end;
|
||||
ReliabilityPage.TabVisible := RelChk.Checked;
|
||||
|
||||
// Test assumptions of variance - covariance homogeneity if requested
|
||||
if AssumpChk.Checked then
|
||||
@ -307,13 +299,14 @@ begin
|
||||
SetLength(ColStdDev,NoSelected);
|
||||
errorfound := false;
|
||||
count := NoCases;
|
||||
lReport.Clear;
|
||||
lReport.Add('BOX TEST FOR HOMOGENEITY OF VARIANCE-COVARIANCE MATRIX');
|
||||
lReport.Add('');
|
||||
GridCovar(NoSelected, Selected, varcovmat, ColMeans, ColVar, ColStdDev, errorfound, count);
|
||||
title := 'SAMPLE COVARIANCE MATRIX';
|
||||
MatPrint(varcovmat, NoSelected, NoSelected, title, ColLabels, ColLabels, NoCases, lReport);
|
||||
if errorfound then
|
||||
MessageDlg('Zero variance found for a variable.', mtError, [mbOK], 0);
|
||||
ErrorMsg('Zero variance found for a variable.');
|
||||
|
||||
// get average of variances into workmat diagonal and average of
|
||||
// covariances into workmat off-diagonals (See Winer, pg 371)
|
||||
@ -368,7 +361,7 @@ begin
|
||||
begin
|
||||
M2 := 0.0;
|
||||
errorfound := true;
|
||||
MessageDlg('A determinant <= zero was found.', mtError, [mbOK], 0);
|
||||
ErrorMsg('A determinant <= zero was found.');
|
||||
end;
|
||||
if not errorfound then
|
||||
begin
|
||||
@ -384,69 +377,37 @@ begin
|
||||
if chi2 >= 1000.0 then prob := 0.0;
|
||||
end;
|
||||
end;
|
||||
|
||||
title := 'ASSUMED POP. COVARIANCE MATRIX';
|
||||
for i := 0 to NoSelected-1 do
|
||||
for j := 0 to NoSelected-1 do
|
||||
varcovmat[i,j] := workmat[i,j];
|
||||
MatPrint(varcovmat, NoSelected, NoSelected, title, ColLabels, ColLabels, NoCases, lReport);
|
||||
lReport.Add('Determinant of variance-covariance matrix = %10.3g', [determ1]);
|
||||
lReport.Add('Determinant of homogeneity matrix = %10.3g', [determ2]);
|
||||
lReport.Add('Determinant of variance-covariance matrix: %10.3g', [determ1]);
|
||||
lReport.Add('Determinant of homogeneity matrix: %10.3g', [determ2]);
|
||||
if not errorfound then
|
||||
begin
|
||||
lReport.Add('ChiSquare = %10.3f with %3d degrees of freedom', [chi2,f3]);
|
||||
lReport.Add('Probability of larger chisquare = %6.3g', [1.0-prob]);
|
||||
lReport.Add('ChiSquare: %10.3f', [chi2]);
|
||||
lReport.Add(' with %d degrees of freedom', [f3]);
|
||||
lReport.Add('Probability of larger chisquare: %10.3f', [1.0-prob]);
|
||||
end;
|
||||
end;
|
||||
|
||||
DisplayReport(lReport);
|
||||
FTestAssumptionsReportFrame.DisplayReport(lReport);
|
||||
end;
|
||||
TestAssumptionsPage.TabVisible := AssumpChk.Checked;
|
||||
|
||||
finally
|
||||
lReport.Free;
|
||||
ColStdDev := nil;
|
||||
workmat := nil;
|
||||
vcmat := nil;
|
||||
varcovmat := nil;
|
||||
end;
|
||||
|
||||
{ Now, plot values if indicated in options list }
|
||||
{ Finally, plot values if indicated in options list }
|
||||
if PlotChk.Checked then
|
||||
begin
|
||||
SetLength(GraphFrm.Xpoints,1,NoSelected);
|
||||
SetLength(GraphFrm.Ypoints,1,NoSelected);
|
||||
|
||||
// use rowvar to hold variable no.
|
||||
for i := 1 to NoSelected do
|
||||
begin
|
||||
rowvar[i-1] := Selected[i-1];
|
||||
GraphFrm.Xpoints[0,i-1] := Selected[i-1];
|
||||
GraphFrm.Ypoints[0,i-1] := ColMeans[i-1];
|
||||
end;
|
||||
GraphFrm.nosets := 1;
|
||||
GraphFrm.nbars := NoSelected;
|
||||
GraphFrm.Heading := 'WITHIN SUBJECTS ANOVA';
|
||||
GraphFrm.XTitle := 'Repeated Measure Var. No.';
|
||||
GraphFrm.YTitle := 'Mean';
|
||||
GraphFrm.barwideprop := 0.5;
|
||||
GraphFrm.AutoScaled := true;
|
||||
GraphFrm.GraphType := 2; // 3d Vertical Bar Chart
|
||||
GraphFrm.BackColor := clYellow;
|
||||
GraphFrm.WallColor := clBlack;
|
||||
GraphFrm.FloorColor := clLtGray;
|
||||
GraphFrm.ShowBackWall := true;
|
||||
GraphFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Clean-up
|
||||
RowVar := nil;
|
||||
RowMeans := nil;
|
||||
ColVar := nil;
|
||||
ColMeans := nil;
|
||||
ColLabels := nil;
|
||||
GraphFrm.Xpoints := nil;
|
||||
GraphFrm.Ypoints := nil;
|
||||
Selected := nil;
|
||||
Plot(ColMeans, ColLabels);
|
||||
ChartPage.TabVisible := PlotChk.Checked;
|
||||
ChartPage.PageIndex := PageControl.PageCount-1;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.InBtnClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
@ -465,6 +426,7 @@ begin
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.OutBtnClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
@ -485,11 +447,77 @@ begin
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.Plot(ColMeans: DblDyneVec; ColLabels: StrDyneVec);
|
||||
var
|
||||
ser: TChartSeries;
|
||||
begin
|
||||
FChartFrame.Clear;
|
||||
|
||||
FChartFrame.SetTitle('WITHIN SUBJECTS ANOVA');
|
||||
FChartFrame.SetXTitle('Repeated Measure Variables');
|
||||
FChartFrame.SetYTitle('Mean');
|
||||
|
||||
ser := FChartFrame.PlotXY(ptBars, nil, ColMeans, ColLabels, nil, '', DATA_COLORS[0]);
|
||||
FChartFrame.Chart.BottomAxis.Marks.Source := ser.Source;
|
||||
FChartFrame.Chart.BottomAxis.Marks.Style := smsLabel;
|
||||
FChartFrame.Chart.Legend.Visible := false;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.Reset;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if FReliabilityReportFrame <> nil then
|
||||
FReliabilityReportFrame.Clear;
|
||||
if FTestAssumptionsReportFrame <> nil then
|
||||
FTestAssumptionsReportFrame.Clear;
|
||||
|
||||
VarList.Clear;
|
||||
SelList.Clear;
|
||||
PlotChk.Checked := false;
|
||||
RelChk.Checked := false;
|
||||
AssumpChk.Checked := false;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
|
||||
ReliabilityPage.TabVisible := false;
|
||||
TestAssumptionsPage.TabVisible := false;
|
||||
ChartPage.TabVisible := false;
|
||||
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.SelListDblClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
begin
|
||||
index := SelList.ItemIndex;
|
||||
if index > -1 then
|
||||
begin
|
||||
VarList.Items.Add(SelList.Items[index]);
|
||||
SelList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.UpdateBtnStates;
|
||||
var
|
||||
i: Integer;
|
||||
lEnabled: Boolean;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if FReliabilityReportFrame <> nil then
|
||||
FReliabilityReportFrame.UpdateBtnStates;
|
||||
if FTestAssumptionsReportFrame <> nil then
|
||||
FTestAssumptionsReportFrame.UpdateBtnStates;
|
||||
|
||||
lEnabled := false;
|
||||
for i:=0 to VarList.Items.Count-1 do
|
||||
if VarList.Selected[i] then
|
||||
@ -509,6 +537,42 @@ begin
|
||||
OutBtn.Enabled := lEnabled;
|
||||
end;
|
||||
|
||||
|
||||
function TWithinANOVAFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
|
||||
if SelList.Items.Count = 0 then
|
||||
begin
|
||||
AControl := VarList;
|
||||
AMsg := 'No variables selected.';
|
||||
exit;
|
||||
end;
|
||||
if SelList.Items.Count = 1 then
|
||||
begin
|
||||
AControl := VarList;
|
||||
AMsg := 'At least two variables must be selected.';
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.VarListDblClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index > -1 then
|
||||
begin
|
||||
SelList.Items.Add(VarList.Items[index]);
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TWithinANOVAFrm.VarListSelectionChange(Sender: TObject;
|
||||
User: boolean);
|
||||
begin
|
||||
@ -516,8 +580,5 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I withinanovaunit.lrs}
|
||||
|
||||
end.
|
||||
|
||||
|
@ -42,10 +42,12 @@ begin
|
||||
inherited;
|
||||
|
||||
FReportFrame := TReportFrame.Create(self);
|
||||
FReportFrame.Name := '';
|
||||
FReportFrame.Parent := ReportPage;
|
||||
FReportFrame.Align := alClient;
|
||||
|
||||
FChartFrame := TChartFrame.Create(self);
|
||||
FChartFrame.Name := '';
|
||||
FChartFrame.Parent := ChartPage;
|
||||
FChartFrame.Align := alClient;
|
||||
FChartFrame.Chart.BottomAxis.Intervals.MaxLength := 80;
|
||||
|
Reference in New Issue
Block a user