LazStats: Inherit tTestUnit from TBasicStatsReportFormUnit

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7844 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-04 23:14:23 +00:00
parent 9953cfe29b
commit ff2834b9fe
9 changed files with 1022 additions and 926 deletions

View File

@ -69,4 +69,5 @@ correlation, means, standard deviations and confidence interval for each correla
165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button. 165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button.
166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis. 166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis.
167=Notes: This is a non-parametric analysis of ordinal data.\nIt is similar to a two-way Analysis of Variance but utilizes a chi-square statistic (H) for determining the significance of the row, column and interaction effects. The dependent value, if not initially rank data, may be obtained first by creating a new variable with the "transformation" procedure available under the "Variables" menu. The output of this procedure contains the results both of a "traditional" 2-way ANOVA as well as the SRH results.\nIt should be noted that the power of the SRH analysis is less than that of the traditional ANOVA. It is suggested that there be at least 5 or more cases in each cell and that the design is a balanced design of fixed levels.\nThe H statistic is obtained as the division of the sum of squares for an effect by the mean square of the total and the test is performed by a chi-squared probability with the degrees of freedom equal to the SS of the effect being tested. 167=Notes: This is a non-parametric analysis of ordinal data.\nIt is similar to a two-way Analysis of Variance but utilizes a chi-square statistic (H) for determining the significance of the row, column and interaction effects. The dependent value, if not initially rank data, may be obtained first by creating a new variable with the "transformation" procedure available under the "Variables" menu. The output of this procedure contains the results both of a "traditional" 2-way ANOVA as well as the SRH results.\nIt should be noted that the power of the SRH analysis is less than that of the traditional ANOVA. It is suggested that there be at least 5 or more cases in each cell and that the design is a balanced design of fixed levels.\nThe H statistic is obtained as the division of the sum of squares for an effect by the mean square of the total and the test is performed by a chi-squared probability with the degrees of freedom equal to the SS of the effect being tested.
168=This procedure lets you enter the number of observed values and the number of expected values for one or more categories.\nEnter the values as indicated and when finished, press the compute button. 168=This procedure lets you enter the number of observed values and the number of expected values for one or more categories.\nEnter the values as indicated and when finished, press the compute button.
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.

View File

@ -323,7 +323,7 @@
<Unit27> <Unit27>
<Filename Value="forms\analysis\comparisons\ttestunit.pas"/> <Filename Value="forms\analysis\comparisons\ttestunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="TtestFrm"/> <ComponentName Value="TtestForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TTestUnit"/> <UnitName Value="TTestUnit"/>

View File

@ -99,11 +99,11 @@ type
procedure TukeyBTest( procedure TukeyBTest(
ErrorMS : double; { within groups error } ErrorMS : double; { within groups error }
ErrorDF : double; { degrees of freedom within } ErrorDF : double; { degrees of freedom within }
group_total : DblDyneVec; { vector of group sums } group_total : DblDyneVec; { vector of group sums }
group_count : DblDyneVec; { vector of group n's } group_count : DblDyneVec; { vector of group n's }
min_grp : integer; { smallest group code } min_grp : integer; { smallest group code }
max_grp : integer; { largest group code } max_grp : integer; { largest group code }
groupsize : double; { size of groups (all equal) } groupsize : double; { size of groups (all equal) }
AReport : TStrings); AReport : TStrings);
public public

View File

