You've already forked lazarus-ccr
LazStats: Inherit BatlettTestUnit from BasicStatsReportForumUnit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7890 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -73,3 +73,4 @@ correlation, means, standard deviations and confidence interval for each correla
|
||||
169=Directions:\nFor independent groups data, first click the variable to be analyzed then click the variable containing group codes.\nFor dependent variables it is assumed the data for each pair of values are in a case.\nEnter the names of those two variables.
|
||||
170=Directions:\nThis analysis assumes that levels of Factor B are nested within levels of Factor A. It is assumed that all factors are fixed level factors.\n\nThe variables for the group coding should be defined as integers. The dependent variable should be defined as a floating point variable. The number of cases for each ABC group should be equal and the number of B treatments in in each A level should be equal. The number of C treatment levels should be the same for each AB combination.\n\nClick the variable for each factor variable and the corresponding arrow to enter it in the edit box for that variable. Select the type of plot desired for the means (if any.) Click the Compute button to continue.
|
||||
171=Directions: This analysis assumes that levels of Factor B are nested within levels of Factor A. Unless otherwise specified, it is assumed that Factors A and B are fixed level factors. If Factor B is a random variable, check the provided box to indicate this.\n\nThe number of cases for each B group should be equal and the number of B treatements in each A level should be equal.
|
||||
172=This is the Bartlett test of sphericity for three or more variables. Enter three or more of the variables listed in the left box and press the compute button to obtain the results.
|
@ -1,225 +1,128 @@
|
||||
object BartlettTestForm: TBartlettTestForm
|
||||
inherited BartlettTestForm: TBartlettTestForm
|
||||
Left = 474
|
||||
Height = 394
|
||||
Height = 356
|
||||
Top = 304
|
||||
Width = 411
|
||||
Width = 639
|
||||
HelpType = htKeyword
|
||||
HelpKeyword = 'html/BartlettTestofSphericity.htm'
|
||||
AutoSize = True
|
||||
Caption = 'Bartlett Test of Sphericity'
|
||||
ClientHeight = 394
|
||||
ClientWidth = 411
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnShow = ResetBtnClick
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object ResetBtn: TButton
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 202
|
||||
Height = 25
|
||||
Top = 361
|
||||
Width = 54
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 2
|
||||
ClientHeight = 356
|
||||
ClientWidth = 639
|
||||
inherited ParamsPanel: TPanel
|
||||
Height = 340
|
||||
Width = 320
|
||||
ClientHeight = 340
|
||||
ClientWidth = 320
|
||||
inherited CloseBtn: TButton
|
||||
Left = 265
|
||||
Top = 315
|
||||
TabOrder = 8
|
||||
end
|
||||
object ComputeBtn: TButton
|
||||
AnchorSideRight.Control = CloseBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 264
|
||||
Height = 25
|
||||
Top = 361
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Compute'
|
||||
OnClick = ComputeBtnClick
|
||||
TabOrder = 3
|
||||
inherited ComputeBtn: TButton
|
||||
Left = 181
|
||||
Top = 315
|
||||
TabOrder = 7
|
||||
end
|
||||
object HelpBtn: TButton
|
||||
Tag = 119
|
||||
AnchorSideRight.Control = ResetBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 143
|
||||
Height = 25
|
||||
Top = 361
|
||||
Width = 51
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Help'
|
||||
OnClick = HelpBtnClick
|
||||
TabOrder = 1
|
||||
inherited ResetBtn: TButton
|
||||
Left = 119
|
||||
Top = 315
|
||||
TabOrder = 6
|
||||
end
|
||||
object CloseBtn: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 348
|
||||
Height = 25
|
||||
Top = 361
|
||||
Width = 55
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
TabOrder = 4
|
||||
inherited HelpBtn: TButton
|
||||
Tag = 172
|
||||
Left = 60
|
||||
Top = 315
|
||||
TabOrder = 5
|
||||
end
|
||||
object Memo1: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 45
|
||||
Top = 8
|
||||
Width = 395
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'This is the Bartlett test of sphericity for three or more variables. Enter three or more of the variables listed in the left box and press the compute button to obtain the results.'
|
||||
ParentColor = False
|
||||
WordWrap = True
|
||||
inherited ButtonBevel: TBevel
|
||||
Top = 299
|
||||
Width = 320
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = CloseBtn
|
||||
object Label2: TLabel[5]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 345
|
||||
Width = 411
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
object Panel1: TPanel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Memo1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Bevel1
|
||||
Left = 0
|
||||
Height = 292
|
||||
Top = 53
|
||||
Width = 411
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 292
|
||||
ClientWidth = 411
|
||||
Constraints.MinHeight = 240
|
||||
TabOrder = 0
|
||||
object Label2: TLabel
|
||||
AnchorSideTop.Control = Panel1
|
||||
Left = 8
|
||||
Height = 15
|
||||
Top = 8
|
||||
Top = 0
|
||||
Width = 46
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Variables'
|
||||
ParentColor = False
|
||||
end
|
||||
object VarList: TListBox
|
||||
object VarList: TListBox[6]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = Label2
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AllBtn
|
||||
AnchorSideBottom.Control = ChiSqrEdit
|
||||
Left = 8
|
||||
Height = 198
|
||||
Top = 25
|
||||
Width = 166
|
||||
AnchorSideBottom.Control = ButtonBevel
|
||||
Left = 0
|
||||
Height = 282
|
||||
Top = 17
|
||||
Width = 134
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
BorderSpacing.Right = 6
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnDblClick = VarListDblClick
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 0
|
||||
end
|
||||
object Label3: TLabel
|
||||
object Label3: TLabel[7]
|
||||
AnchorSideLeft.Control = SelList
|
||||
AnchorSideTop.Control = Label2
|
||||
Left = 236
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
Left = 188
|
||||
Height = 15
|
||||
Top = 8
|
||||
Top = 0
|
||||
Width = 44
|
||||
Caption = 'Selected'
|
||||
ParentColor = False
|
||||
end
|
||||
object SelList: TListBox
|
||||
object SelList: TListBox[8]
|
||||
AnchorSideLeft.Control = AllBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Label3
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = VarList
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 236
|
||||
Height = 198
|
||||
Top = 25
|
||||
Width = 167
|
||||
Left = 188
|
||||
Height = 282
|
||||
Top = 17
|
||||
Width = 124
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnDblClick = SelListDblClick
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 4
|
||||
end
|
||||
object InBtn: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object InBtn: TBitBtn[9]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = VarList
|
||||
Left = 191
|
||||
Left = 147
|
||||
Height = 26
|
||||
Top = 25
|
||||
Width = 28
|
||||
Top = 17
|
||||
Width = 26
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 1
|
||||
OnClick = InBtnClick
|
||||
Spacing = 0
|
||||
TabOrder = 1
|
||||
end
|
||||
object OutBtn: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object OutBtn: TBitBtn[10]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = InBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 191
|
||||
Left = 147
|
||||
Height = 26
|
||||
Top = 55
|
||||
Width = 28
|
||||
Top = 47
|
||||
Width = 26
|
||||
BorderSpacing.Top = 4
|
||||
Images = MainDataModule.ImageList
|
||||
ImageIndex = 0
|
||||
@ -227,111 +130,25 @@ object BartlettTestForm: TBartlettTestForm
|
||||
Spacing = 0
|
||||
TabOrder = 2
|
||||
end
|
||||
object AllBtn: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
object AllBtn: TBitBtn[11]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = OutBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 182
|
||||
Left = 140
|
||||
Height = 25
|
||||
Top = 85
|
||||
Width = 46
|
||||
Top = 77
|
||||
Width = 40
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'ALL'
|
||||
Caption = 'All'
|
||||
OnClick = AllBtnClick
|
||||
Spacing = 0
|
||||
TabOrder = 3
|
||||
end
|
||||
object Label1: TLabel
|
||||
AnchorSideTop.Control = ChiSqrEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = ChiSqrEdit
|
||||
Left = 33
|
||||
Height = 15
|
||||
Top = 235
|
||||
Width = 60
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Chi Square:'
|
||||
ParentColor = False
|
||||
end
|
||||
object ChiSqrEdit: TEdit
|
||||
AnchorSideLeft.Control = DFEdit
|
||||
AnchorSideRight.Control = VarList
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Panel1
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 101
|
||||
Height = 23
|
||||
Top = 231
|
||||
Width = 73
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akLeft, akRight]
|
||||
ReadOnly = True
|
||||
TabOrder = 5
|
||||
Text = 'ChiSqrEdit'
|
||||
end
|
||||
object Label4: TLabel
|
||||
AnchorSideTop.Control = ProbEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = ProbEdit
|
||||
Left = 255
|
||||
Height = 15
|
||||
Top = 235
|
||||
Width = 60
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Probability:'
|
||||
ParentColor = False
|
||||
end
|
||||
object ProbEdit: TEdit
|
||||
AnchorSideTop.Control = ChiSqrEdit
|
||||
AnchorSideRight.Control = SelList
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 323
|
||||
Height = 23
|
||||
Top = 231
|
||||
Width = 80
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akTop, akRight]
|
||||
ReadOnly = True
|
||||
TabOrder = 6
|
||||
Text = 'ProbEdit'
|
||||
end
|
||||
object Label5: TLabel
|
||||
AnchorSideLeft.Control = VarList
|
||||
AnchorSideTop.Control = DFEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = DFEdit
|
||||
Left = 16
|
||||
Height = 15
|
||||
Top = 266
|
||||
Width = 77
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Left = 8
|
||||
Caption = 'Deg. Freedom:'
|
||||
ParentColor = False
|
||||
end
|
||||
object DFEdit: TEdit
|
||||
AnchorSideLeft.Control = Label5
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ChiSqrEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = ChiSqrEdit
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 101
|
||||
Height = 23
|
||||
Top = 262
|
||||
Width = 73
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
ReadOnly = True
|
||||
TabOrder = 7
|
||||
Text = 'DFEdit'
|
||||
end
|
||||
inherited ParamsSplitter: TSplitter
|
||||
Left = 332
|
||||
Height = 356
|
||||
end
|
||||
end
|
||||
|
@ -5,77 +5,156 @@ unit BartlettTestUnit;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Buttons, ExtCtrls,
|
||||
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs,
|
||||
MatrixLib, ContextHelpUnit;
|
||||
Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, Buttons, ExtCtrls,
|
||||
MainUnit, Globals, FunctionsLib, MatrixLib, BasicStatsReportFormUnit;
|
||||
|
||||
type
|
||||
|
||||
{ TBartlettTestForm }
|
||||
|
||||
TBartlettTestForm = class(TForm)
|
||||
TBartlettTestForm = class(TBasicStatsReportForm)
|
||||
AllBtn: TBitBtn;
|
||||
Bevel1: TBevel;
|
||||
Memo1: TLabel;
|
||||
Panel1: TPanel;
|
||||
CloseBtn: TButton;
|
||||
ChiSqrEdit: TEdit;
|
||||
DFEdit: TEdit;
|
||||
Label5: TLabel;
|
||||
ProbEdit: TEdit;
|
||||
HelpBtn: TButton;
|
||||
InBtn: TBitBtn;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
Label4: TLabel;
|
||||
ComputeBtn: TButton;
|
||||
OutBtn: TBitBtn;
|
||||
ResetBtn: TButton;
|
||||
SelList: TListBox;
|
||||
VarList: TListBox;
|
||||
procedure AllBtnClick(Sender: TObject);
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure InBtnClick(Sender: TObject);
|
||||
procedure OutBtnClick(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
procedure SelListDblClick(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
|
||||
BartlettTestForm: TBartlettTestForm;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Math, Utils;
|
||||
Utils, GridProcs;
|
||||
|
||||
{ TBartlettTestForm }
|
||||
|
||||
procedure TBartlettTestForm.ResetBtnClick(Sender: TObject);
|
||||
constructor TBartlettTestForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.AdjustConstraints;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
ParamsPanel.Constraints.MinWidth := CloseBtn.Width * 4 + CloseBtn.BorderSpacing.Left * 3;
|
||||
ParamsPanel.Constraints.MinHeight := AllBtn.Top + AllBtn.Height +
|
||||
VarList.BorderSpacing.Bottom + ButtonBevel.Height +
|
||||
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.AllBtnClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
ChiSqrEdit.Text := '';
|
||||
ProbEdit.Text := '';
|
||||
DFEdit.Text := '';
|
||||
for i := 0 to VarList.Items.Count-1 do
|
||||
SelList.Items.Add(VarList.Items[i]);
|
||||
VarList.Clear;
|
||||
SelList.Clear;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.Compute;
|
||||
VAR
|
||||
matrix: DblDyneMat = nil;
|
||||
means: DblDyneVec = nil;
|
||||
variances: DblDyneVec = nil;
|
||||
stddevs: DblDyneVec = nil;
|
||||
ColNoSelected: IntDyneVec = nil;
|
||||
DataGrid: DblDyneMat = nil;
|
||||
RowLabels: StrDyneVec = nil;
|
||||
ColLabels: StrDyneVec = nil;
|
||||
determinant, chisquare, probability: double;
|
||||
i, j, df, numVars, numCases, colno: integer;
|
||||
errorcode: boolean;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
numVars := SelList.Count;
|
||||
SetLength(matrix, numVars+1, numVars+1); // +1 due to augmentation
|
||||
SetLength(means, numVars+1);
|
||||
SetLength(stddevs, numVars+1);
|
||||
SetLength(variances, numVars+1);
|
||||
SetLength(ColNoSelected, numVars);
|
||||
SetLength(DataGrid, NoCases, numVars);
|
||||
SetLength(RowLabels, numVars);
|
||||
SetLength(ColLabels, numVars);
|
||||
|
||||
for j := 0 to numVars-1 do
|
||||
begin
|
||||
RowLabels[j] := SelList.Items[j];
|
||||
ColLabels[j] := RowLabels[j];
|
||||
ColNoSelected[j] := GetVariableIndex(OS3MainFrm.DataGrid, RowLabels[j]);
|
||||
end;
|
||||
|
||||
numCases := 0;
|
||||
errorcode := false;
|
||||
|
||||
// get data into the datagrid
|
||||
for j := 0 to numVars-1 do
|
||||
begin
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
|
||||
colno := ColNoSelected[j];
|
||||
DataGrid[i-1, j] := StrToFloat(OS3MainFrm.DataGrid.Cells[colno, i]);
|
||||
numCases := numCases + 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
lReport := TStringList.Create;
|
||||
try
|
||||
numCases := 0;
|
||||
Correlations(numVars, ColNoSelected, matrix, means, variances, stddevs, errorcode, numCases);
|
||||
|
||||
MatPrint(matrix, numVars, numVars, 'CORRELATION MATRIX', RowLabels, ColLabels, numCases, lReport);
|
||||
lReport.Add('');
|
||||
|
||||
Determ(matrix, numVars, numVars, determinant, errorcode);
|
||||
lReport.Add('Determinant of matrix: %8.3f', [determinant]);
|
||||
lReport.Add('');
|
||||
|
||||
chiSquare := -((numCases-1) - (2*numVars - 5)/6) * ln(determinant);
|
||||
df := (sqr(numVars)- numVars) div 2;
|
||||
probability := ChiSquaredProb(chiSquare, df);
|
||||
|
||||
lReport.Add('ChiSquare: %8.3f', [chisquare]);
|
||||
lReport.Add('Degrees of Freedom: %8d', [df]);
|
||||
lReport.Add('Probability > value: %8.3f', [1.0 - probability]);
|
||||
|
||||
FReportFrame.DisplayReport(lReport);
|
||||
|
||||
finally
|
||||
lReport.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.InBtnClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
@ -94,143 +173,6 @@ begin
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
procedure TBartlettTestForm.AllBtnClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to VarList.Items.Count-1 do
|
||||
SelList.Items.Add(VarList.Items[i]);
|
||||
VarList.Clear;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
procedure TBartlettTestForm.ComputeBtnClick(Sender: TObject);
|
||||
VAR
|
||||
matrix: DblDyneMat = nil;
|
||||
means: DblDyneVec = nil;
|
||||
variances: DblDyneVec = nil;
|
||||
stddevs: DblDyneVec = nil;
|
||||
ColNoSelected: IntDyneVec = nil;
|
||||
DataGrid: DblDyneMat = nil;
|
||||
RowLabels: StrDyneVec = nil;
|
||||
ColLabels: StrDyneVec = nil;
|
||||
determinant, chisquare, probability: double;
|
||||
i, j, df, p, ncases, colno: integer;
|
||||
title: string;
|
||||
dblvalue: double;
|
||||
errorcode: boolean;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
p := SelList.Count;
|
||||
SetLength(matrix, p+1, p+1);
|
||||
SetLength(means, p+1);
|
||||
SetLength(stddevs, p+1);
|
||||
SetLength(variances, p+1);
|
||||
SetLength(ColNoSelected, p+1);
|
||||
SetLength(DataGrid, NoCases, p+1);
|
||||
SetLength(RowLabels, p+1);
|
||||
SetLength(ColLabels, p+1);
|
||||
|
||||
for j := 0 to p-1 do
|
||||
begin
|
||||
for i := 1 to NoVariables do
|
||||
begin
|
||||
if SelList.Items.Strings[j] = OS3MainFrm.DataGrid.Cells[i,0] then
|
||||
begin
|
||||
ColNoSelected[j] := i;
|
||||
RowLabels[j] := OS3MainFrm.DataGrid.Cells[i,0];
|
||||
ColLabels[j] := OS3MainFrm.DataGrid.Cells[i,0];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
ncases := 0;
|
||||
errorcode := false;
|
||||
|
||||
// get data into the datagrid
|
||||
for j := 0 to p-1 do
|
||||
begin
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
if not GoodRecord(i, p, ColNoSelected) then continue;
|
||||
colno := ColNoSelected[j];
|
||||
dblvalue := StrToFloat(OS3MainFrm.DataGrid.Cells[colno, i]);
|
||||
DataGrid[i-1,j] := dblvalue;
|
||||
ncases := ncases + 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
lReport := TStringList.Create;
|
||||
try
|
||||
ncases := 0;
|
||||
Correlations(p, ColNoSelected, matrix, means, variances, stddevs, errorcode, ncases);
|
||||
|
||||
title := 'CORRELATION MATRIX';
|
||||
MatPrint(matrix, p, p, title, RowLabels, ColLabels, ncases, lReport);
|
||||
lReport.Add('');
|
||||
|
||||
Determ(matrix, p, p, determinant, errorcode);
|
||||
lReport.Add('Determinant of matrix: %8.3f', [determinant]);
|
||||
lReport.Add('');
|
||||
|
||||
chisquare := -((ncases-1) - (2.0*p-5)/6) * ln(determinant);
|
||||
df := ((p * p) - p) div 2;
|
||||
probability := chisquaredprob(chisquare,df);
|
||||
|
||||
//chivalue := format('%8.3f',[chisquare]);
|
||||
ChiSqrEdit.Text := Format('%.3f', [chisquare]);;
|
||||
ProbEdit.Text := Format('%.3f', [1.0-probability]);
|
||||
DFEdit.Text := IntToStr(df);
|
||||
|
||||
lReport.Add('ChiSquare: %8.3f', [chisquare]);
|
||||
lReport.Add('Degrees of Freedom: %8d', [df]);
|
||||
lReport.Add('Probability > value: %8.3f', [1.0 - probability]);
|
||||
|
||||
DisplayReport(lReport);
|
||||
|
||||
finally
|
||||
lReport.Free;
|
||||
ColLabels := nil;
|
||||
RowLabels := nil;
|
||||
DataGrid := nil;
|
||||
ColNoSelected := nil;
|
||||
variances := nil;
|
||||
stddevs := nil;
|
||||
means := nil;
|
||||
matrix := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBartlettTestForm.FormActivate(Sender: TObject);
|
||||
var
|
||||
w: Integer;
|
||||
begin
|
||||
if FAutoSized then
|
||||
exit;
|
||||
|
||||
w := {%H-}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.MinHeight := Height;
|
||||
Constraints.MinWidth := Width;
|
||||
|
||||
FAutoSized := true;
|
||||
end;
|
||||
|
||||
procedure TBartlettTestForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Assert(OS3MainFrm <> nil);
|
||||
end;
|
||||
|
||||
procedure TBartlettTestForm.HelpBtnClick(Sender: TObject);
|
||||
begin
|
||||
if ContextHelpForm = nil then
|
||||
Application.CreateForm(TContextHelpForm, ContextHelpForm);
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
||||
end;
|
||||
|
||||
procedure TBartlettTestForm.OutBtnClick(Sender: TObject);
|
||||
var
|
||||
@ -250,13 +192,58 @@ begin
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.Reset;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
SelList.Clear;
|
||||
VarList.Clear;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.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 TBartlettTestForm.UpdateBtnStates;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
InBtn.Enabled := AnySelected(VarList);
|
||||
OutBtn.Enabled := AnySelected(SelList);
|
||||
AllBtn.Enabled := VarList.Items.Count > 0;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBartlettTestForm.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 TBartlettTestForm.VarListSelectionChange(Sender: TObject;
|
||||
User: boolean);
|
||||
begin
|
||||
@ -264,8 +251,5 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I bartletttestunit.lrs}
|
||||
|
||||
end.
|
||||
|
||||
|
@ -13,7 +13,7 @@ object MedianPolishForm: TMedianPolishForm
|
||||
OnCreate = FormCreate
|
||||
OnShow = ResetBtnClick
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
LCLVersion = '2.0.10.0'
|
||||
object ResetBtn: TButton
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
@ -69,7 +69,7 @@ object MedianPolishForm: TMedianPolishForm
|
||||
ModalResult = 11
|
||||
TabOrder = 3
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
object ButtonBevel: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
@ -86,7 +86,7 @@ object MedianPolishForm: TMedianPolishForm
|
||||
AnchorSideTop.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Bevel1
|
||||
AnchorSideBottom.Control = ButtonBevel
|
||||
Left = 0
|
||||
Height = 361
|
||||
Top = 0
|
||||
|
@ -21,7 +21,7 @@ type
|
||||
{ TMedianPolishForm }
|
||||
|
||||
TMedianPolishForm = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
ButtonBevel: TBevel;
|
||||
NormChk: TCheckBox;
|
||||
MaxEdit: TEdit;
|
||||
Label4: TLabel;
|
||||
|
@ -733,77 +733,6 @@ begin
|
||||
DblDeclineFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu" "Analysis" > "Multivariate" > "Average Link Clustering"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_AvgLinkClick(Sender: TObject);
|
||||
begin
|
||||
if AvgLinkFrm = nil then
|
||||
Application.CreateForm(TAvgLinkFrm, AvgLinkFrm);
|
||||
AvgLinkFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "K Means Clustering"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_KMeansClick(Sender: TObject);
|
||||
begin
|
||||
if KMeansFrm = nil then
|
||||
Application.CreateForm(TKMeansFrm, KMeansFrm);
|
||||
kmeansfrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Single Link Clustering"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_SingleLinkClick(Sender: TObject);
|
||||
begin
|
||||
if SingleLinkFrm = nil then
|
||||
Application.CreateForm(TSingleLinkFrm, SingleLinkFrm);
|
||||
SingleLinkFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "MANOVA / Discriminant Function"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_MANOVAClick(Sender: TObject);
|
||||
begin
|
||||
if DiscrimFrm = nil then
|
||||
Application.CreateForm(TDiscrimFrm, DiscrimFrm);
|
||||
DiscrimFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Hierarchical Analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_HierarchicalClick(Sender: TObject);
|
||||
begin
|
||||
if HierarchForm = nil then
|
||||
Application.CreateForm(THierarchForm, HierarchForm);
|
||||
HierarchForm.Show;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Path analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_PathClick(Sender: TObject);
|
||||
begin
|
||||
if PathFrm = nil then
|
||||
Application.CreateForm(TPathFrm, PathFrm);
|
||||
PathFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Factor analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_FactorClick(Sender: TObject);
|
||||
begin
|
||||
if FactorFrm = nil then
|
||||
Application.CreateForm(TFactorFrm, FactorFrm);
|
||||
FactorFrm.ShowModal;
|
||||
end;
|
||||
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_CanonicalClick(Sender: TObject);
|
||||
begin
|
||||
if CanonicalForm = nil then
|
||||
Application.CreateForm(TCanonicalForm, CanonicalForm);
|
||||
CanonicalForm.Show;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Generalized Kappa"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_GLMClick(Sender: TObject);
|
||||
begin
|
||||
if GLMFrm = nil then
|
||||
Application.CreateForm(TGLMFrm, GLMFrm);
|
||||
GLMFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Cross-classification" > "AxB Log Linear"
|
||||
procedure TOS3MainFrm.mnuAnalysisCC_ABLogLinClick(Sender: TObject);
|
||||
begin
|
||||
@ -1005,22 +934,6 @@ begin
|
||||
if DataGrid.Cells[PrevCol,PrevRow] <> '' then FormatCell(PrevCol,PrevRow);
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Bartlett Test of Sphericity"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_BartlettClick(Sender: TObject);
|
||||
begin
|
||||
if BartlettTestForm = nil then
|
||||
Application.CreateForm(TBartlettTestForm, BartlettTestform);
|
||||
BartlettTestForm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_CorrespondenceClick(Sender: TObject);
|
||||
begin
|
||||
if CorrespondenceForm = nil then
|
||||
Application.CreateForm(TCorrespondenceForm, CorrespondenceForm);
|
||||
CorrespondenceForm.ShowModal;
|
||||
end;
|
||||
|
||||
procedure TOS3MainFrm.DataGridClick(Sender: TObject);
|
||||
begin
|
||||
RowEdit.Text := IntToStr(DataGrid.Row);
|
||||
@ -2219,6 +2132,97 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{ Multivariate commands }
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Bartlett Test of Sphericity"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_BartlettClick(Sender: TObject);
|
||||
begin
|
||||
if BartlettTestForm = nil then
|
||||
Application.CreateForm(TBartlettTestForm, BartlettTestform);
|
||||
BartlettTestForm.Show;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_CorrespondenceClick(Sender: TObject);
|
||||
begin
|
||||
if CorrespondenceForm = nil then
|
||||
Application.CreateForm(TCorrespondenceForm, CorrespondenceForm);
|
||||
CorrespondenceForm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu" "Analysis" > "Multivariate" > "Average Link Clustering"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_AvgLinkClick(Sender: TObject);
|
||||
begin
|
||||
if AvgLinkFrm = nil then
|
||||
Application.CreateForm(TAvgLinkFrm, AvgLinkFrm);
|
||||
AvgLinkFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "K Means Clustering"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_KMeansClick(Sender: TObject);
|
||||
begin
|
||||
if KMeansFrm = nil then
|
||||
Application.CreateForm(TKMeansFrm, KMeansFrm);
|
||||
kmeansfrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Single Link Clustering"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_SingleLinkClick(Sender: TObject);
|
||||
begin
|
||||
if SingleLinkFrm = nil then
|
||||
Application.CreateForm(TSingleLinkFrm, SingleLinkFrm);
|
||||
SingleLinkFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "MANOVA / Discriminant Function"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_MANOVAClick(Sender: TObject);
|
||||
begin
|
||||
if DiscrimFrm = nil then
|
||||
Application.CreateForm(TDiscrimFrm, DiscrimFrm);
|
||||
DiscrimFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Hierarchical Analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_HierarchicalClick(Sender: TObject);
|
||||
begin
|
||||
if HierarchForm = nil then
|
||||
Application.CreateForm(THierarchForm, HierarchForm);
|
||||
HierarchForm.Show;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Path analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_PathClick(Sender: TObject);
|
||||
begin
|
||||
if PathFrm = nil then
|
||||
Application.CreateForm(TPathFrm, PathFrm);
|
||||
PathFrm.ShowModal;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Factor analysis"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_FactorClick(Sender: TObject);
|
||||
begin
|
||||
if FactorFrm = nil then
|
||||
Application.CreateForm(TFactorFrm, FactorFrm);
|
||||
FactorFrm.ShowModal;
|
||||
end;
|
||||
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_CanonicalClick(Sender: TObject);
|
||||
begin
|
||||
if CanonicalForm = nil then
|
||||
Application.CreateForm(TCanonicalForm, CanonicalForm);
|
||||
CanonicalForm.Show;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "Generalized Kappa"
|
||||
procedure TOS3MainFrm.mnuAnalysisMulti_GLMClick(Sender: TObject);
|
||||
begin
|
||||
if GLMFrm = nil then
|
||||
Application.CreateForm(TGLMFrm, GLMFrm);
|
||||
GLMFrm.ShowModal;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ SPC commands }
|
||||
|
||||
// Menu "Analysis" > "Statistical Process Control" > "Defect (nonconformity) c Chart"
|
||||
|
@ -332,7 +332,7 @@ procedure Correlations(NoSelected: integer; const Selected: IntDyneVec;
|
||||
var
|
||||
i, j: integer;
|
||||
begin
|
||||
// get covariance matrix, means and standard deviations
|
||||
// Get covariance matrix, means and standard deviations
|
||||
GridCovar(NoSelected, Selected, Correlations, Means, Variances, StdDevs, ErrorCode, Ngood);
|
||||
for i := 0 to NoSelected-1 do
|
||||
begin
|
||||
|
Reference in New Issue
Block a user