You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7887 8e941d3f-bd1b-0410-a28a-d453659cc2b4
659 lines
24 KiB
ObjectPascal
659 lines
24 KiB
ObjectPascal
unit TwoCorrsUnit;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
|
ExtCtrls, StdCtrls, MainUnit, Globals, FunctionsLib, OutPutUnit, DataProcs,
|
|
contexthelpunit;
|
|
|
|
type
|
|
|
|
{ TTwoCorrsFrm }
|
|
|
|
TTwoCorrsFrm = class(TForm)
|
|
HelpBtn: TButton;
|
|
ResetBtn: TButton;
|
|
CancelBtn: TButton;
|
|
ComputeBtn: TButton;
|
|
ReturnBtn: TButton;
|
|
CInterval: TEdit;
|
|
Label14: TLabel;
|
|
Xvar: TEdit;
|
|
Yvar: TEdit;
|
|
Zvar: TEdit;
|
|
GroupVar: TEdit;
|
|
xlabel: TLabel;
|
|
ylabel: TLabel;
|
|
zlabel: TLabel;
|
|
GroupLabel: TLabel;
|
|
SelVarLabel: TLabel;
|
|
VarList: TListBox;
|
|
Panel2: TPanel;
|
|
rxy1: TEdit;
|
|
Size1: TEdit;
|
|
rxy2: TEdit;
|
|
Size2: TEdit;
|
|
firstcorlabel: TLabel;
|
|
size1label: TLabel;
|
|
SecdCorLabel: TLabel;
|
|
Size2Label: TLabel;
|
|
rxy: TEdit;
|
|
rxz: TEdit;
|
|
ryz: TEdit;
|
|
SampSize: TEdit;
|
|
corxylabel: TLabel;
|
|
corxzlabel: TLabel;
|
|
coryzlabel: TLabel;
|
|
sampsizelabel: TLabel;
|
|
Panel1: TPanel;
|
|
RadioGroup1: TRadioGroup;
|
|
RadioGroup2: TRadioGroup;
|
|
procedure ComputeBtnClick(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure HelpBtnClick(Sender: TObject);
|
|
procedure RadioGroup1Click(Sender: TObject);
|
|
procedure RadioGroup2Click(Sender: TObject);
|
|
procedure ResetBtnClick(Sender: TObject);
|
|
procedure VarListClick(Sender: TObject);
|
|
private
|
|
{ private declarations }
|
|
independent : boolean;
|
|
griddata : boolean;
|
|
|
|
public
|
|
{ public declarations }
|
|
end;
|
|
|
|
var
|
|
TwoCorrsFrm: TTwoCorrsFrm;
|
|
|
|
implementation
|
|
|
|
{ TTwoCorrsFrm }
|
|
|
|
procedure TTwoCorrsFrm.ResetBtnClick(Sender: TObject);
|
|
VAR i : integer;
|
|
begin
|
|
RadioGroup1.ItemIndex := 0;
|
|
RadioGroup2.ItemIndex := 0;
|
|
Panel1.Visible := true;
|
|
Panel2.Visible := false;
|
|
VarList.Clear;
|
|
Xvar.Text := '';
|
|
Yvar.Text := '';
|
|
Zvar.Text := '';
|
|
Xvar.Visible := false;
|
|
Yvar.Visible := false;
|
|
Zvar.Visible := false;
|
|
corxylabel.Visible := false;
|
|
corxzlabel.Visible := false;
|
|
coryzlabel.Visible := false;
|
|
GroupVar.Text := '';
|
|
GroupVar.Visible := false;
|
|
sampsizelabel.Visible := false;
|
|
rxy.Text := '';
|
|
rxz.Text := '';
|
|
ryz.Text := '';
|
|
SampSize.Text := '';
|
|
rxy1.Text := '';
|
|
rxy2.Text := '';
|
|
Size1.Text := '';
|
|
Size2.Text := '';
|
|
firstcorlabel.Visible := true;
|
|
size1label.Visible := true;
|
|
SecdCorLabel.Visible := true;
|
|
Size2Label.Visible := true;
|
|
rxy.Visible := false;
|
|
rxz.Visible := false;
|
|
ryz.Visible := false;
|
|
rxy1.Visible := true;
|
|
rxy2.Visible := true;
|
|
Size1.Visible := true;
|
|
Size2.Visible := true;
|
|
SelVarLabel.Visible := true;
|
|
xlabel.Visible := true;
|
|
ylabel.Visible := true;
|
|
zlabel.Visible := false;
|
|
Zvar.Visible := false;
|
|
GroupLabel.Visible := true;
|
|
independent := true;
|
|
griddata := false;
|
|
CInterval.Text := '95.0';
|
|
for i := 1 to NoVariables do
|
|
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
|
end;
|
|
|
|
procedure TTwoCorrsFrm.VarListClick(Sender: TObject);
|
|
VAR index : integer;
|
|
begin
|
|
index := VarList.ItemIndex;
|
|
if Xvar.Text = '' then
|
|
begin
|
|
Xvar.Text := VarList.Items.Strings[index];
|
|
exit;
|
|
end;
|
|
if Yvar.Text = '' then
|
|
begin
|
|
Yvar.Text := VarList.Items.Strings[index];
|
|
exit;
|
|
end;
|
|
if not independent then
|
|
begin
|
|
if Zvar.Text = '' then
|
|
begin
|
|
Zvar.Text := VarList.Items.Strings[index];
|
|
exit;
|
|
end;
|
|
end;
|
|
if independent then
|
|
begin
|
|
if GroupVar.Text = '' then
|
|
begin
|
|
GroupVar.Text := VarList.Items.Strings[index];
|
|
exit;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TTwoCorrsFrm.FormShow(Sender: TObject);
|
|
begin
|
|
ResetBtnClick(self);
|
|
end;
|
|
|
|
procedure TTwoCorrsFrm.HelpBtnClick(Sender: TObject);
|
|
begin
|
|
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
|
end;
|
|
|
|
procedure TTwoCorrsFrm.ComputeBtnClick(Sender: TObject);
|
|
var
|
|
Corxy, Corxz, Coryz, Cor1, Cor2, alpha, tvalue, df1, df2 : double;
|
|
CorDif, zOne, zTwo, zDif, StdErr, zValue, zprobability : double;
|
|
UCL, LCL, ztest, ConfLevel, tprobability, ttest : double;
|
|
mean1, mean2, mean3, variance1, variance2, variance3 : double;
|
|
stddev1, stddev2, stddev3, value1, value2, value3 : double;
|
|
meanx1, meanx2, meany1, meany2, varx1, varx2, vary1, vary2 : double;
|
|
sdx1, sdx2, sdy1, sdy2, value : double;
|
|
SSize1, SSize2, SSize, v1, v2, v3, grp, ncases, NoSelected: integer;
|
|
min, max, grpval, ncases1, ncases2, i : integer;
|
|
cellstring, outline : string;
|
|
ColNoSelected : IntDyneVec;
|
|
|
|
begin
|
|
SetLength(ColNoSelected,NoVariables);
|
|
Corxy := 0.0;
|
|
Corxz := 0.0;
|
|
Coryz := 0.0;
|
|
Cor1 := 0.0;
|
|
Cor2 := 0.0;
|
|
mean1 := 0.0;
|
|
mean2 := 0.0;
|
|
mean3 := 0.0;
|
|
variance1 := 0.0;
|
|
variance2 := 0.0;
|
|
variance3 := 0.0;
|
|
meanx1 := 0.0;
|
|
meanx2 := 0.0;
|
|
meany1 := 0.0;
|
|
|
|
if not griddata then // use data on the form
|
|
begin
|
|
if independent then // read data from form and obtain results
|
|
begin
|
|
Cor1 := StrToFloat(rxy1.Text);
|
|
Cor2 := StrToFloat(rxy2.Text);
|
|
SSize1 := StrToInt(Size1.Text);
|
|
SSize2 := StrToInt(Size2.Text);
|
|
ConfLevel := StrToFloat(CInterval.Text) / 100.0;
|
|
CorDif := Cor1 - Cor2;
|
|
zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1));
|
|
zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2));
|
|
zDif := zOne - zTwo;
|
|
StdErr := sqrt((1.0 / (SSize1 - 3.0)) + (1.0 / (SSize2 -3.0)));
|
|
zValue := zDif / StdErr;
|
|
alpha := (1.0 - ConfLevel) / 2.0;
|
|
zTest := inversez(1.0 - alpha);
|
|
zprobability := 1.0 - probz(zValue);
|
|
UCL := zDif + StdErr * zTest;
|
|
LCL := zDif - StdErr * zTest;
|
|
UCL := (exp(2.0 * UCL) - 1.0) / (exp(2.0 * UCL) + 1.0);
|
|
LCL := (exp(2.0 * LCL) - 1.0) / (exp(2.0 * LCL) + 1.0);
|
|
end;
|
|
if not independent then // obtain data from form and obtain results
|
|
begin
|
|
Corxy := StrToFloat(rxy.Text);
|
|
Corxz := StrToFloat(rxz.Text);
|
|
Coryz := StrToFloat(ryz.Text);
|
|
SSize := StrToInt(SampSize.Text);
|
|
ConfLevel := StrToFloat(CInterval.Text) / 100.0;
|
|
CorDif := Corxy - Corxz;
|
|
alpha := (1.0 - ConfLevel) / 2.0;
|
|
tvalue := (CorDif * sqrt((SSize - 3.0) * (1.0 + Coryz))) /
|
|
sqrt(2.0 * (1.0 - (Corxy * Corxy) - (Corxz * Corxz) -
|
|
(Coryz * Coryz) + (2.0 * Corxy * Corxz * Coryz)));
|
|
df1 := 1.0;
|
|
df2 := SSize - 3.0;
|
|
tprobability := probt(tvalue,df2);
|
|
ttest := inverset(1.0 - alpha, df2);
|
|
end;
|
|
end;
|
|
|
|
if griddata then
|
|
begin
|
|
v1 := 1;
|
|
v2 := 1;
|
|
grp := 1;
|
|
if independent then // read grid data for independent r's
|
|
begin
|
|
for i := 1 to NoVariables do
|
|
begin
|
|
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
|
|
if cellstring = Xvar.Text then v1 := i;
|
|
if cellstring = Yvar.Text then v2 := i;
|
|
if cellstring = GroupVar.Text then grp := i;
|
|
end;
|
|
ColNoSelected[0] := v1;
|
|
ColNoSelected[1] := v2;
|
|
ColNoSelected[2] := grp;
|
|
NoSelected := 3;
|
|
meanx1 := 0.0;
|
|
meany1 := 0.0;
|
|
varx1 := 0.0;
|
|
vary1 := 0.0;
|
|
meanx2 := 0.0;
|
|
meany2 := 0.0;
|
|
varx2 := 0.0;
|
|
vary2 := 0.0;
|
|
Cor1 := 0.0;
|
|
Cor2 := 0.0;
|
|
ncases1 := 0;
|
|
ncases2 := 0;
|
|
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,1])));
|
|
max := min;
|
|
for i := 2 to NoCases do
|
|
begin
|
|
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
|
|
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i])));
|
|
if grpval > max then max := grpval;
|
|
if grpval < min then min := grpval;
|
|
end;
|
|
for i := 1 to NoCases do
|
|
begin
|
|
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
|
|
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i])));
|
|
if grpval = min then
|
|
begin
|
|
ncases1 := ncases1 + 1;
|
|
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
|
|
meanx1 := meanx1 + value1;
|
|
varx1 := varx1 + (value1 * value1);
|
|
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
|
|
meany1 := meany1 + value2;
|
|
vary1 := vary1 + (value2 * value2);
|
|
Cor1 := Cor1 + (value1 * value2);
|
|
end;
|
|
if grpval = max then
|
|
begin
|
|
ncases2 := ncases2 + 1;
|
|
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
|
|
meanx2 := meanx2 + value1;
|
|
varx2 := varx2 + (value1 * value1);
|
|
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
|
|
meany2 := meany2 + value2;
|
|
vary2 := vary2 + (value2 * value2);
|
|
Cor2 := Cor2 + (value1 * value2);
|
|
end;
|
|
end; // next case
|
|
varx1 := varx1 - (meanx1 * meanx1) / ncases1;
|
|
varx1 := varx1 / (ncases1 - 1.0);
|
|
varx2 := varx2 - (meanx2 * meanx2) / ncases2;
|
|
varx2 := varx2 / (ncases2 - 1.0);
|
|
vary1 := vary1 - (meany1 * meany1) / ncases1;
|
|
vary1 := vary1 / (ncases1 - 1.0);
|
|
vary2 := vary2 - (meany2 * meany2) / ncases2;
|
|
vary2 := vary2 / (ncases2 - 1.0);
|
|
Cor1 := Cor1 - (meanx1 * meany1) / ncases1;
|
|
Cor1 := Cor1 / (ncases1 - 1.0);
|
|
Cor2 := Cor2 - (meanx2 * meany2) / ncases2;
|
|
Cor2 := Cor2 / (ncases2 - 1.0);
|
|
sdx1 := sqrt(varx1);
|
|
sdx2 := sqrt(varx2);
|
|
sdy1 := sqrt(vary1);
|
|
sdy2 := sqrt(vary2);
|
|
Cor1 := Cor1 / (sdx1 * sdy1);
|
|
Cor2 := Cor2 / (sdx2 * sdy2);
|
|
meanx1 := meanx1 / ncases1;
|
|
meany1 := meany1 / ncases1;
|
|
meanx2 := meanx2 / ncases2;
|
|
meany2 := meany2 / ncases2;
|
|
SSize1 := ncases1;
|
|
SSize2 := ncases2;
|
|
ConfLevel := StrToFloat(CInterval.Text) / 100.0;
|
|
CorDif := Cor1 - Cor2;
|
|
zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1));
|
|
zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2));
|
|
zDif := zOne - zTwo;
|
|
StdErr := sqrt((1.0 / (SSize1 - 3.0)) + (1.0 / (SSize2 -3.0)));
|
|
zValue := zDif / StdErr;
|
|
alpha := (1.0 - ConfLevel) / 2.0;
|
|
zTest := inversez(1.0 - alpha);
|
|
zprobability := 1.0 - probz(zValue);
|
|
UCL := zDif + StdErr * zTest;
|
|
LCL := zDif - StdErr * zTest;
|
|
UCL := (exp(2.0 * UCL) - 1.0) / (exp(2.0 * UCL) + 1.0);
|
|
LCL := (exp(2.0 * LCL) - 1.0) / (exp(2.0 * LCL) + 1.0);
|
|
end;
|
|
if not independent then // read grid data for dependent r's
|
|
begin
|
|
mean1 := 0.0;
|
|
mean2 := 0.0;
|
|
mean3 := 0.0;
|
|
variance1 := 0.0;
|
|
variance2 := 0.0;
|
|
variance3 := 0.0;
|
|
Corxy := 0.0;
|
|
Corxz := 0.0;
|
|
Coryz := 0.0;
|
|
ncases := 0;
|
|
for i := 1 to NoVariables do
|
|
begin
|
|
cellstring := OS3MainFrm.DataGrid.Cells[i,0];
|
|
if cellstring = Xvar.Text then v1 := i;
|
|
if cellstring = Yvar.Text then v2 := i;
|
|
if cellstring = ZVar.Text then v3 := i;
|
|
end;
|
|
ColNoSelected[0] := v1;
|
|
ColNoSelected[1] := v2;
|
|
ColNoSelected[2] := v3;
|
|
NoSelected := 3;
|
|
for i := 1 to NoCases do
|
|
begin
|
|
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
|
|
ncases := ncases + 1;
|
|
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
|
|
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
|
|
value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v3,i]));
|
|
mean1 := mean1 + value1;
|
|
mean2 := mean2 + value2;
|
|
mean3 := mean3 + value3;
|
|
variance1 := variance1 + (value1 * value1);
|
|
variance2 := variance2 + (value2 * value2);
|
|
variance3 := variance3 + (value3 * value3);
|
|
Corxy := Corxy + (value1 * value2);
|
|
Corxz := Corxz + (value1 * value3);
|
|
Coryz := Coryz + (value2 * value3);
|
|
end;
|
|
variance1 := variance1 - (mean1 * mean1) / ncases;
|
|
variance1 := variance1 / (ncases - 1.0);
|
|
stddev1 := sqrt(variance1);
|
|
variance2 := variance2 - (mean2 * mean2) / ncases;
|
|
variance2 := variance2 / (ncases - 1.0);
|
|
stddev2 := sqrt(variance2);
|
|
variance3 := variance3 - (mean3 * mean3) / ncases;
|
|
variance3 := variance3 / (ncases - 1.0);
|
|
stddev3 := sqrt(variance3);
|
|
Corxy := Corxy - (mean1 * mean2) / ncases;
|
|
Corxy := Corxy / (ncases - 1.0);
|
|
Corxy := Corxy / (stddev1 * stddev2);
|
|
Corxz := Corxz - (mean1 * mean3) / ncases;
|
|
Corxz := Corxz / (ncases - 1.0);
|
|
Corxz := Corxz / (stddev1 * stddev3);
|
|
Coryz := Coryz - (mean2 * mean3) / ncases;
|
|
Coryz := Coryz / (ncases - 1.0);
|
|
Coryz := Coryz / (stddev2 * stddev3);
|
|
mean1 := mean1 / ncases;
|
|
mean2 := mean2 / ncases;
|
|
mean3 := mean3 / ncases;
|
|
SSize := ncases;
|
|
ConfLevel := StrToFloat(CInterval.Text) / 100.0;
|
|
CorDif := Corxy - Corxz;
|
|
alpha := (1.0 - ConfLevel) / 2.0;
|
|
tvalue := (CorDif * sqrt((SSize - 3.0) * (1.0 + Coryz))) /
|
|
sqrt(2.0 * (1.0 - (Corxy * Corxy) - (Corxz * Corxz) -
|
|
(Coryz * Coryz) + (2.0 * Corxy * Corxz * Coryz)));
|
|
df1 := 1.0;
|
|
df2 := SSize - 3.0;
|
|
tprobability := probt(tvalue,df2);
|
|
ttest := inverset(1.0 - alpha, df2);
|
|
end;
|
|
end;
|
|
|
|
// Initialize output form
|
|
OutPutFrm.RichEdit.Clear;
|
|
OutPutFrm.RichEdit.Lines.Add('COMPARISON OF TWO CORRELATIONS');
|
|
OutPutFrm.RichEdit.Lines.Add('');
|
|
// OutPutFrm.RichEdit.ParaGraph.Alignment := taLeftJustify;
|
|
if independent then
|
|
begin
|
|
outline := format('Correlation one = %6.3f',[Cor1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Sample size one = %d',[SSize1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Correlation two = %6.3f',[Cor2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline :=format('Sample size two = %d',[SSize2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Difference between correlations = %6.3f',[CorDif]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Confidence level selected = %s',[CInterval.Text]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('z for Correlation One = %6.3f',[zOne]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('z for Correlation Two = %6.3f',[zTwo]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('z difference = %6.3f',[zDif]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Standard error of difference = %6.3f',[StdErr]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('z test statistic = %6.3f',[zValue]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Probability > |z| = %6.3f',[zprobability]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('z Required for significance = %6.3f',[zTest]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
OutPutFrm.RichEdit.Lines.Add('Note: above is a two-tailed test.');
|
|
outline := format('Confidence Limits = (%6.3f,%6.3f)',[LCL,UCL]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
if griddata then
|
|
begin
|
|
outline := format('Mean X for group 1 = %9.3f',[meanx1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Mean X for group 2 = %9.3f',[meanx2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Std.Dev. X for group 1 = %9.3f',[sdx1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Std.Dev. X for group 2 = %9.3f',[sdx2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Mean y for group 1 = %9.3f',[meany1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Mean Y for group 2 = %9.3f',[meany2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Std.Dev. Y for group 1 = %9.3f',[sdy1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Std.Dev. Y for group 2 = %9.3f',[sdy2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
end;
|
|
end;
|
|
|
|
if not independent then
|
|
begin
|
|
outline := format('Correlation x with y = %6.3f',[Corxy]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Correlation x with z = %6.3f',[Corxz]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Correlation y with z = %6.3f',[Coryz]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Sample size = %d',[SSize]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Confidence Level Selected = %s',[CInterval.Text]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Difference r(x,y) - r(x,z) = %6.3f',[CorDif]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline :=format('t test statistic = %6.3f',[tvalue]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('Probability > |t| = %6.3f',[tprobability]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format('t value for significance = %6.3f',[ttest]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
if griddata then
|
|
begin
|
|
OutPutFrm.RichEdit.Lines.Add('Variable Mean Variance Std.Dev.');
|
|
outline := format(' X %9.3f %9.3f %9.3f',
|
|
[mean1, variance1, stddev1]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format(' Y %9.3f %9.3f %9.3f',
|
|
[mean2, variance2, stddev2]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
outline := format(' Z %9.3f %9.3f %9.3f',
|
|
[mean3, variance3, stddev3]);
|
|
OutPutFrm.RichEdit.Lines.Add(outline);
|
|
end;
|
|
end;
|
|
OutPutFrm.ShowModal;
|
|
ColNoSelected := nil;
|
|
end;
|
|
|
|
procedure TTwoCorrsFrm.RadioGroup1Click(Sender: TObject);
|
|
VAR index : integer;
|
|
begin
|
|
index := RadioGroup1.ItemIndex;
|
|
if index = 0 then
|
|
begin
|
|
Panel2.Visible := false;
|
|
Panel1.Visible := true;
|
|
griddata := false;
|
|
yvar.Visible := false;
|
|
xvar.Visible := false;
|
|
groupvar.Visible := false;
|
|
rxy1.Visible := true;
|
|
rxy2.Visible := true;
|
|
size1.Visible := true;
|
|
size2.Visible := true;
|
|
end
|
|
else
|
|
begin
|
|
Panel1.Visible := false;
|
|
Panel2.Visible := true;
|
|
xvar.Visible := true;
|
|
yvar.Visible := true;
|
|
groupvar.Visible := true;
|
|
griddata := true;
|
|
rxy1.Visible := false;
|
|
rxy2.Visible := false;
|
|
size1.Visible := false;
|
|
size2.Visible := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TTwoCorrsFrm.RadioGroup2Click(Sender: TObject);
|
|
VAR index1, index2 : integer;
|
|
begin
|
|
index2 := RadioGroup2.ItemIndex;
|
|
index1 := RadioGroup1.ItemIndex;
|
|
if ((index2 = 0) and (index1 = 0)) then // form input with independent corrs
|
|
begin
|
|
independent := true;
|
|
panel2.Visible := false;
|
|
panel1.Visible := true;
|
|
// GroupVar.Visible := true;
|
|
// GroupLabel.Visible := true;
|
|
corxylabel.Visible := false;
|
|
corxzlabel.Visible := false;
|
|
coryzlabel.Visible := false;
|
|
// Xvar.Visible := true;
|
|
// Yvar.Visible := true;
|
|
// Zvar.Visible := false;
|
|
// SelVarLabel.Visible := true;
|
|
// xlabel.Visible := true;
|
|
// ylabel.Visible := true;
|
|
// Zlabel.Visible := false;
|
|
rxy1.Visible := true;
|
|
rxy2.Visible := true;
|
|
Size1.Visible := true;
|
|
Size2.Visible := true;
|
|
firstcorlabel.Visible := true;
|
|
size1label.Visible := true;
|
|
SecdCorLabel.Visible := true;
|
|
Size2Label.Visible := true;
|
|
rxy.Visible := false;
|
|
rxz.Visible := false;
|
|
ryz.Visible := false;
|
|
SampSize.Visible := false;
|
|
SampSizeLabel.Visible := false;
|
|
end;
|
|
if ((index2 = 0) and (index1 = 1)) then // grid data for independent corrs
|
|
begin
|
|
Panel1.Visible := false;
|
|
Panel2.Visible := true;
|
|
xlabel.Visible := true;
|
|
ylabel.Visible := true;
|
|
zlabel.Visible := false;
|
|
xvar.Visible := true;
|
|
yvar.Visible := true;
|
|
zvar.Visible := false;
|
|
grouplabel.Visible := true;
|
|
groupvar.Visible := true;
|
|
end;
|
|
if ((index2 = 1) and (index1 = 0)) then // form data for dependent corrs
|
|
begin
|
|
Panel1.Visible := true;
|
|
Panel2.Visible := false;
|
|
corxylabel.Visible := true;
|
|
corxzlabel.Visible := true;
|
|
coryzlabel.Visible := true;
|
|
rxy.Visible := true;
|
|
rxz.Visible := true;
|
|
ryz.Visible := true;
|
|
sampsizelabel.Visible := true;
|
|
sampsize.Visible := true;
|
|
firstcorlabel.Visible := false;
|
|
rxy1.Visible := false;
|
|
size1label.Visible := false;
|
|
size1.Visible := false;
|
|
SecdCorLabel.Visible := false;
|
|
rxy2.Visible := false;
|
|
size2label.Visible := false;
|
|
size2.Visible := false;
|
|
end;
|
|
if ((index2 = 1) and (index1 = 1)) then // grid data for dependent corrs
|
|
begin
|
|
Panel1.Visible := false;
|
|
Panel2.Visible := true;
|
|
independent := false;
|
|
GroupVar.Visible := false;
|
|
sampsizelabel.Visible := true;
|
|
corxylabel.Visible := true;
|
|
corxzlabel.Visible := true;
|
|
coryzlabel.Visible := true;
|
|
xvar.Visible := true;
|
|
yvar.Visible := true;
|
|
Zvar.Visible := true;
|
|
zlabel.Visible := true;
|
|
SelVarLabel.Visible := true;
|
|
xlabel.Visible := true;
|
|
ylabel.Visible := true;
|
|
GroupLabel.Visible := false;
|
|
// rxy1.Visible := false;
|
|
// rxy2.Visible := false;
|
|
// Size1.Visible := false;
|
|
// Size2.Visible := false;
|
|
// firstcorlabel.Visible := false;
|
|
// size1label.Visible := false;
|
|
// SecdCorLabel.Visible := false;
|
|
// Size2Label.Visible := false;
|
|
// rxy.Visible := true;
|
|
// rxz.Visible := true;
|
|
// ryz.Visible := true;
|
|
// SampSize.Visible := true;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
{$I twocorrsunit.lrs}
|
|
|
|
end.
|
|
|