@ -5,45 +5,44 @@ unit TTestUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, ExtCtrls, StdCtrls, Buttons,
MainUnit, Globals, OutputUnit, DataProcs; MainUnit, Globals, BasicStatsReportFormUnit;
type type
{ TTtestFrm } { TTtestForm }
TTtestFrm = class(TForm) TTtestForm = class(TBasicStatsReportForm)
Bevel1: TBevel;
Bevel2: TBevel;
Bevel3: TBevel; Bevel3: TBevel;
Bevel4: TBevel; Bevel4: TBevel;
Bevel5: TBevel; Bevel5: TBevel;
GroupBox1: TGroupBox; TailCombo: TComboBox;
GroupCodeBtn: TCheckBox; GroupCodeGroup: TGroupBox;
Grp1Code: TEdit; GroupCodeChk: TCheckBox;
Grp2Code: TEdit; Grp1CodeEdit: TEdit;
Grp2CodeEdit: TEdit;
GrpCodeLabel1: TLabel; GrpCodeLabel1: TLabel;
GrpCodeLabel2: TLabel; GrpCodeLabel2: TLabel;
Memo1: TLabel; GrpIn: TBitBtn;
Notebook1: TNotebook; GrpOut: TBitBtn;
Label2: TLabel;
Notebook: TNotebook;
Page1: TPage; Page1: TPage;
Page2: TPage; Page2: TPage;
RadioGroup3: TRadioGroup; Cor12Label: TLabel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
CorBetweenLabel: TLabel;
Cor12: TEdit; Cor12: TEdit;
CInterval: TEdit; CInterval: TEdit;
Grp: TEdit; GrpEdit: TEdit;
Label1: TLabel; Label1: TLabel;
Var2: TEdit; Var1In: TBitBtn;
Var1: TEdit; Var1Out: TBitBtn;
FirstVarLabel: TLabel; Var2Edit: TEdit;
Var1Edit: TEdit;
Var1Label: TLabel;
GrpLabel: TLabel; GrpLabel: TLabel;
SecdVarLabel: TLabel; Var2Label: TLabel;
ListBox1: TListBox; VarList: TListBox;
SelVarLabel: TLabel; SelVarLabel: TLabel;
N2: TEdit; N2: TEdit;
N1: TEdit; N1: TEdit;
@ -57,129 +56,88 @@ type
Mean1: TEdit; Mean1: TEdit;
Mean2Label: TLabel; Mean2Label: TLabel;
Mean1Label: TLabel; Mean1Label: TLabel;
Panel2: TPanel; DataEntryGroup: TRadioGroup;
RadioGroup1: TRadioGroup; DepIndepGroup: TRadioGroup;
RadioGroup2: TRadioGroup; Var2In: TBitBtn;
procedure ComputeBtnClick(Sender: TObject); Var2Out: TBitBtn;
procedure FormActivate(Sender: TObject); procedure GroupCodeChkChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure DataEntryGroupClick(Sender: TObject);
procedure FormShow(Sender: TObject); procedure DepIndepGroupClick(Sender: TObject);
procedure GroupCodeBtnChange(Sender: TObject); procedure GrpInClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject); procedure GrpOutClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject); procedure Var1InClick(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject); procedure Var1OutClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject); procedure Var2InClick(Sender: TObject);
procedure Var2OutClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private private
{ private declarations }
FAutoSized: Boolean;
independent: boolean; independent: boolean;
griddata: boolean; griddata: boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end; end;
var var
TtestFrm: TTtestFrm; TtestForm: TTtestForm;
implementation implementation
{$R *.lfm}
uses uses
Math, MathUnit; Math,
MathUnit, GridProcs;
{ TTtestFrm }
procedure TTtestFrm.ResetBtnClick(Sender: TObject); { TTtestForm }
var
i: integer; constructor TTtestForm.Create(AOwner: TComponent);
begin begin
inherited;
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT); CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
RadioGroup1.ItemIndex := 0;
RadioGroup2.ItemIndex := 0;
Notebook1.PageIndex := RadioGroup1.ItemIndex;
ListBox1.Clear;
Var1.Text := '';
Var2.Text := '';
Mean1.Text := '';
Mean2.Text := '';
SD1.Text := '';
SD2.Text := '';
N1.Text := '';
N2.Text := '';
Cor12.Text := '';
independent := true;
griddata := false;
GroupCodeBtn.Checked := false;
Grp.Text := '';
for i := 1 to NoVariables do
ListBox1.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Grp.Text := '';
Grp1Code.Text := '';
Grp2Code.Text := '';
end; end;
procedure TTtestFrm.FormActivate(Sender: TObject);
var procedure TTtestForm.AdjustConstraints;
w: Integer;
begin begin
if FAutoSized then inherited;
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); ParamsPanel.Constraints.MinWidth := Max(
ResetBtn.Constraints.MinWidth := w; DataEntryGroup.Width + DepIndepGroup.BorderSpacing.Left + DepIndepGroup.Width,
ComputeBtn.Constraints.MinWidth := w; 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left
CloseBtn.Constraints.MinWidth := w; );
ParamsPanel.Constraints.MinHeight := DataEntryGroup.Height +
Constraints.MinWidth := CInterval.Left + CInterval.Width + (Width - ResetBtn.Left) + ResetBtn.BorderSpacing.Left; TailCombo.BorderSpacing.Top + TailCombo.Height +
CInterval.BorderSpacing.Top + CInterval.Height + CInterval.BorderSpacing.Bottom +
Bevel5.Width := SecdVarLabel.Canvas.TextWidth(SecdVarlabel.Caption); Bevel3.Height + Bevel3.BorderSpacing.Bottom +
//ListBox1.Constraints.MinHeight := Grp2Code.Top + Grp2Code.Height - Listbox1.Top - Var2.Height - Var2.BorderSpacing.Top; GrpIn.Top + GroupCodeGroup.Height +
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
//Constraints.MinHeight := ListBox1.Top + ListBox1.Constraints.MinHeight + Bevel2.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top*2;
FAutoSized := true;
end; end;
procedure TTtestFrm.FormCreate(Sender: TObject);
begin procedure TTtestForm.Compute;
Assert(OS3MainFrm <> nil);
end;
procedure TTtestFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TTtestFrm.GroupCodeBtnChange(Sender: TObject);
begin
Grp1Code.Enabled := GroupCodeBtn.Checked;
Grp2Code.Enabled := GroupCodeBtn.Checked;
GrpCodeLabel1.Enabled := GroupCodeBtn.Checked;
GrpCodeLabel2.Enabled := GroupCodeBtn.Checked;
end;
procedure TTtestFrm.ComputeBtnClick(Sender: TObject);
var var
M1, M2, Dif, stddev1, stddev2, r12, stderr1, stderr2: double; M1, M2, Dif, stddev1, stddev2, r12, stderr1, stderr2: double;
tequal, tunequal, cov12, lowci, hici, F, Fp, df1, df2: double; tequal, tunequal, cov12, lowci, hici, F, Fp, df1, df2: double;
tprobability, value1, value2: double; tprobability, value1, value2: double;
variance1, variance2, pooled, sedif, df, ConfInt, tconfint: double; variance1, variance2, pooled, sedif, df, ConfInt, tconfint: double;
i, v1, v2, ncases1, ncases2, NoSelected: integer; i, nCases1, nCases2: integer;
group, min, max: integer; group, min, max: integer;
ColNoSelected: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil;
label1Str, label2Str: string; label1Str, label2Str: string;
msg: String;
C: TWinControl;
lReport: TStrings; lReport: TStrings;
begin begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
SetLength(ColNoSelected,NoVariables); SetLength(ColNoSelected,NoVariables);
ncases1 := 0; ncases1 := 0;
ncases2 := 0; ncases2 := 0;
@ -189,8 +147,6 @@ begin
M2 := 0.0; M2 := 0.0;
Dif := 0.0; Dif := 0.0;
r12 := 0.0; r12 := 0.0;
v1 := 0;
v2 := 0;
stddev1 := 0.0; stddev1 := 0.0;
stddev2 := 0.0; stddev2 := 0.0;
@ -198,30 +154,17 @@ begin
ConfInt := (100.0 - ConfInt) / 100.0; // one tail ConfInt := (100.0 - ConfInt) / 100.0; // one tail
if independent then if independent then
Var2.Text := Grp.Text; Var2Edit.Text := GrpEdit.Text;
// data read from grid // data read from grid
if griddata then if griddata then
begin begin
for i := 1 to NoVariables do SetLength(ColNoSelected, 2);
begin ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, Var1Edit.Text);
if Var1.Text = OS3MainFrm.DataGrid.Cells[i,0] then ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Var2Edit.Text);
begin
v1 := i;
ColNoSelected[0] := i;
label1Str := Var1.Text;
end;
if Var2.Text = OS3MainFrm.DataGrid.Cells[i,0] then
begin
v2 := i;
ColNoSelected[1] := i;
label2Str := Var2.Text;
end;
end; // next variable
ncases1 := 0; ncases1 := 0;
ncases2 := 0; ncases2 := 0;
NoSelected := 2;
M1 := 0.0; M1 := 0.0;
M2 := 0.0; M2 := 0.0;
variance1 := 0.0; variance1 := 0.0;
@ -231,10 +174,10 @@ begin
begin begin
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
ncases1 := ncases1 + 1; ncases1 := ncases1 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
M1 := M1 + value1; M1 := M1 + value1;
M2 := M2 + value2; M2 := M2 + value2;
variance1 := variance1 + value1 * value1; variance1 := variance1 + value1 * value1;
@ -260,27 +203,21 @@ begin
if independent then if independent then
begin begin
if GroupCodeBtn.Checked then if GroupCodeChk.Checked then
begin begin
min := StrToInt(Grp1Code.Text); min := StrToInt(Grp1CodeEdit.Text);
max := StrToInt(Grp2Code.Text); max := StrToInt(Grp2CodeEdit.Text);
{
response := InputBox('Group 1','Enter the code for group 1','1');
min := StrToInt(response);
response := InputBox('Group 2','Enter the code for group 2','2');
max := StrToInt(response);
}
end else end else
begin begin
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,1]))); min := MaxInt;
max := min; max := min;
end; end;
for i := 2 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]))); group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])));
if GroupCodeBtn.Checked = false then if not GroupCodeChk.Checked then
begin begin
if group < min then min := group; if group < min then min := group;
if group > max then max := group; if group > max then max := group;
@ -289,9 +226,9 @@ begin
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
group := round(value2); group := round(value2);
if group = min then if group = min then
begin begin
@ -340,7 +277,6 @@ begin
end; end;
end; end;
// Initialize output form // Initialize output form
lReport := TStringList.Create; lReport := TStringList.Create;
try try
@ -363,8 +299,8 @@ begin
sedif := sqrt(pooled); sedif := sqrt(pooled);
tequal := dif / sedif; tequal := dif / sedif;
df := ncases1 + ncases2 - 2; df := ncases1 + ncases2 - 2;
tprobability := probt(tequal,df); tprobability := ProbT(tequal, df);
if RadioGroup3.ItemIndex = 1 then tprobability := 0.5 * tprobability; if TailCombo.ItemIndex = 1 then tprobability := 0.5 * tprobability;
lReport.Add('Assuming equal variances, t = %.3f with probability = %.4f and %.0f degrees of freedom', [ lReport.Add('Assuming equal variances, t = %.3f with probability = %.4f and %.0f degrees of freedom', [
tequal, tprobability, df tequal, tprobability, df
]); ]);
@ -374,14 +310,15 @@ begin
lowci := dif - tconfint * sedif; lowci := dif - tconfint * sedif;
hici := dif + tconfint * sedif; hici := dif + tconfint * sedif;
lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]); lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]);
lReport.Add('');
// now for unequal variances // now for unequal variances
sedif := sqrt((variance1 / ncases1) + (variance2 / ncases2)); sedif := sqrt((variance1 / ncases1) + (variance2 / ncases2));
tunequal := dif / sedif; tunequal := dif / sedif;
df := sqr((variance1 / ncases1) + (variance2 / ncases2)); df := sqr((variance1 / ncases1) + (variance2 / ncases2));
df := df / (sqr(variance1 / ncases1) / (ncases1 - 1) + sqr(variance2 / ncases2) / (ncases2 - 1) ); df := df / (sqr(variance1 / ncases1) / (ncases1 - 1) + sqr(variance2 / ncases2) / (ncases2 - 1) );
tprobability := probt(tequal,df); tprobability := ProbT(tequal, df);
if RadioGroup3.ItemIndex = 1 then tprobability := 0.5 * tprobability; if TailCombo.ItemIndex = 1 then tprobability := 0.5 * tprobability;
lReport.Add('Assuming unequal variances, t = %.3f with probability = %.4f and %.0f degrees of freedom', [ lReport.Add('Assuming unequal variances, t = %.3f with probability = %.4f and %.0f degrees of freedom', [
tunequal, tprobability, df tunequal, tprobability, df
]); ]);
@ -391,6 +328,7 @@ begin
lowci := dif - tconfint * sedif; lowci := dif - tconfint * sedif;
hici := dif + tconfint * sedif; hici := dif + tconfint * sedif;
lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]); lReport.Add('Confidence interval = (%.2f ... %.2f)', [lowci, hici]);
lReport.Add('');
df1 := ncases1 - 1; df1 := ncases1 - 1;
df2 := ncases2 - 1; df2 := ncases2 - 1;
@ -437,7 +375,7 @@ begin
lReport.Add('t for test of equal variances = %.3f with probability = %.4f', [tequal, tprobability]); lReport.Add('t for test of equal variances = %.3f with probability = %.4f', [tequal, tprobability]);
end; end;
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
@ -445,96 +383,138 @@ begin
end; end;
end; end;
procedure TTtestFrm.ListBox1Click(Sender: TObject);
VAR index : integer;
begin
index := ListBox1.ItemIndex;
if not independent then
begin
if Var1.Text <> '' then Var2.Text := ListBox1.Items.Strings[index]
else Var1.Text := ListBox1.Items.Strings[index];
end;
if independent then
begin
if Var1.Text <> '' then Grp.Text := ListBox1.Items.Strings[index]
else Var1.Text := ListBox1.Items.Strings[index];
end;
end;
procedure TTtestFrm.RadioGroup1Click(Sender: TObject); procedure TTtestForm.DataEntryGroupClick(Sender: TObject);
VAR
index : integer;
begin
index := RadioGroup1.ItemIndex;
Notebook1.PageIndex := index;
if index = 0 then
begin
// Panel2.Visible := true;
// Panel1.Visible := false;
griddata := false;
end
else
begin
// Panel1.Visible := true;
// Panel2.Visible := false;
griddata := true;
if RadioGroup2.ItemIndex = 1 then
begin
SecdVarLabel.Visible := true;
Var2.Visible := true;
Grp.Visible := false;
GrpLabel.Visible := false;
end
else
begin
SecdVarLabel.Visible := false;
Var2.Visible := false;
Grp.Visible := true;
GrpLabel.Visible := true;
end;
end;
end;
procedure TTtestFrm.RadioGroup2Click(Sender: TObject);
var var
index: integer; index: integer;
begin begin
index := RadioGroup2.ItemIndex; index := DataEntryGroup.ItemIndex;
independent := (index = 0); Notebook.PageIndex := index;
Grp.Visible := independent; gridData := (index = 1);
GrpLabel.Visible := independent; if index = 1 then
GroupCodeBtn.Visible := independent; begin
GroupBox1.Visible := independent; if DepIndepGroup.ItemIndex = 1 then
SecdVarLabel.Visible := not independent; Var2Edit.Visible := true
Var2.Visible := not independent; else
{ Var2Edit.Visible := false;
if index = 0 then end;
begin
independent := true; Var2Label.Visible := Var2Edit.Visible;
CorBetweenLabel.Visible := false; Var2In.Visible := Var2Edit.Visible;
Cor12.Visible := false; Var2Out.Visible := Var2Edit.Visible;
Grp.Visible := true;
GrpLabel.Visible := true; GrpEdit.Visible := not Var2Edit.Visible;
GroupCodeBtn.Visible := true; GrpLabel.Visible := GrpEdit.Visible;
Groupbxo1.Visible := true; GrpIn.Visible := GrpEdit.Visible;
SecdVarLabel.Visible := false; GrpOut.Visible := GrpEdit.Visible;
Var2.Visible := false;
end
else
begin
independent := false;
CorBetweenLabel.Visible := true;
Cor12.Visible := true;
GrpLabel.Visible := false;
Grp.Visible := false;
GroupCodeBtn.Visible := false;
SecdVarLabel.Visible := true;
Var2.Visible := true;
end;
}
end; end;
function TTtestFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
procedure TTtestForm.DepIndepGroupClick(Sender: TObject);
begin
independent := (DepIndepGroup.ItemIndex = 0);
GrpEdit.Visible := independent;
GrpLabel.Visible := independent;
GrpIn.Visible := independent;
GrpOut.Visible := independent;
GroupCodeChk.Visible := independent;
GroupCodeGroup.Visible := independent;
Var2Label.Visible := not independent;
Var2Edit.Visible := not independent;
Var2In.Visible := not independent;
Var2Out.Visible := not independent;
Cor12.Visible := not independent;
Cor12Label.Visible := not independent;
end;
procedure TTtestForm.GroupCodeChkChange(Sender: TObject);
begin
Grp1CodeEdit.Enabled := GroupCodeChk.Checked;
Grp2CodeEdit.Enabled := GroupCodeChk.Checked;
GrpCodeLabel1.Enabled := GroupCodeChk.Checked;
GrpCodeLabel2.Enabled := GroupCodeChk.Checked;
end;
procedure TTtestForm.GrpInClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (GrpEdit.Text = '') then
begin
GrpEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TTtestForm.GrpOutClick(Sender: TObject);
begin
if GrpEdit.Text <> '' then
begin
VarList.Items.Add(GrpEdit.Text);
GrpEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTtestForm.Reset;
var
i: integer;
begin
inherited;
DataEntryGroup.ItemIndex := 0;
DepIndepGroup.ItemIndex := 0;
Notebook.PageIndex := DataEntryGroup.ItemIndex;
independent := true;
griddata := false;
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
Var1Edit.Clear;
Var2Edit.Clear;
Mean1.Clear;
Mean2.Clear;
SD1.Clear;
SD2.Clear;
N1.Clear;
N2.Clear;
Cor12.Clear;
GroupCodeChk.Checked := false;
GrpEdit.Clear;
Grp1CodeEdit.Clear;
Grp2CodeEdit.Clear;
DepIndepGroupClick(nil);
UpdateBtnStates;
end;
procedure TTtestForm.UpdateBtnStates;
begin
inherited UpdateBtnStates;
Var1In.Enabled := (Var1Edit.Text = '') and (VarList.ItemIndex > -1);
Var2In.Enabled := (Var2Edit.Text = '') and (VarList.ItemIndex > -1);
GrpIn.Enabled := (GrpEdit.Text = '') and (VarList.ItemIndex > -1);
Var1Out.Enabled := Var1Edit.Text <> '';
Var2Out.Enabled := Var2Edit.Text <> '';
GrpOut.Enabled := GrpEdit.Text <> '';
end;
function TTtestForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var var
n: Integer; n: Integer;
x: Double; x: Double;
@ -542,7 +522,7 @@ begin
Result := false; Result := false;
AControl := nil; AControl := nil;
AMsg := ''; AMsg := '';
if Notebook1.PageIndex = 0 then if Notebook.PageIndex = 0 then
begin begin
if (Mean1.Text = '') or not TryStrToFloat(Mean1.Text, x) then if (Mean1.Text = '') or not TryStrToFloat(Mean1.Text, x) then
begin begin
@ -581,35 +561,35 @@ begin
exit; exit;
end; end;
end else end else
if Notebook1.PageIndex = 1 then if Notebook.PageIndex = 1 then
begin begin
if (Var1.Text = '') then if (Var1Edit.Text = '') then
begin begin
AControl := Var1; AControl := Var1Edit;
AMsg := 'Variable 1 not specified.'; AMsg := 'Variable 1 not specified.';
exit; exit;
end; end;
if Var2.Visible and (Var2.Text = '') then if Var2Edit.Visible and (Var2Edit.Text = '') then
begin begin
AControl := Var2; AControl := Var2Edit;
AMsg := 'Variable 2 not specified.'; AMsg := 'Variable 2 not specified.';
exit; exit;
end; end;
if Grp.Visible and (Grp.Text = '') then if GrpEdit.Visible and (GrpEdit.Text = '') then
begin begin
AControl := Grp; AControl := GrpEdit;
AMsg := 'Group variable not specified.'; AMsg := 'Group variable not specified.';
exit; exit;
end; end;
if Grp1Code.Visible and ((Grp1Code.Text = '') or not TryStrToInt(Grp1Code.Text, n))then if Grp1CodeEdit.Visible and ((Grp1CodeEdit.Text = '') or not TryStrToInt(Grp1CodeEdit.Text, n))then
begin begin
AControl := Grp1Code; AControl := Grp1CodeEdit;
AMsg := 'Code for group 1 missing.'; AMsg := 'Code for group 1 missing.';
exit; exit;
end; end;
if Grp2Code.Visible and ((Grp2Code.Text = '') or not TryStrToInt(Grp2Code.Text, n))then if Grp2CodeEdit.Visible and ((Grp2CodeEdit.Text = '') or not TryStrToInt(Grp2CodeEdit.Text, n))then
begin begin
AControl := Grp2Code; AControl := Grp2CodeEdit;
AMsg := 'Code for group 2 missing.'; AMsg := 'Code for group 2 missing.';
exit; exit;
end; end;
@ -617,8 +597,95 @@ begin
Result := true; Result := true;
end; end;
initialization
{$I ttestunit.lrs} procedure TTtestForm.Var1InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var1Edit.Text = '') then
begin
Var1Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TTtestForm.Var1OutClick(Sender: TObject);
begin
if Var1Edit.Text <> '' then
begin
VarList.Items.Add(Var1Edit.Text);
Var1Edit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTtestForm.Var2InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var2Edit.Text = '') then
begin
Var2Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TTtestForm.Var2OutClick(Sender: TObject);
begin
if Var2Edit.Text <> '' then
begin
VarList.Items.Add(Var2Edit.Text);
Var2Edit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTtestForm.VarListDblClick(Sender: TObject);
var
index: integer;
s: String;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
s := VarList.Items[index];
if Var1Edit.Text = '' then
begin
Var1Edit.Text := s;
VarList.Items.Delete(index);
end else
if independent then
begin
if GrpEdit.Text = '' then
begin
GrpEdit.Text := s;
VarList.Items.Delete(index);
end;
end else
begin
if Var2Edit.Text = '' then
begin
Var2Edit.Text := s;
VarList.Items.Delete(index);
end;
end;
UpdateBtnStates;
end;
end;
procedure TTtestForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
end. end.

