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:
wp_xxyyzz
2020-11-16 18:42:40 +00:00
parent 25f1fc4f27
commit 4a72eb5f1e
7 changed files with 339 additions and 533 deletions

View File

@ -20,7 +20,7 @@ correlation, means, standard deviations and confidence interval for each correla
116=Directions: Select each categorical variable from the available variables in the leftmost box in the order that you wish to have the breakdown proceed. Click the OK button to start the analysis. 116=Directions: Select each categorical variable from the available variables in the leftmost box in the order that you wish to have the breakdown proceed. Click the OK button to start the analysis.
117=Directions: First, click on the variable name that represents the sample lot number. Next, click on the variable that represents the measurement. Click on the Delta size and enter the desired value. Click on the alpha and/or beta probability boxes and enter values to change from the default values. You may also enter target specifications if you first click the check box to use a target specification. 117=Directions: First, click on the variable name that represents the sample lot number. Next, click on the variable that represents the measurement. Click on the Delta size and enter the desired value. Click on the alpha and/or beta probability boxes and enter values to change from the default values. You may also enter target specifications if you first click the check box to use a target specification.
118=Description: Double Declining Value determines accelerated depreciation values for an asset given the initial cost, life expectancy, and value, and depreciation period. EXAMPLE: What is the depreciation value for a computer with a life expectancy of three years if it initially cost $2,000.00 with no expected value at the end of the three years? Initial Cost = 2000.00 Life Expectancy = 3 End Value = 0.0 Depreciation Period = 3 ANSWER: $148.15 118=Description: Double Declining Value determines accelerated depreciation values for an asset given the initial cost, life expectancy, and value, and depreciation period. EXAMPLE: What is the depreciation value for a computer with a life expectancy of three years if it initially cost $2,000.00 with no expected value at the end of the three years? Initial Cost = 2000.00 Life Expectancy = 3 End Value = 0.0 Depreciation Period = 3 ANSWER: $148.15
119=This procedure provides means, variances, standard deviations, skewness, kurtosis and range values for each variable selected. Select the variables in the left list and enter them for analysiis by clicking the right arrow. If you select the z score option, a new variable will be added to your grid for each variable you select. The new variable will contain the transformation of the original variable into a z score. 119=This procedure provides means, variances, standard deviations, skewness, kurtosis and range values for each variable selected. Select the variables in the left list and enter them for analysiis by clicking the right arrow. If you select the z score option, a new variable will be added to your grid for each variable you select. The new variable will contain the transformation of the original variable into a z score.
120=Each row of the grid below corresponds to one column of the data grid. Complete the information requested in each cell of the row. To add another variable (row in the dictionary), press the down-arrow on your keyboard. 120=Each row of the grid below corresponds to one column of the data grid. Complete the information requested in each cell of the row. To add another variable (row in the dictionary), press the down-arrow on your keyboard.
121=Directions: Specify the lag value for the differences desired, e.g. 1 to obtain the difference between point 1 and 2, 2, and 3, etc. Also, indicate the order, i.e. the number of times to repeat the differencing operation. Click OK when ready. 121=Directions: Specify the lag value for the differences desired, e.g. 1 to obtain the difference between point 1 and 2, 2, and 3, etc. Also, indicate the order, i.e. the number of times to repeat the differencing operation. Click OK when ready.
122=This procedure is an adaptation of the program written by Niels G. Waller, Dept. of Psychology, University of California-Davis, Jan. 1998. It's purpose is to identify test items that differ in the response pattern for two groups: a reference group and a focal group. The file of data to be analyzed should consist of a variable containing a code designating the two groups and variables containing subject's item responses coded 0 for incorrect and 1 for correct. No missing data may be included. The results provide the Mantel-Haenszel statistics for identifying those items which are different for the two groups. 122=This procedure is an adaptation of the program written by Niels G. Waller, Dept. of Psychology, University of California-Davis, Jan. 1998. It's purpose is to identify test items that differ in the response pattern for two groups: a reference group and a focal group. The file of data to be analyzed should consist of a variable containing a code designating the two groups and variables containing subject's item responses coded 0 for incorrect and 1 for correct. No missing data may be included. The results provide the Mantel-Haenszel statistics for identifying those items which are different for the two groups.
@ -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. 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. 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. 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.

