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

@ -70,3 +70,4 @@ correlation, means, standard deviations and confidence interval for each correla
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.
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>
<Filename Value="forms\analysis\comparisons\ttestunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="TtestFrm"/>
<ComponentName Value="TtestForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="TTestUnit"/>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -883,22 +883,6 @@ begin
SpBrFrm.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" > "One sample tests"
procedure TOS3MainFrm.mnuAnalysisOneSampleTestsClick(Sender: TObject);
begin
@ -908,30 +892,6 @@ begin
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);
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"
procedure TOS3MainFrm.mnuAnalysisMulti_BartlettClick(Sender: TObject);
begin
@ -1076,22 +1004,6 @@ begin
BartlettTestForm.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" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"
procedure TOS3MainFrm.mnuAnalysisMulti_CorrespondenceClick(Sender: TObject);
begin
@ -1693,14 +1605,6 @@ begin
CompareDistFrm.ShowModal;
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);
begin
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 }
// Menu "Analysis" > "Descriptive" > "Box Plot"