View File

@ -133,7 +133,7 @@ inherited TwoCorrsForm: TTwoCorrsForm
Height = 292 Height = 292
Top = 80 Top = 80
Width = 392 Width = 392
PageIndex = 2 PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8

View File

@ -176,6 +176,7 @@ begin
GrpIn.Visible := GroupVarEdit.Visible; GrpIn.Visible := GroupVarEdit.Visible;
GrpOut.Visible := GroupVarEdit.Visible; GrpOut.Visible := GroupVarEdit.Visible;
UpdateBtnStates;
end; end;

View File

@ -465,6 +465,8 @@ begin
IndSize2.Clear; IndSize2.Clear;
Notebook.PageIndex := 1; Notebook.PageIndex := 1;
UpdateBtnStates;
end; end;

View File

@ -883,22 +883,6 @@ begin
SpBrFrm.ShowModal; SpBrFrm.ShowModal;
end; end;
// Menu "Analysis" > "Comparisons" > "ABC mnuAnalysisComp_Anova with B Nested in A"
procedure TOS3MainFrm.mnuAnalysisComp_NestedABCClick(Sender: TObject);
begin
if ABCNestedForm = nil then
Application.CreateForm(TABCNestedForm, ABCNestedForm);
ABCNestedForm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "2 or 3 Way mnuAnalysisComp_Anova with One Case Per Cell"
procedure TOS3MainFrm.mnuAnalysisComp_OneCaseAnovaClick(Sender: TObject);
begin
if OneCaseAnovaForm = nil then
Application.CreateForm(TOneCaseAnovaForm, OneCaseAnovaForm);
OneCaseAnovaForm.ShowModal;
end;
// Menu "Analysis" > "One sample tests" // Menu "Analysis" > "One sample tests"
procedure TOS3MainFrm.mnuAnalysisOneSampleTestsClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisOneSampleTestsClick(Sender: TObject);
begin begin
@ -908,30 +892,6 @@ begin
end; end;
// Menu "Analysis" > "Comparisons" > "Difference beween Proportions"
procedure TOS3MainFrm.mnuAnalysisComp_PropDiffClick(Sender: TObject);
begin
if TwoPropForm = nil then
Application.CreateForm(TTwoPropForm, TwoPropForm);
TwoPropForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "t-tests"
procedure TOS3MainFrm.mnuAnalysisComp_tTestsClick(Sender: TObject);
begin
if TTestFrm = nil then
Application.CreateForm(TTTestFrm, TTestFrm);
TTestFrm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "Within Subjects mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_WithinAnovaClick(Sender: TObject);
begin
if WithinANOVAFrm = nil then
Application.CreateForm(TWithinANOVAFrm, WithinANOVAFrm);
WithinAnovaFrm.ShowModal;
end;
{ {
@ -1036,38 +996,6 @@ begin
if DataGrid.Cells[PrevCol,PrevRow] <> '' then FormatCell(PrevCol,PrevRow); if DataGrid.Cells[PrevCol,PrevRow] <> '' then FormatCell(PrevCol,PrevRow);
end; end;
// Menu "Analysis" > "Comparisons" > "1,2 or 3 Way ANOVAs"
procedure TOS3MainFrm.mnuAnalysisComp_AnovaClick(Sender: TObject);
begin
if BlksAnovaFrm = nil then
Application.CreateForm(TBlksAnovaFrm, BlksAnovaFrm);
BlksAnovaFrm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "A x B x S mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_ABSAnovaClick(Sender: TObject);
begin
if ABRAnovaForm = nil then
Application.CreateForm(TABRAnovaForm, ABRAnovaForm);
ABRAnovaForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "mnuAnalysisComp_Ancova by Regression"
procedure TOS3MainFrm.mnuAnalysisComp_AncovaClick(Sender: TObject);
begin
if ANCOVAfrm = nil then
Application.CreateForm(TANCOVAfrm, ANCOVAfrm);
ANCOVAFRM.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "A x S mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_AxSAnovaClick(Sender: TObject);
begin
if AxSAnovaFrm = nil then
Application.CreateForm(TAxSAnovaFrm, AxSAnovaFrm);
AxSAnovaFrm.ShowModal;
end;
// Menu "Analysis" > "Multivariate" > "Bartlett Test of Sphericity" // Menu "Analysis" > "Multivariate" > "Bartlett Test of Sphericity"
procedure TOS3MainFrm.mnuAnalysisMulti_BartlettClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisMulti_BartlettClick(Sender: TObject);
begin begin
@ -1076,22 +1004,6 @@ begin
BartlettTestForm.ShowModal; BartlettTestForm.ShowModal;
end; end;
// Menu "Analysis" > "Comparisons" > "B Nested in A mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_BinAClick(Sender: TObject);
begin
if BNestedAForm = nil then
Application.CreateForm(TBNestedAForm, BNestedAForm);
BNestedAForm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "Difference Between Correlations"
procedure TOS3MainFrm.mnuAnalysisComp_CorrDiffClick(Sender: TObject);
begin
if TwoCorrsForm = nil then
Application.CreateForm(TTwoCorrsForm, TwoCorrsForm);
TwoCorrsForm.Show;
end;
// Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis" // Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"
procedure TOS3MainFrm.mnuAnalysisMulti_CorrespondenceClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisMulti_CorrespondenceClick(Sender: TObject);
begin begin
@ -1693,14 +1605,6 @@ begin
CompareDistFrm.ShowModal; CompareDistFrm.ShowModal;
end; end;
// Menu "Analysis" > "Comparisons" > "Latin and Greco-Latin Squares"
procedure TOS3MainFrm.mnuAnalysisComp_LatinSquaresClick(Sender: TObject);
begin
if LatinSqrsFrm = nil then
Application.CreateForm(TLatinSqrsFrm, LatinSqrsFrm);
LatinSqrsFrm.ShowModal;
end;
procedure TOS3MainFrm.MatManMnuClick(Sender: TObject); procedure TOS3MainFrm.MatManMnuClick(Sender: TObject);
begin begin
if MatManFrm = nil then if MatManFrm = nil then
@ -1921,6 +1825,105 @@ end;
{ Comparisons commands }
// Menu "Analysis" > "Comparisons" > "1,2 or 3 Way ANOVAs"
procedure TOS3MainFrm.mnuAnalysisComp_AnovaClick(Sender: TObject);
begin
if BlksAnovaFrm = nil then
Application.CreateForm(TBlksAnovaFrm, BlksAnovaFrm);
BlksAnovaFrm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "A x B x S Anova"
procedure TOS3MainFrm.mnuAnalysisComp_ABSAnovaClick(Sender: TObject);
begin
if ABRAnovaForm = nil then
Application.CreateForm(TABRAnovaForm, ABRAnovaForm);
ABRAnovaForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "Ancova by Regression"
procedure TOS3MainFrm.mnuAnalysisComp_AncovaClick(Sender: TObject);
begin
if ANCOVAfrm = nil then
Application.CreateForm(TANCOVAfrm, ANCOVAfrm);
ANCOVAFRM.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "A x S Anova"
procedure TOS3MainFrm.mnuAnalysisComp_AxSAnovaClick(Sender: TObject);
begin
if AxSAnovaFrm = nil then
Application.CreateForm(TAxSAnovaFrm, AxSAnovaFrm);
AxSAnovaFrm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "B Nested in A mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_BinAClick(Sender: TObject);
begin
if BNestedAForm = nil then
Application.CreateForm(TBNestedAForm, BNestedAForm);
BNestedAForm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "Difference Between Correlations"
procedure TOS3MainFrm.mnuAnalysisComp_CorrDiffClick(Sender: TObject);
begin
if TwoCorrsForm = nil then
Application.CreateForm(TTwoCorrsForm, TwoCorrsForm);
TwoCorrsForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "Latin and Greco-Latin Squares"
procedure TOS3MainFrm.mnuAnalysisComp_LatinSquaresClick(Sender: TObject);
begin
if LatinSqrsFrm = nil then
Application.CreateForm(TLatinSqrsFrm, LatinSqrsFrm);
LatinSqrsFrm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "ABC mnuAnalysisComp_Anova with B Nested in A"
procedure TOS3MainFrm.mnuAnalysisComp_NestedABCClick(Sender: TObject);
begin
if ABCNestedForm = nil then
Application.CreateForm(TABCNestedForm, ABCNestedForm);
ABCNestedForm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "2 or 3 Way mnuAnalysisComp_Anova with One Case Per Cell"
procedure TOS3MainFrm.mnuAnalysisComp_OneCaseAnovaClick(Sender: TObject);
begin
if OneCaseAnovaForm = nil then
Application.CreateForm(TOneCaseAnovaForm, OneCaseAnovaForm);
OneCaseAnovaForm.ShowModal;
end;
// Menu "Analysis" > "Comparisons" > "Difference beween Proportions"
procedure TOS3MainFrm.mnuAnalysisComp_PropDiffClick(Sender: TObject);
begin
if TwoPropForm = nil then
Application.CreateForm(TTwoPropForm, TwoPropForm);
TwoPropForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "t-tests"
procedure TOS3MainFrm.mnuAnalysisComp_tTestsClick(Sender: TObject);
begin
if TTestForm = nil then
Application.CreateForm(TTTestForm, TTestForm);
TTestForm.Show;
end;
// Menu "Analysis" > "Comparisons" > "Within Subjects mnuAnalysisComp_Anova"
procedure TOS3MainFrm.mnuAnalysisComp_WithinAnovaClick(Sender: TObject);
begin
if WithinANOVAFrm = nil then
Application.CreateForm(TWithinANOVAFrm, WithinANOVAFrm);
WithinAnovaFrm.ShowModal;
end;
{ Descriptive statistics commands } { Descriptive statistics commands }
// Menu "Analysis" > "Descriptive" > "Box Plot" // Menu "Analysis" > "Descriptive" > "Box Plot"