View File

@ -1,225 +1,128 @@
object BartlettTestForm: TBartlettTestForm inherited BartlettTestForm: TBartlettTestForm
Left = 474 Left = 474
Height = 394 Height = 356
Top = 304 Top = 304
Width = 411 Width = 639
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/BartlettTestofSphericity.htm' HelpKeyword = 'html/BartlettTestofSphericity.htm'
AutoSize = True
Caption = 'Bartlett Test of Sphericity' Caption = 'Bartlett Test of Sphericity'
ClientHeight = 394 ClientHeight = 356
ClientWidth = 411 ClientWidth = 639
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 340
OnShow = ResetBtnClick Width = 320
Position = poMainFormCenter ClientHeight = 340
LCLVersion = '2.1.0.0' ClientWidth = 320
object ResetBtn: TButton inherited CloseBtn: TButton
AnchorSideRight.Control = ComputeBtn Left = 265
AnchorSideBottom.Control = Owner Top = 315
AnchorSideBottom.Side = asrBottom TabOrder = 8
Left = 202 end
Height = 25 inherited ComputeBtn: TButton
Top = 361 Left = 181
Width = 54 Top = 315
Anchors = [akRight, akBottom] TabOrder = 7
AutoSize = True end
BorderSpacing.Left = 8 inherited ResetBtn: TButton
BorderSpacing.Top = 8 Left = 119
BorderSpacing.Right = 8 Top = 315
BorderSpacing.Bottom = 8 TabOrder = 6
Caption = 'Reset' end
OnClick = ResetBtnClick inherited HelpBtn: TButton
TabOrder = 2 Tag = 172
end Left = 60
object ComputeBtn: TButton Top = 315
AnchorSideRight.Control = CloseBtn TabOrder = 5
AnchorSideBottom.Control = Owner end
AnchorSideBottom.Side = asrBottom inherited ButtonBevel: TBevel
Left = 264 Top = 299
Height = 25 Width = 320
Top = 361 end
Width = 76 object Label2: TLabel[5]
Anchors = [akRight, akBottom] AnchorSideLeft.Control = ParamsPanel
AutoSize = True AnchorSideTop.Control = ParamsPanel
BorderSpacing.Left = 8 Left = 0
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 3
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
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
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
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
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 Height = 15
Top = 8 Top = 0
Width = 46 Width = 46
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Variables' Caption = 'Variables'
ParentColor = False ParentColor = False
end end
object VarList: TListBox object VarList: TListBox[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label2 AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = ChiSqrEdit AnchorSideBottom.Control = ButtonBevel
Left = 8 Left = 0
Height = 198 Height = 282
Top = 25 Top = 17
Width = 166 Width = 134
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 6
BorderSpacing.Bottom = 8
ItemHeight = 0 ItemHeight = 0
MultiSelect = True MultiSelect = True
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object Label3: TLabel object Label3: TLabel[7]
AnchorSideLeft.Control = SelList AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Label2 AnchorSideTop.Control = ParamsPanel
Left = 236 Left = 188
Height = 15 Height = 15
Top = 8 Top = 0
Width = 44 Width = 44
Caption = 'Selected' Caption = 'Selected'
ParentColor = False ParentColor = False
end end
object SelList: TListBox object SelList: TListBox[8]
AnchorSideLeft.Control = AllBtn AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3 AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = VarList AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 236 Left = 188
Height = 198 Height = 282
Top = 25 Top = 17
Width = 167 Width = 124
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 8
ItemHeight = 0 ItemHeight = 0
MultiSelect = True MultiSelect = True
OnDblClick = SelListDblClick
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 4 TabOrder = 4
end end
object InBtn: TBitBtn object InBtn: TBitBtn[9]
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
Left = 191 Left = 147
Height = 26 Height = 26
Top = 25 Top = 17
Width = 28 Width = 26
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
OnClick = InBtnClick OnClick = InBtnClick
Spacing = 0 Spacing = 0
TabOrder = 1 TabOrder = 1
end end
object OutBtn: TBitBtn object OutBtn: TBitBtn[10]
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 191 Left = 147
Height = 26 Height = 26
Top = 55 Top = 47
Width = 28 Width = 26
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
@ -227,111 +130,25 @@ object BartlettTestForm: TBartlettTestForm
Spacing = 0 Spacing = 0
TabOrder = 2 TabOrder = 2
end end
object AllBtn: TBitBtn object AllBtn: TBitBtn[11]
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn AnchorSideTop.Control = OutBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 182 Left = 140
Height = 25 Height = 25
Top = 85 Top = 77
Width = 46 Width = 40
AutoSize = True AutoSize = True
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Caption = 'ALL' Caption = 'All'
OnClick = AllBtnClick OnClick = AllBtnClick
Spacing = 0 Spacing = 0
TabOrder = 3 TabOrder = 3
end end
object Label1: TLabel end
AnchorSideTop.Control = ChiSqrEdit inherited ParamsSplitter: TSplitter
AnchorSideTop.Side = asrCenter Left = 332
AnchorSideRight.Control = ChiSqrEdit Height = 356
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
end end
end end

View File

@ -5,77 +5,156 @@ unit BartlettTestUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, Buttons, ExtCtrls,
StdCtrls, Buttons, ExtCtrls, MainUnit, Globals, FunctionsLib, MatrixLib, BasicStatsReportFormUnit;
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs,
MatrixLib, ContextHelpUnit;
type type
{ TBartlettTestForm } { TBartlettTestForm }
TBartlettTestForm = class(TForm) TBartlettTestForm = class(TBasicStatsReportForm)
AllBtn: TBitBtn; AllBtn: TBitBtn;
Bevel1: TBevel;
Memo1: TLabel;
Panel1: TPanel;
CloseBtn: TButton;
ChiSqrEdit: TEdit;
DFEdit: TEdit;
Label5: TLabel;
ProbEdit: TEdit;
HelpBtn: TButton;
InBtn: TBitBtn; InBtn: TBitBtn;
Label1: TLabel;
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
Label4: TLabel;
ComputeBtn: TButton;
OutBtn: TBitBtn; OutBtn: TBitBtn;
ResetBtn: TButton;
SelList: TListBox; SelList: TListBox;
VarList: TListBox; VarList: TListBox;
procedure AllBtnClick(Sender: TObject); 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 InBtnClick(Sender: TObject);
procedure OutBtnClick(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); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private private
{ private declarations }
FAutoSized: Boolean; protected
procedure UpdateBtnStates; procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end; end;
var var
BartlettTestForm: TBartlettTestForm; BartlettTestForm: TBartlettTestForm;
implementation implementation
{$R *.lfm}
uses uses
Math, Utils; Utils, GridProcs;
{ TBartlettTestForm } { 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 var
i: integer; i: integer;
begin begin
ChiSqrEdit.Text := ''; for i := 0 to VarList.Items.Count-1 do
ProbEdit.Text := ''; SelList.Items.Add(VarList.Items[i]);
DFEdit.Text := '';
VarList.Clear; VarList.Clear;
SelList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates; UpdateBtnStates;
end; 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); procedure TBartlettTestForm.InBtnClick(Sender: TObject);
var var
i: integer; i: integer;
@ -94,143 +173,6 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; 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); procedure TBartlettTestForm.OutBtnClick(Sender: TObject);
var var
@ -250,13 +192,58 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; 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; procedure TBartlettTestForm.UpdateBtnStates;
begin begin
inherited;
InBtn.Enabled := AnySelected(VarList); InBtn.Enabled := AnySelected(VarList);
OutBtn.Enabled := AnySelected(SelList); OutBtn.Enabled := AnySelected(SelList);
AllBtn.Enabled := VarList.Items.Count > 0; AllBtn.Enabled := VarList.Items.Count > 0;
end; 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; procedure TBartlettTestForm.VarListSelectionChange(Sender: TObject;
User: boolean); User: boolean);
begin begin
@ -264,8 +251,5 @@ begin
end; end;
initialization
{$I bartletttestunit.lrs}
end. end.

