You've already forked lazarus-ccr
LazStats: Inherit TwoCorrsUnit from TBasicStatsReportForm. Minor refactoring of TwoCorrsUnit and TwoPropUnit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7843 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -307,7 +307,7 @@
|
||||
<Unit25>
|
||||
<Filename Value="forms\analysis\comparisons\twocorrsunit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="TwoCorrsFrm"/>
|
||||
<ComponentName Value="TwoCorrsForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="TwoCorrsUnit"/>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,198 +5,181 @@ unit TwoCorrsUnit;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
ExtCtrls, StdCtrls,
|
||||
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit;
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
ExtCtrls, StdCtrls, Buttons,
|
||||
MainUnit, Globals, FunctionsLib, DataProcs, BasicStatsReportFormUnit;
|
||||
|
||||
type
|
||||
|
||||
{ TTwoCorrsFrm }
|
||||
{ TTwoCorrsForm }
|
||||
|
||||
TTwoCorrsFrm = class(TForm)
|
||||
TTwoCorrsForm = class(TBasicStatsReportForm)
|
||||
Bevel1: TBevel;
|
||||
Bevel2: TBevel;
|
||||
HelpBtn: TButton;
|
||||
Notebook1: TNotebook;
|
||||
Bevel5: TBevel;
|
||||
Notebook: TNotebook;
|
||||
Page1: TPage;
|
||||
Page2: TPage;
|
||||
Page3: TPage;
|
||||
Panel1: TPanel;
|
||||
PanelPage1: TPanel;
|
||||
ResetBtn: TButton;
|
||||
ComputeBtn: TButton;
|
||||
ReturnBtn: TButton;
|
||||
CInterval: TEdit;
|
||||
CIntervalEdit: TEdit;
|
||||
Label14: TLabel;
|
||||
Xvar: TEdit;
|
||||
Yvar: TEdit;
|
||||
Zvar: TEdit;
|
||||
GroupVar: TEdit;
|
||||
xlabel: TLabel;
|
||||
ylabel: TLabel;
|
||||
zlabel: TLabel;
|
||||
GroupLabel: TLabel;
|
||||
Var1In: TBitBtn;
|
||||
Var2In: TBitBtn;
|
||||
Var1Out: TBitBtn;
|
||||
Var3In: TBitBtn;
|
||||
Var2Out: TBitBtn;
|
||||
GrpIn: TBitBtn;
|
||||
Var3Out: TBitBtn;
|
||||
GrpOut: TBitBtn;
|
||||
XVarEdit: TEdit;
|
||||
YVarEdit: TEdit;
|
||||
ZVarEdit: TEdit;
|
||||
GroupVarEdit: TEdit;
|
||||
XVarLabel: TLabel;
|
||||
YVarLabel: TLabel;
|
||||
ZVarLabel: TLabel;
|
||||
GroupVarLabel: TLabel;
|
||||
SelVarLabel: TLabel;
|
||||
VarList: TListBox;
|
||||
PanelPage3: TPanel;
|
||||
rxy1: TEdit;
|
||||
Size1: TEdit;
|
||||
rxy2: TEdit;
|
||||
Size2: TEdit;
|
||||
Corr1Edit: TEdit;
|
||||
SampleSize1Edit: TEdit;
|
||||
Corr2Edit: TEdit;
|
||||
Size2Edit: TEdit;
|
||||
firstcorlabel: TLabel;
|
||||
size1label: TLabel;
|
||||
SecdCorLabel: TLabel;
|
||||
Size2Label: TLabel;
|
||||
rxy: TEdit;
|
||||
rxz: TEdit;
|
||||
ryz: TEdit;
|
||||
SampSize: TEdit;
|
||||
CorrXYEdit: TEdit;
|
||||
CorrXZEdit: TEdit;
|
||||
CorrYZEdit: TEdit;
|
||||
SampleSizeEdit: TEdit;
|
||||
corxylabel: TLabel;
|
||||
corxzlabel: TLabel;
|
||||
coryzlabel: TLabel;
|
||||
sampsizelabel: TLabel;
|
||||
SampleSizeLabel: TLabel;
|
||||
PanelPage2: TPanel;
|
||||
RadioGroup1: TRadioGroup;
|
||||
RadioGroup2: TRadioGroup;
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(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);
|
||||
DataSourceGroup: TRadioGroup;
|
||||
DepIndepGroup: TRadioGroup;
|
||||
procedure DataSourceGroupClick(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 Var3InClick(Sender: TObject);
|
||||
procedure Var3OutClick(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
|
||||
TwoCorrsFrm: TTwoCorrsFrm;
|
||||
TwoCorrsForm: TTwoCorrsForm;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Math, MathUnit;
|
||||
Math,
|
||||
MathUnit, GridProcs;
|
||||
|
||||
{ TTwoCorrsFrm }
|
||||
|
||||
procedure TTwoCorrsFrm.ResetBtnClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
{ TTwoCorrsForm }
|
||||
|
||||
constructor TTwoCorrsForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
|
||||
|
||||
RadioGroup1.ItemIndex := 0;
|
||||
RadioGroup2.ItemIndex := 0;
|
||||
Notebook1.PageIndex := 0;
|
||||
VarList.Clear;
|
||||
Xvar.Text := '';
|
||||
Yvar.Text := '';
|
||||
Zvar.Text := '';
|
||||
rxy.Text := '';
|
||||
rxz.Text := '';
|
||||
ryz.Text := '';
|
||||
SampSize.Text := '';
|
||||
rxy1.Text := '';
|
||||
rxy2.Text := '';
|
||||
Size1.Text := '';
|
||||
Size2.Text := '';
|
||||
zlabel.Visible := false;
|
||||
Zvar.Visible := false;
|
||||
GroupLabel.Visible := true;
|
||||
GroupVar.Text := '';
|
||||
GroupVar.Visible := true;
|
||||
independent := true;
|
||||
griddata := false;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
inherited;
|
||||
CIntervalEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
|
||||
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.FormActivate(Sender: TObject);
|
||||
|
||||
procedure TTwoCorrsForm.AdjustConstraints;
|
||||
var
|
||||
w: Integer;
|
||||
begin
|
||||
if FAutoSized then
|
||||
exit;
|
||||
inherited;
|
||||
|
||||
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
|
||||
HelpBtn.Constraints.MinWidth := w;
|
||||
ResetBtn.Constraints.MinWidth := w;
|
||||
ComputeBtn.Constraints.MinWidth := w;
|
||||
ReturnBtn.Constraints.MinWidth := w;
|
||||
|
||||
Width := Max(
|
||||
RadioGroup2.Left + RadioGroup2.Width + RadioGroup2.BorderSpacing.Right,
|
||||
Width - HelpBtn.Left + HelpBtn.BorderSpacing.Left
|
||||
w := Max(DataSourceGroup.Width, DepIndepGroup.Width);
|
||||
DataSourceGroup.Constraints.MinWidth := w;
|
||||
DepIndepGroup.Constraints.MinWidth := w;
|
||||
ParamsPanel.Constraints.MinWidth := Max(
|
||||
CloseBtn.Width * 4 + CloseBtn.BorderSpacing.Left * 3,
|
||||
w * 2 + DepIndepGroup.BorderSpacing.Left
|
||||
);
|
||||
Constraints.MinWidth := Width;
|
||||
Constraints.MinHeight := Height;
|
||||
|
||||
FAutoSized := true;
|
||||
ParamsPanel.Constraints.MinHeight := DataSourceGroup.Height +
|
||||
NoteBook.BorderSpacing.Top + Var3Out.Top + Var3Out.Height +
|
||||
NoteBook.BorderSpacing.Bottom + CIntervalEdit.Height +
|
||||
ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsFrm.FormCreate(Sender: TObject);
|
||||
|
||||
procedure TTwoCorrsForm.Reset;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Assert(OS3MainFrm <> nil);
|
||||
inherited;
|
||||
|
||||
DataSourceGroup.ItemIndex := 0;
|
||||
DepIndepGroup.ItemIndex := 0;
|
||||
independent := true;
|
||||
griddata := false;
|
||||
|
||||
Notebook.PageIndex := 0;
|
||||
|
||||
VarList.Clear;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
|
||||
XVarEdit.Clear;
|
||||
YVarEdit.Clear;
|
||||
ZVarEdit.Clear;
|
||||
CorrXYEdit.Clear;
|
||||
CorrXZEdit.Clear;
|
||||
CorrYZEdit.Clear;
|
||||
SampleSizeEdit.Clear;
|
||||
Corr1Edit.Clear;
|
||||
Corr2Edit.Clear;
|
||||
SampleSize1Edit.Clear;
|
||||
Size2Edit.Clear;
|
||||
// ZVarLabel.Visible := false;
|
||||
// ZVarEdit.Visible := false;
|
||||
// GroupVarLabel.Visible := true;
|
||||
GroupVarEdit.Clear;
|
||||
// GroupVarEdit.Visible := true;
|
||||
|
||||
ZVarEdit.Visible := false;
|
||||
ZVarLabel.Visible := ZVarEdit.Visible;
|
||||
Var3In.Visible := ZVarEdit.Visible;
|
||||
Var3Out.Visible := ZVarEdit.Visible;
|
||||
|
||||
GroupVarEdit.Visible := not ZVarEdit.Visible;
|
||||
GroupVarLabel.Visible := GroupVarEdit.Visible;
|
||||
GrpIn.Visible := GroupVarEdit.Visible;
|
||||
GrpOut.Visible := GroupVarEdit.Visible;
|
||||
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
ResetBtnClick(self);
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsFrm.HelpBtnClick(Sender: TObject);
|
||||
begin
|
||||
if ContextHelpForm = nil then
|
||||
Application.CreateForm(TContextHelpForm, ContextHelpForm);
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).tag);
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsFrm.ComputeBtnClick(Sender: TObject);
|
||||
procedure TTwoCorrsForm.Compute;
|
||||
var
|
||||
lReport: TStrings;
|
||||
Corxy, Corxz, Coryz, Cor1, Cor2, alpha, tvalue, df2: double;
|
||||
@ -206,21 +189,11 @@ var
|
||||
stddev1, stddev2, stddev3, value1, value2, value3: double;
|
||||
meanx1, meanx2, meany1, meany2, varx1, varx2, vary1, vary2: double;
|
||||
sdx1, sdx2, sdy1, sdy2: double;
|
||||
SSize1, SSize2, SSize, v1, v2, v3, grp, ncases, NoSelected: integer;
|
||||
SSize1, SSize2, SSize, {v1, v2, v3, grp, }ncases: Integer; //, NoSelected: integer;
|
||||
min, max, grpval, ncases1, ncases2, i: integer;
|
||||
cellstring: string;
|
||||
msg: String;
|
||||
C: TWinControl;
|
||||
ColNoSelected: IntDyneVec = nil;
|
||||
begin
|
||||
if not Validate(msg, C) then
|
||||
begin
|
||||
C.SetFocus;
|
||||
MessageDlg(msg, mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
exit;
|
||||
end;
|
||||
|
||||
SetLength(ColNoSelected, NoVariables);
|
||||
Corxy := 0.0;
|
||||
Corxz := 0.0;
|
||||
@ -236,7 +209,7 @@ begin
|
||||
meanx1 := 0.0;
|
||||
meanx2 := 0.0;
|
||||
meany1 := 0.0;
|
||||
ConfLevel := StrToFloat(CInterval.Text) / 100.0;
|
||||
ConfLevel := StrToFloat(CIntervalEdit.Text) / 100.0;
|
||||
|
||||
// *** USE DATA ON THE FORM ***
|
||||
if not griddata then
|
||||
@ -244,10 +217,10 @@ begin
|
||||
// read data from form and obtain results
|
||||
if independent then
|
||||
begin
|
||||
Cor1 := StrToFloat(rxy1.Text);
|
||||
Cor2 := StrToFloat(rxy2.Text);
|
||||
SSize1 := StrToInt(Size1.Text);
|
||||
SSize2 := StrToInt(Size2.Text);
|
||||
Cor1 := StrToFloat(Corr1Edit.Text);
|
||||
Cor2 := StrToFloat(Corr2Edit.Text);
|
||||
SSize1 := StrToInt(SampleSize1Edit.Text);
|
||||
SSize2 := StrToInt(Size2Edit.Text);
|
||||
CorDif := Cor1 - Cor2;
|
||||
zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1));
|
||||
zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2));
|
||||
@ -266,10 +239,10 @@ begin
|
||||
// obtain data from form and obtain results
|
||||
if not independent then
|
||||
begin
|
||||
Corxy := StrToFloat(rxy.Text);
|
||||
Corxz := StrToFloat(rxz.Text);
|
||||
Coryz := StrToFloat(ryz.Text);
|
||||
SSize := StrToInt(SampSize.Text);
|
||||
Corxy := StrToFloat(CorrXYEdit.Text);
|
||||
Corxz := StrToFloat(CorrXZEdit.Text);
|
||||
Coryz := StrToFloat(CorrYZEdit.Text);
|
||||
SSize := StrToInt(SampleSizeEdit.Text);
|
||||
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));
|
||||
@ -279,26 +252,33 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// *** USE DATA FROM THE GRID ***
|
||||
if griddata then
|
||||
begin
|
||||
v1 := 1;
|
||||
v2 := 1;
|
||||
grp := 1;
|
||||
//v1 := 1;
|
||||
//v2 := 1;
|
||||
//grp := 1;
|
||||
|
||||
// read grid data for independent r's
|
||||
if independent then
|
||||
begin
|
||||
SetLength(ColNoSelected, 3);
|
||||
ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, XVarEdit.Text);
|
||||
ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, YVarEdit.Text);
|
||||
ColNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, GroupVarEdit.Text);
|
||||
(*
|
||||
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;
|
||||
if cellstring = XVarEdit.Text then v1 := i;
|
||||
if cellstring = YVarEdit.Text then v2 := i;
|
||||
if cellstring = GroupVarEdit.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;
|
||||
@ -311,26 +291,26 @@ begin
|
||||
Cor2 := 0.0;
|
||||
ncases1 := 0;
|
||||
ncases2 := 0;
|
||||
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,1])));
|
||||
max := min;
|
||||
for i := 2 to NoCases do
|
||||
min := MaxInt;
|
||||
max := -min;
|
||||
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 not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
|
||||
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], 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 not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
|
||||
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i])));
|
||||
if grpval = min then
|
||||
begin
|
||||
ncases1 := ncases1 + 1;
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
|
||||
meanx1 := meanx1 + value1;
|
||||
varx1 := varx1 + (value1 * value1);
|
||||
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
|
||||
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
|
||||
meany1 := meany1 + value2;
|
||||
vary1 := vary1 + value2 * value2;
|
||||
Cor1 := Cor1 + value1 * value2;
|
||||
@ -338,10 +318,10 @@ begin
|
||||
if grpval = max then
|
||||
begin
|
||||
ncases2 := ncases2 + 1;
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
|
||||
meanx2 := meanx2 + value1;
|
||||
varx2 := varx2 + (value1 * value1);
|
||||
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]));
|
||||
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
|
||||
meany2 := meany2 + value2;
|
||||
vary2 := vary2 + value2 * value2;
|
||||
Cor2 := Cor2 + value1 * value2;
|
||||
@ -399,24 +379,17 @@ begin
|
||||
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;
|
||||
SetLength(ColNoSelected, 3);
|
||||
ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, XVarEdit.Text);
|
||||
ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, YVarEdit.Text);
|
||||
ColNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, ZVarEdit.Text);
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
|
||||
if not GoodRecord(OS3MainFrm.DataGrid, i, 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]));
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
|
||||
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
|
||||
value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]));
|
||||
mean1 := mean1 + value1;
|
||||
mean2 := mean2 + value2;
|
||||
mean3 := mean3 + value3;
|
||||
@ -428,22 +401,22 @@ begin
|
||||
Coryz := Coryz + value2 * value3;
|
||||
end;
|
||||
variance1 := variance1 - mean1 * mean1 / ncases;
|
||||
variance1 := variance1 / (ncases - 1.0);
|
||||
variance1 := variance1 / (ncases - 1);
|
||||
stddev1 := sqrt(variance1);
|
||||
variance2 := variance2 - mean2 * mean2 / ncases;
|
||||
variance2 := variance2 / (ncases - 1.0);
|
||||
variance2 := variance2 / (ncases - 1);
|
||||
stddev2 := sqrt(variance2);
|
||||
variance3 := variance3 - mean3 * mean3 / ncases;
|
||||
variance3 := variance3 / (ncases - 1.0);
|
||||
variance3 := variance3 / (ncases - 1);
|
||||
stddev3 := sqrt(variance3);
|
||||
Corxy := Corxy - mean1 * mean2 / ncases;
|
||||
Corxy := Corxy / (ncases - 1.0);
|
||||
Corxy := Corxy / (ncases - 1);
|
||||
Corxy := Corxy / (stddev1 * stddev2);
|
||||
Corxz := Corxz - mean1 * mean3 / ncases;
|
||||
Corxz := Corxz / (ncases - 1.0);
|
||||
Corxz := Corxz / (ncases - 1);
|
||||
Corxz := Corxz / (stddev1 * stddev3);
|
||||
Coryz := Coryz - mean2 * mean3 / ncases;
|
||||
Coryz := Coryz / (ncases - 1.0);
|
||||
Coryz := Coryz / (ncases - 1);
|
||||
Coryz := Coryz / (stddev2 * stddev3);
|
||||
mean1 := mean1 / ncases;
|
||||
mean2 := mean2 / ncases;
|
||||
@ -467,11 +440,11 @@ begin
|
||||
if independent then
|
||||
begin
|
||||
lReport.Add('Correlation one: %6.3f', [Cor1]);
|
||||
lReport.Add('Sample size one: %6d', [SSize1]);
|
||||
lReport.Add('Sample size one: %6d', [SSize1]);
|
||||
lReport.Add('Correlation two: %6.3f', [Cor2]);
|
||||
lReport.Add('Sample size two: %6d', [SSize2]);
|
||||
lReport.Add('Sample size two: %6d', [SSize2]);
|
||||
lReport.Add('Difference between correlations: %6.3f', [CorDif]);
|
||||
lReport.Add('Confidence level selected: %6s', [CInterval.Text]);
|
||||
lReport.Add('Confidence level selected: %6s', [CIntervalEdit.Text]);
|
||||
lReport.Add('z for Correlation One: %6.3f', [zOne]);
|
||||
lReport.Add('z for Correlation Two: %6.3f', [zTwo]);
|
||||
lReport.Add('z difference: %6.3f', [zDif]);
|
||||
@ -480,7 +453,7 @@ begin
|
||||
lReport.Add('Probability > |z|: %6.3f', [zprobability]);
|
||||
lReport.Add('z Required for significance: %6.3f', [zTest]);
|
||||
lReport.Add('Note: above is a two-tailed test.');
|
||||
lReport.Add('Confidence Limits = (%.3f ... %.3f)', [LCL, UCL]);
|
||||
lReport.Add('Confidence Limits: %6.3f ... %.3f', [LCL, UCL]);
|
||||
lReport.Add('');
|
||||
if griddata then
|
||||
begin
|
||||
@ -488,7 +461,7 @@ begin
|
||||
lReport.Add('Mean X for group 2: %9.3f', [meanx2]);
|
||||
lReport.Add('Std.Dev. X for group 1: %9.3f', [sdx1]);
|
||||
lReport.Add('Std.Dev. X for group 2: %9.3f', [sdx2]);
|
||||
lReport.Add('Mean y for group 1; %9.3f', [meany1]);
|
||||
lReport.Add('Mean y for group 1: %9.3f', [meany1]);
|
||||
lReport.Add('Mean Y for group 2: %9.3f', [meany2]);
|
||||
lReport.Add('Std.Dev. Y for group 1: %9.3f', [sdy1]);
|
||||
lReport.Add('Std.Dev. Y for group 2: %9.3f', [sdy2]);
|
||||
@ -500,8 +473,8 @@ begin
|
||||
lReport.Add('Correlation x with y: %6.3f', [Corxy]);
|
||||
lReport.Add('Correlation x with z: %6.3f', [Corxz]);
|
||||
lReport.Add('Correlation y with z: %6.3f', [Coryz]);
|
||||
lReport.Add('Sample size: %6d', [SSize]);
|
||||
lReport.Add('Confidence Level Selected: %6s', [CInterval.Text]);
|
||||
lReport.Add('Sample size: %6d', [SSize]);
|
||||
lReport.Add('Confidence Level Selected: %6s', [CIntervalEdit.Text]);
|
||||
lReport.Add('Difference r(x,y) - r(x,z): %6.3f', [CorDif]);
|
||||
lReport.Add('t test statistic: %6.3f', [tvalue]);
|
||||
lReport.Add('Probability > |t|: %6.3f', [tprobability]);
|
||||
@ -509,83 +482,114 @@ begin
|
||||
lReport.Add('');
|
||||
if griddata then
|
||||
begin
|
||||
lReport.Add('Variable Mean Variance Std.Dev.');
|
||||
lReport.Add(' X %9.3f %9.3f %9.3f', [mean1, variance1, stddev1]);
|
||||
lReport.Add(' Y %9.3f %9.3f %9.3f', [mean2, variance2, stddev2]);
|
||||
lReport.Add(' Z %9.3f %9.3f %9.3f', [mean3, variance3, stddev3]);
|
||||
lReport.Add('Variable Mean Variance Std.Dev. ');
|
||||
lReport.Add('-------- ---------- ---------- ----------');
|
||||
lReport.Add(' X %10.3f %10.3f %10.3f', [mean1, variance1, stddev1]);
|
||||
lReport.Add(' Y %10.3f %10.3f %10.3f', [mean2, variance2, stddev2]);
|
||||
lReport.Add(' Z %10.3f %10.3f %10.3f', [mean3, variance3, stddev3]);
|
||||
end;
|
||||
end;
|
||||
|
||||
DisplayReport(lReport);
|
||||
FReportFrame.DisplayReport(lReport);
|
||||
|
||||
finally
|
||||
lReport.Free;
|
||||
ColNoSelected := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsFrm.RadioGroup1Click(Sender: TObject);
|
||||
|
||||
procedure TTwoCorrsForm.DataSourceGroupClick(Sender: TObject);
|
||||
var
|
||||
index: integer;
|
||||
begin
|
||||
index := RadioGroup1.ItemIndex;
|
||||
index := DataSourceGroup.ItemIndex;
|
||||
if index = 0 then
|
||||
begin
|
||||
griddata := false;
|
||||
if independent then
|
||||
Notebook1.PageIndex := 0
|
||||
Notebook.PageIndex := 0
|
||||
else
|
||||
Notebook1.PageIndex := 1;
|
||||
Notebook.PageIndex := 1;
|
||||
end else
|
||||
begin
|
||||
griddata := true;
|
||||
Notebook1.PageIndex := 2;
|
||||
Notebook.PageIndex := 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsFrm.RadioGroup2Click(Sender: TObject);
|
||||
|
||||
procedure TTwoCorrsForm.DepIndepGroupClick(Sender: TObject);
|
||||
var
|
||||
index1, index2: integer;
|
||||
begin
|
||||
index1 := RadioGroup1.ItemIndex;
|
||||
index2 := RadioGroup2.ItemIndex;
|
||||
index1 := DataSourceGroup.ItemIndex;
|
||||
index2 := DepIndepGroup.ItemIndex;
|
||||
|
||||
// form input with independent corrs
|
||||
if ((index2 = 0) and (index1 = 0)) then
|
||||
begin
|
||||
independent := true;
|
||||
Notebook1.PageIndex := 0;
|
||||
Notebook.PageIndex := 0;
|
||||
end;
|
||||
|
||||
// grid data for independent corrs
|
||||
if ((index2 = 0) and (index1 = 1)) then
|
||||
begin
|
||||
Notebook1.PageIndex := 2;
|
||||
zlabel.Visible := false;
|
||||
zvar.Visible := false;
|
||||
grouplabel.Visible := true;
|
||||
groupvar.Visible := true;
|
||||
Notebook.PageIndex := 2;
|
||||
// ZVarLabel.Visible := false;
|
||||
ZVarEdit.Visible := false;
|
||||
// GroupVarLabel.Visible := true;
|
||||
// GroupVarEdit.Visible := true;
|
||||
end;
|
||||
|
||||
// form data for dependent corrs
|
||||
if ((index2 = 1) and (index1 = 0)) then
|
||||
begin
|
||||
Notebook1.PageIndex := 1;
|
||||
Notebook.PageIndex := 1;
|
||||
end;
|
||||
|
||||
// grid data for dependent corrs
|
||||
if ((index2 = 1) and (index1 = 1)) then
|
||||
begin
|
||||
Notebook1.PageIndex := 2;
|
||||
Notebook.PageIndex := 2;
|
||||
independent := false;
|
||||
zlabel.Visible := true;
|
||||
Zvar.Visible := true;
|
||||
GroupLabel.Visible := false;
|
||||
GroupVar.Visible := false;
|
||||
// ZVarLabel.Visible := true;
|
||||
ZVarEdit.Visible := true;
|
||||
// GroupVarLabel.Visible := false;
|
||||
// GroupVarEdit.Visible := false;
|
||||
end;
|
||||
|
||||
// if Notebook.PageIndex = 2 then
|
||||
// begin
|
||||
ZVarLabel.Visible := ZVarEdit.Visible;
|
||||
Var3In.Visible := ZVarEdit.Visible;
|
||||
Var3Out.Visible := ZVarEdit.Visible;
|
||||
|
||||
GroupVarEdit.Visible := not ZVarEdit.Visible;
|
||||
GroupVarLabel.Visible := GroupVarEdit.Visible;
|
||||
GrpIn.Visible := GroupVarEdit.Visible;
|
||||
GrpOut.Visible := GroupVarEdit.Visible;
|
||||
// end;
|
||||
end;
|
||||
|
||||
function TTwoCorrsFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
|
||||
procedure TTwoCorrsForm.UpdateBtnStates;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
Var1In.Enabled := (VarList.ItemIndex > -1) and (XVarEdit.Text = '');
|
||||
Var2In.Enabled := (VarList.ItemIndex > -1) and (YVarEdit.Text = '');
|
||||
Var3In.Enabled := (VarList.ItemIndex > -1) and (ZVarEdit.Text = '');
|
||||
GrpIn.Enabled := (VarList.ItemIndex > -1) and (GroupVarEdit.Text = '');
|
||||
|
||||
Var1Out.Enabled := XVarEdit.Text <> '';
|
||||
Var2Out.Enabled := YVarEdit.Text <> '';
|
||||
Var3Out.Enabled := ZVarEdit.Text <> '';
|
||||
GrpOut.Enabled := GroupVarEdit.Text <> '';
|
||||
end;
|
||||
|
||||
|
||||
function TTwoCorrsForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
var
|
||||
n: Integer;
|
||||
x: Double;
|
||||
@ -593,75 +597,75 @@ begin
|
||||
Result := false;
|
||||
AControl := nil;
|
||||
AMsg := '';
|
||||
if Notebook1.PageIndex = 0 then
|
||||
if Notebook.PageIndex = 0 then
|
||||
begin
|
||||
if (rxy1.Text = '') or not TryStrToFloat(rxy1.Text, x) then
|
||||
if (Corr1Edit.Text = '') or not TryStrToFloat(Corr1Edit.Text, x) then
|
||||
begin
|
||||
AControl := rxy1;
|
||||
AControl := Corr1Edit;
|
||||
AMsg := 'Invalid input for first correlation';
|
||||
exit;
|
||||
end;
|
||||
if (Size1.Text = '') or not TryStrToInt(Size1.Text, n) or (n <= 0) then
|
||||
if (SampleSize1Edit.Text = '') or not TryStrToInt(SampleSize1Edit.Text, n) or (n <= 0) then
|
||||
begin
|
||||
AControl := Size1;
|
||||
AControl := SampleSize1Edit;
|
||||
AMsg := 'Invald input for size of sample 1';
|
||||
exit;
|
||||
end;
|
||||
if (rxy2.Text = '') or not TryStrToFloat(rxy2.Text, x) then
|
||||
if (Corr2Edit.Text = '') or not TryStrToFloat(Corr2Edit.Text, x) then
|
||||
begin
|
||||
AControl := rxy2;
|
||||
AControl := Corr2Edit;
|
||||
AMsg := 'Invalid input for second correlation';
|
||||
exit;
|
||||
end;
|
||||
if (Size2.Text = '') or not TryStrToInt(Size2.Text, n) or (n <= 0) then
|
||||
if (Size2Edit.Text = '') or not TryStrToInt(Size2Edit.Text, n) or (n <= 0) then
|
||||
begin
|
||||
AControl := Size2;
|
||||
AControl := Size2Edit;
|
||||
AMsg := 'Invalud input for size of sample 2';
|
||||
exit;
|
||||
end;
|
||||
end else
|
||||
if Notebook1.PageIndex = 1 then
|
||||
if Notebook.PageIndex = 1 then
|
||||
begin
|
||||
if (rxy.Text = '') or not TryStrToFloat(rxy.Text, x) then
|
||||
AControl := rxy
|
||||
if (CorrXYEdit.Text = '') or not TryStrToFloat(CorrXYEdit.Text, x) then
|
||||
AControl := CorrXYEdit
|
||||
else
|
||||
if (rxz.Text = '') or not TryStrToFloat(rxz.Text, x) then
|
||||
AControl := rxz
|
||||
if (CorrXZEdit.Text = '') or not TryStrToFloat(CorrXZEdit.Text, x) then
|
||||
AControl := CorrXZEdit
|
||||
else
|
||||
if (ryz.Text = '') or not TryStrToFloat(ryz.Text, x) then
|
||||
AControl := ryz
|
||||
if (CorrYZEdit.Text = '') or not TryStrToFloat(CorrYZEdit.Text, x) then
|
||||
AControl := CorrYZEdit
|
||||
else
|
||||
if (SampSize.Text = '') or not TryStrToInt(SampSize.Text, n) or (n < 0) then
|
||||
AControl := SampSize;
|
||||
if (SampleSizeEdit.Text = '') or not TryStrToInt(SampleSizeEdit.Text, n) or (n < 0) then
|
||||
AControl := SampleSizeEdit;
|
||||
if AControl <> nil then
|
||||
begin
|
||||
AMsg := 'Invalid input.';
|
||||
exit;
|
||||
end;
|
||||
end else
|
||||
if Notebook1.PageIndex = 2 then
|
||||
if Notebook.PageIndex = 2 then
|
||||
begin
|
||||
if XVar.Text = '' then
|
||||
if XVarEdit.Text = '' then
|
||||
begin
|
||||
AControl := XVar;
|
||||
AControl := XVarEdit;
|
||||
AMsg := 'X variable not specified.';
|
||||
exit;
|
||||
end;
|
||||
if YVar.Text = '' then
|
||||
if YVarEdit.Text = '' then
|
||||
begin
|
||||
AControl := YVar;
|
||||
AControl := YVarEdit;
|
||||
AMsg := 'Y variable not specified.';
|
||||
exit;
|
||||
end;
|
||||
case RadioGroup2.ItemIndex of
|
||||
0: if (GroupVar.Text = '') then
|
||||
case DepIndepGroup.ItemIndex of
|
||||
0: if (GroupVarEdit.Text = '') then
|
||||
begin
|
||||
AControl := GroupVar;
|
||||
AControl := GroupVarEdit;
|
||||
AMsg := 'Group variable not specified';
|
||||
exit;
|
||||
end;
|
||||
1: if (ZVar.Text = '') then begin
|
||||
AControl := ZVar;
|
||||
1: if (ZVarEdit.Text = '') then begin
|
||||
AControl := ZVarEdit;
|
||||
AMsg := 'Z variable not specified.';
|
||||
exit;
|
||||
end;
|
||||
@ -670,8 +674,156 @@ begin
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I twocorrsunit.lrs}
|
||||
|
||||
procedure TTwoCorrsForm.Var1InClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index > -1 then
|
||||
begin
|
||||
if XVarEdit.Text = '' then
|
||||
begin
|
||||
XVarEdit.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsForm.Var1OutClick(Sender: TObject);
|
||||
begin
|
||||
if XVarEdit.Text <> '' then
|
||||
begin
|
||||
VarList.Items.Add(XVarEdit.Text);
|
||||
XVarEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.Var2InClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index > -1 then
|
||||
begin
|
||||
if YVarEdit.Text = '' then
|
||||
begin
|
||||
YVarEdit.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.Var2OutClick(Sender: TObject);
|
||||
begin
|
||||
if YVarEdit.Text <> '' then
|
||||
begin
|
||||
VarList.Items.Add(YVarEdit.Text);
|
||||
YVarEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.Var3InClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if (not independent) and (index > -1) then
|
||||
begin
|
||||
if ZVarEdit.Text = '' then
|
||||
begin
|
||||
ZVarEdit.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.Var3OutClick(Sender: TObject);
|
||||
begin
|
||||
if (not independent) and (ZVarEdit.Text <> '') then
|
||||
begin
|
||||
VarList.Items.Add(ZVarEdit.Text);
|
||||
ZVarEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.GrpInClick(Sender: TObject);
|
||||
var
|
||||
index: Integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if independent and (index > -1) then
|
||||
begin
|
||||
if GroupVarEdit.Text = '' then
|
||||
begin
|
||||
GroupVarEdit.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTwoCorrsForm.GrpOutClick(Sender: TObject);
|
||||
begin
|
||||
if independent and (GroupVarEdit.Text <> '') then
|
||||
begin
|
||||
VarList.Items.Add(GroupVarEdit.Text);
|
||||
GroupVarEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.VarListDblClick(Sender: TObject);
|
||||
var
|
||||
index: integer;
|
||||
s: String;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index >-1 then
|
||||
begin
|
||||
s := VarList.Items[index];
|
||||
if XVarEdit.Text = '' then
|
||||
begin
|
||||
XVarEdit.Text := s;
|
||||
VarList.Items.Delete(index);
|
||||
end else
|
||||
if YVarEdit.Text = '' then
|
||||
begin
|
||||
YVarEdit.Text := s;
|
||||
VarList.Items.Delete(index);
|
||||
end else
|
||||
if (not independent) and (ZVarEdit.Text = '') then
|
||||
begin
|
||||
ZVarEdit.Text := VarList.Items.Strings[index];
|
||||
VarList.Items.Delete(index);
|
||||
end else
|
||||
if independent and (GroupVarEdit.Text = '') then
|
||||
begin
|
||||
GroupVarEdit.Text := VarList.Items.Strings[index];
|
||||
VarList.Items.Delete(index);
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoCorrsForm.VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
begin
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
@ -36,7 +36,7 @@ inherited TwoPropForm: TTwoPropForm
|
||||
end
|
||||
object Notebook: TNotebook[5]
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = RadioGroup1
|
||||
AnchorSideTop.Control = DataSourceGroup
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
@ -60,8 +60,8 @@ inherited TwoPropForm: TTwoPropForm
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 0
|
||||
Width = 83
|
||||
Caption = 'Select Variables:'
|
||||
Width = 97
|
||||
Caption = 'Available Variables'
|
||||
ParentColor = False
|
||||
end
|
||||
object Var1Label: TLabel
|
||||
@ -523,7 +523,7 @@ inherited TwoPropForm: TTwoPropForm
|
||||
TabOrder = 5
|
||||
Text = '95.0'
|
||||
end
|
||||
object RadioGroup1: TRadioGroup[8]
|
||||
object DataSourceGroup: TRadioGroup[8]
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
AnchorSideRight.Control = Bevel5
|
||||
Left = -3
|
||||
@ -549,7 +549,7 @@ inherited TwoPropForm: TTwoPropForm
|
||||
'Values Entered on this Form'
|
||||
'Values in the Data Grid'
|
||||
)
|
||||
OnClick = RadioGroup1Click
|
||||
OnClick = DataSourceGroupClick
|
||||
TabOrder = 6
|
||||
end
|
||||
object DepIndepGroup: TRadioGroup[9]
|
||||
|
@ -58,11 +58,11 @@ type
|
||||
Samp20Label: TLabel;
|
||||
GrpOut: TBitBtn;
|
||||
VarList: TListBox;
|
||||
RadioGroup1: TRadioGroup;
|
||||
DataSourceGroup: TRadioGroup;
|
||||
DepIndepGroup: TRadioGroup;
|
||||
procedure GrpInClick(Sender: TObject);
|
||||
procedure GrpOutClick(Sender: TObject);
|
||||
procedure RadioGroup1Click(Sender: TObject);
|
||||
procedure DataSourceGroupClick(Sender: TObject);
|
||||
procedure DepIndepGroupClick(Sender: TObject);
|
||||
procedure Var1InClick(Sender: TObject);
|
||||
procedure Var1OutClick(Sender: TObject);
|
||||
@ -94,7 +94,8 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Math;
|
||||
Math,
|
||||
GridProcs;
|
||||
|
||||
|
||||
{ TTwoPropForm }
|
||||
@ -107,13 +108,20 @@ end;
|
||||
|
||||
|
||||
procedure TTwoPropForm.AdjustConstraints;
|
||||
var
|
||||
w: Integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
w := Max(DataSourceGroup.Width, DepIndepGroup.Width);
|
||||
DataSourceGroup.Constraints.MinWidth := w;
|
||||
DepIndepGroup.Constraints.MinWidth := w;
|
||||
ParamsPanel.Constraints.MinWidth := Max(
|
||||
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
|
||||
RadioGroup1.Width + Bevel5.Width + DepIndepGroup.Width
|
||||
2*w + Bevel5.Width
|
||||
);
|
||||
ParamsPanel.Constraints.MinHeight := GrpOut.Top + GrpOut.Height +
|
||||
ParamsPanel.Constraints.MinHeight := DataSourceGroup.Height +
|
||||
Notebook.BorderSpacing.Top + Var2Out.Top + Var2Out.Height +
|
||||
Notebook.BorderSpacing.Bottom + CIntervalEdit.Height + ButtonBevel.Height +
|
||||
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
|
||||
end;
|
||||
@ -124,7 +132,8 @@ var
|
||||
ConfInt, Prop1, Prop2, zstatistic, zprobability: double;
|
||||
PropDif, stderr, UCL, LCL, value1, value2, ztest: double;
|
||||
P, Q: double;
|
||||
i, v1, v2, NoSelected, f1, f2, f3, f4, ncases1, ncases2: integer;
|
||||
i: Integer; //, v1, v2, NoSelected,
|
||||
f1, f2, f3, f4, ncases1, ncases2: integer;
|
||||
min, max, group, AB, AC, CD, BD: integer;
|
||||
ColNoSelected: IntDyneVec = nil;
|
||||
lReport: TStrings;
|
||||
@ -132,12 +141,12 @@ begin
|
||||
// Initialize output form
|
||||
stderr := 0.0;
|
||||
PropDif := 0.0;
|
||||
v2 := 0;
|
||||
// v2 := 0;
|
||||
ztest := 0.0;
|
||||
Prop1 := 0.0;
|
||||
Prop2 := 0.0;
|
||||
NoSelected := 0;
|
||||
v1 := 0;
|
||||
// NoSelected := 0;
|
||||
// v1 := 0;
|
||||
zstatistic := 0.0;
|
||||
zprobability := 0.0;
|
||||
UCL := 0.0;
|
||||
@ -147,6 +156,7 @@ begin
|
||||
|
||||
ConfInt := (100.0 - StrToFloat(CIntervalEdit.Text)) / 2.0 ;
|
||||
ConfInt := (100.0 - ConfInt) / 100.0; // one tail
|
||||
|
||||
ncases1 := 0;
|
||||
ncases2 := 0;
|
||||
f1 := 0;
|
||||
@ -158,6 +168,10 @@ begin
|
||||
|
||||
if griddata then // data read from grid
|
||||
begin
|
||||
SetLength(ColNoSelected, 2);
|
||||
ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, Var1Edit.Text);
|
||||
ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Var2Edit.Text);
|
||||
{
|
||||
for i := 1 to NoVariables do
|
||||
begin
|
||||
if Var1Edit.Text = OS3MainFrm.DataGrid.Cells[i,0] then
|
||||
@ -172,30 +186,34 @@ begin
|
||||
ColNoSelected[1] := i;
|
||||
end;
|
||||
end; // next variable
|
||||
}
|
||||
|
||||
f1 := 0;
|
||||
f2 := 0;
|
||||
nCases1 := 0;
|
||||
if not independent then // correlated data
|
||||
begin
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
|
||||
ncases1 := ncases1 + 1;
|
||||
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;
|
||||
nCases1 := nCases1 + 1;
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
|
||||
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
|
||||
f1 := f1 + round(value1);
|
||||
f2 := f2 + round(value2);
|
||||
end; // next case
|
||||
f3 := ncases1 - f1;
|
||||
f4 := ncases1 - f2;
|
||||
f3 := nCases1 - f1;
|
||||
f4 := nCases1 - f2;
|
||||
AB := f1 + f2;
|
||||
AC := f1 + f3;
|
||||
CD := f3 + f4;
|
||||
BD := f2 + f4;
|
||||
Prop1 := BD / ncases1;
|
||||
Prop2 := AB / ncases1;
|
||||
stderr := sqrt((f1 / ncases1 + f4 / ncases1) / ncases1);
|
||||
Prop1 := BD / nCases1;
|
||||
Prop2 := AB / nCases1;
|
||||
stderr := sqrt((f1 / nCases1 + f4 / nCases1) / nCases1);
|
||||
PropDif := Prop1 - Prop2;
|
||||
zstatistic := PropDif / stderr;
|
||||
ztest := inversez(ConfInt);
|
||||
ztest := InverseZ(ConfInt);
|
||||
zprobability := 1.0 - ProbZ(abs(zstatistic));
|
||||
UCL := PropDif + stderr * ztest;
|
||||
LCL := PropDif - stderr * ztest;
|
||||
@ -203,21 +221,21 @@ begin
|
||||
|
||||
if independent then
|
||||
begin
|
||||
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,1])));
|
||||
min := MaxInt;
|
||||
max := min;
|
||||
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 not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
|
||||
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])));
|
||||
if group < min then min := group;
|
||||
if group > max then max := group;
|
||||
end;
|
||||
|
||||
for i := 1 to NoCases do
|
||||
begin
|
||||
if not GoodRecord(i,NoSelected,ColNoSelected) then continue;
|
||||
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i]));
|
||||
group := round(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]));
|
||||
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])));
|
||||
if group = min then
|
||||
begin
|
||||
f1 := f1 + round(value1);
|
||||
@ -307,8 +325,10 @@ begin
|
||||
lReport.Add(' --------|-------|------');
|
||||
lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]);
|
||||
lReport.Add('');
|
||||
lReport.Add('Confidence Level selected: %s', [CIntervalEdit.Text]);
|
||||
lReport.Add('Proportion 1 = %.3f and Proportion 2 = %.3f with %d cases', [Prop1, Prop2, ncases1]);
|
||||
lReport.Add('Confidence Level selected: %9s', [CIntervalEdit.Text]);
|
||||
lReport.Add('Proportion 1: %9.3f', [Prop1]);
|
||||
lReport.Add('Proportion 2: %9.3f', [Prop2]);
|
||||
lReport.Add('Number of cases: %9d', [nCases1]);
|
||||
lReport.Add('Difference in proportions: %9.3f', [PropDif]);
|
||||
lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
|
||||
lReport.Add('z test statistic: %9.3f', [zStatistic]);
|
||||
@ -323,14 +343,14 @@ begin
|
||||
lReport.Add('');
|
||||
lReport.Add('Entered Values');
|
||||
lReport.Add('');
|
||||
lReport.Add('Sample 1: Frequency = %5d for %5d cases.', [f1, ncases1]);
|
||||
lReport.Add('Sample 2: Frequency = %5d for %5d cases.', [f2, ncases2]);
|
||||
lReport.Add('Sample 1: Frequency %5d for %5d cases.', [f1, ncases1]);
|
||||
lReport.Add('Sample 2: Frequency %5d for %5d cases.', [f2, ncases2]);
|
||||
lReport.Add('');
|
||||
lReport.Add('Proportion 1: %9.3f', [Prop1]);
|
||||
lReport.Add('Proportion 2: %9.3f', [Prop2]);
|
||||
lReport.Add('Difference: %9.3f', [PropDif]);
|
||||
lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
|
||||
lReport.Add('Confidence Level selected: %-9s', [CIntervalEdit.Text]);
|
||||
lReport.Add('Confidence Level selected: %9s', [CIntervalEdit.Text]);
|
||||
lReport.Add('z test statistic: %9.3f', [zStatistic]);
|
||||
lReport.Add(' with probability %9.4f', [zProbability]);
|
||||
lReport.Add('z value for confidence interval: %9.3f', [ztest]);
|
||||
@ -370,9 +390,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TTwoPropForm.RadioGroup1Click(Sender: TObject);
|
||||
procedure TTwoPropForm.DataSourceGroupClick(Sender: TObject);
|
||||
begin
|
||||
griddata := (RadioGroup1.ItemIndex = 1);
|
||||
griddata := (DataSourceGroup.ItemIndex = 1);
|
||||
DepIndepGroupClick(nil);
|
||||
end;
|
||||
|
||||
@ -415,7 +435,7 @@ var
|
||||
begin
|
||||
inherited;
|
||||
|
||||
RadioGroup1.ItemIndex := 0;
|
||||
DataSourceGroup.ItemIndex := 0;
|
||||
DepIndepGroup.ItemIndex := 0;
|
||||
|
||||
VarList.Clear;
|
||||
@ -600,20 +620,20 @@ begin
|
||||
begin
|
||||
s := VarList.Items[index];
|
||||
if Var1Edit.Text = '' then
|
||||
Var1Edit.Text := s
|
||||
else
|
||||
begin
|
||||
if independent then
|
||||
begin
|
||||
if GrpEdit.Text = '' then
|
||||
GrpEdit.Text := s;
|
||||
end else
|
||||
begin
|
||||
if Var2Edit.Text = '' then
|
||||
Var2Edit.Text := s;
|
||||
end;
|
||||
Var1Edit.Text := s;
|
||||
VarList.Items.Delete(index);
|
||||
end else
|
||||
if independent and (GrpEdit.Text = '') then
|
||||
begin
|
||||
GrpEdit.Text := s;
|
||||
VarList.Items.Delete(index);
|
||||
end else
|
||||
if (not independent) and (Var2Edit.Text = '') then
|
||||
begin
|
||||
Var2Edit.Text := s;
|
||||
VarList.Items.Delete(index);
|
||||
end;
|
||||
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
@ -1087,9 +1087,9 @@ end;
|
||||
// Menu "Analysis" > "Comparisons" > "Difference Between Correlations"
|
||||
procedure TOS3MainFrm.mnuAnalysisComp_CorrDiffClick(Sender: TObject);
|
||||
begin
|
||||
if TwoCorrsFrm = nil then
|
||||
Application.CreateForm(TTwoCorrsFrm, TwoCorrsFrm);
|
||||
TwoCorrsFrm.ShowModal;
|
||||
if TwoCorrsForm = nil then
|
||||
Application.CreateForm(TTwoCorrsForm, TwoCorrsForm);
|
||||
TwoCorrsForm.Show;
|
||||
end;
|
||||
|
||||
// Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"
|
||||
|
Reference in New Issue
Block a user