View File

@ -13,7 +13,7 @@ object MedianPolishForm: TMedianPolishForm
OnCreate = FormCreate OnCreate = FormCreate
OnShow = ResetBtnClick OnShow = ResetBtnClick
Position = poMainFormCenter Position = poMainFormCenter
LCLVersion = '2.1.0.0' LCLVersion = '2.0.10.0'
object ResetBtn: TButton object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
@ -69,7 +69,7 @@ object MedianPolishForm: TMedianPolishForm
ModalResult = 11 ModalResult = 11
TabOrder = 3 TabOrder = 3
end end
object Bevel1: TBevel object ButtonBevel: TBevel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -86,7 +86,7 @@ object MedianPolishForm: TMedianPolishForm
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1 AnchorSideBottom.Control = ButtonBevel
Left = 0 Left = 0
Height = 361 Height = 361
Top = 0 Top = 0

View File

@ -21,7 +21,7 @@ type
{ TMedianPolishForm } { TMedianPolishForm }
TMedianPolishForm = class(TForm) TMedianPolishForm = class(TForm)
Bevel1: TBevel; ButtonBevel: TBevel;
NormChk: TCheckBox; NormChk: TCheckBox;
MaxEdit: TEdit; MaxEdit: TEdit;
Label4: TLabel; Label4: TLabel;

View File

@ -733,77 +733,6 @@ begin
DblDeclineFrm.ShowModal; DblDeclineFrm.ShowModal;
end; 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" // Menu "Analysis" > "Cross-classification" > "AxB Log Linear"
procedure TOS3MainFrm.mnuAnalysisCC_ABLogLinClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisCC_ABLogLinClick(Sender: TObject);
begin begin
@ -1005,22 +934,6 @@ begin
if DataGrid.Cells[PrevCol,PrevRow] <> '' then FormatCell(PrevCol,PrevRow); if DataGrid.Cells[PrevCol,PrevRow] <> '' then FormatCell(PrevCol,PrevRow);
end; 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); procedure TOS3MainFrm.DataGridClick(Sender: TObject);
begin begin
RowEdit.Text := IntToStr(DataGrid.Row); RowEdit.Text := IntToStr(DataGrid.Row);
@ -2219,6 +2132,97 @@ begin
end; 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 } { SPC commands }
// Menu "Analysis" > "Statistical Process Control" > "Defect (nonconformity) c Chart" // Menu "Analysis" > "Statistical Process Control" > "Defect (nonconformity) c Chart"

View File

@ -284,7 +284,7 @@ begin
Augment := true; // augment to get intercept, means, variances, std.devs. Augment := true; // augment to get intercept, means, variances, std.devs.
// get cross-products // get cross-products
GridXProd(NoSelected,Selected,Covar,Augment,Ngood); GridXProd(NoSelected, Selected, Covar, Augment,Ngood);
// Get no. of records in cross-products // Get no. of records in cross-products
N := Ngood; N := Ngood;
@ -332,7 +332,7 @@ procedure Correlations(NoSelected: integer; const Selected: IntDyneVec;
var var
i, j: integer; i, j: integer;
begin begin
// get covariance matrix, means and standard deviations // Get covariance matrix, means and standard deviations
GridCovar(NoSelected, Selected, Correlations, Means, Variances, StdDevs, ErrorCode, Ngood); GridCovar(NoSelected, Selected, Correlations, Means, Variances, StdDevs, ErrorCode, Ngood);
for i := 0 to NoSelected-1 do for i := 0 to NoSelected-1 do
begin begin