You've already forked lazarus-ccr
LazStats: Imoproved results presentation in RIDITUnit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7830 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,13 +1,13 @@
|
|||||||
inherited RIDITForm: TRIDITForm
|
inherited RIDITForm: TRIDITForm
|
||||||
Left = 778
|
Left = 864
|
||||||
Height = 477
|
Height = 477
|
||||||
Top = 182
|
Top = 327
|
||||||
Width = 673
|
Width = 903
|
||||||
HelpType = htKeyword
|
HelpType = htKeyword
|
||||||
HelpKeyword = 'html/RIDITAnalysis.htm'
|
HelpKeyword = 'html/RIDITAnalysis.htm'
|
||||||
Caption = 'Relative to an Identified Distribution Analysis'
|
Caption = 'Relative to an Identified Distribution Analysis'
|
||||||
ClientHeight = 477
|
ClientHeight = 477
|
||||||
ClientWidth = 673
|
ClientWidth = 903
|
||||||
inherited ParamsPanel: TPanel
|
inherited ParamsPanel: TPanel
|
||||||
Height = 461
|
Height = 461
|
||||||
Width = 416
|
Width = 416
|
||||||
@ -408,4 +408,30 @@ inherited RIDITForm: TRIDITForm
|
|||||||
Left = 428
|
Left = 428
|
||||||
Height = 477
|
Height = 477
|
||||||
end
|
end
|
||||||
|
object PageControl: TPageControl[2]
|
||||||
|
Left = 437
|
||||||
|
Height = 461
|
||||||
|
Top = 8
|
||||||
|
Width = 458
|
||||||
|
ActivePage = FrequenciesPage
|
||||||
|
Align = alClient
|
||||||
|
BorderSpacing.Left = 4
|
||||||
|
BorderSpacing.Top = 8
|
||||||
|
BorderSpacing.Right = 8
|
||||||
|
BorderSpacing.Bottom = 8
|
||||||
|
TabIndex = 1
|
||||||
|
TabOrder = 2
|
||||||
|
object ResultsPage: TTabSheet
|
||||||
|
Caption = 'Results'
|
||||||
|
end
|
||||||
|
object FrequenciesPage: TTabSheet
|
||||||
|
Caption = 'Frequencies'
|
||||||
|
end
|
||||||
|
object RowColPropsPage: TTabSheet
|
||||||
|
Caption = 'Row/Column Properties'
|
||||||
|
end
|
||||||
|
object CellChiSqrPage: TTabSheet
|
||||||
|
Caption = 'Cell ChiSsqr'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,8 +6,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, Buttons, ExtCtrls,
|
StdCtrls, Buttons, ExtCtrls, ComCtrls,
|
||||||
MainUnit, Globals, FunctionsLib, MatrixLib, BasicStatsReportFormUnit;
|
MainUnit, Globals, FunctionsLib, MatrixLib, ReportFrameUnit, BasicStatsReportFormUnit;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -17,6 +17,7 @@ type
|
|||||||
Bevel2: TBevel;
|
Bevel2: TBevel;
|
||||||
BonChk: TCheckBox;
|
BonChk: TCheckBox;
|
||||||
AlphaEdit: TEdit;
|
AlphaEdit: TEdit;
|
||||||
|
PageControl: TPageControl;
|
||||||
Panel1: TPanel;
|
Panel1: TPanel;
|
||||||
AlphaLabel: TLabel;
|
AlphaLabel: TLabel;
|
||||||
ObsChk: TCheckBox;
|
ObsChk: TCheckBox;
|
||||||
@ -24,6 +25,10 @@ type
|
|||||||
PropChk: TCheckBox;
|
PropChk: TCheckBox;
|
||||||
ChiChk: TCheckBox;
|
ChiChk: TCheckBox;
|
||||||
RefGrp: TRadioGroup;
|
RefGrp: TRadioGroup;
|
||||||
|
ResultsPage: TTabSheet;
|
||||||
|
FrequenciesPage: TTabSheet;
|
||||||
|
RowColPropsPage: TTabSheet;
|
||||||
|
CellChiSqrPage: TTabSheet;
|
||||||
YatesChk: TCheckBox;
|
YatesChk: TCheckBox;
|
||||||
DetailsChk: TCheckBox;
|
DetailsChk: TCheckBox;
|
||||||
ColList: TListBox;
|
ColList: TListBox;
|
||||||
@ -46,15 +51,18 @@ type
|
|||||||
procedure RefGrpClick(Sender: TObject);
|
procedure RefGrpClick(Sender: TObject);
|
||||||
procedure RowInClick(Sender: TObject);
|
procedure RowInClick(Sender: TObject);
|
||||||
procedure RowOutClick(Sender: TObject);
|
procedure RowOutClick(Sender: TObject);
|
||||||
procedure Analyze(RefCol: integer; ColNoSelected: IntDyneVec;
|
|
||||||
RowLabels: StrDyneVec; ColLabels: StrDyneVec;
|
|
||||||
NoToAnalyze: integer; Freq: IntDyneMat;
|
|
||||||
Props: DblDyneMat; NoRows: integer; AReport: TStrings);
|
|
||||||
procedure VarListDblClick(Sender: TObject);
|
procedure VarListDblClick(Sender: TObject);
|
||||||
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||||
|
|
||||||
private
|
private
|
||||||
|
FFrequenciesReportFrame: TReportFrame;
|
||||||
|
FRowColPropsReportFrame: TReportFrame;
|
||||||
|
FCellChiSqrReportFrame: TReportFrame;
|
||||||
|
|
||||||
|
procedure Analyze(RefCol: integer; RowLabels, ColLabels: StrDyneVec;
|
||||||
|
NoToAnalyze: integer; Freq: IntDyneMat; Props: DblDyneMat;
|
||||||
|
NoRows: integer; AReport: TStrings);
|
||||||
|
|
||||||
protected
|
protected
|
||||||
procedure AdjustConstraints; override;
|
procedure AdjustConstraints; override;
|
||||||
procedure Compute; override;
|
procedure Compute; override;
|
||||||
@ -62,6 +70,7 @@ type
|
|||||||
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
|
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
|
||||||
|
|
||||||
public
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure Reset; override;
|
procedure Reset; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -79,6 +88,46 @@ uses
|
|||||||
|
|
||||||
{ TRIDITForm }
|
{ TRIDITForm }
|
||||||
|
|
||||||
|
constructor TRIDITForm.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
FReportFrame.Parent := ResultsPage;
|
||||||
|
|
||||||
|
FFrequenciesReportFrame := TReportFrame.Create(self);
|
||||||
|
FFrequenciesReportFrame.Name := '';
|
||||||
|
FFrequenciesReportFrame.Parent := FrequenciesPage;
|
||||||
|
FFrequenciesReportFrame.Align := alClient;
|
||||||
|
FFrequenciesReportFrame.BorderSpacing.Left := 0;
|
||||||
|
FFrequenciesReportFrame.BorderSpacing.Top := 0;
|
||||||
|
FFrequenciesReportFrame.BorderSpacing.Bottom := 0;
|
||||||
|
FFrequenciesReportFrame.BorderSpacing.Right := 0;
|
||||||
|
InitToolbar(FFrequenciesReportFrame.ReportToolbar, tpRight);
|
||||||
|
|
||||||
|
FRowColPropsReportFrame := TReportFrame.Create(self);
|
||||||
|
FRowColPropsReportFrame.Name := '';
|
||||||
|
FRowColPropsReportFrame.Parent := RowColPropsPage;
|
||||||
|
FRowColPropsReportFrame.Align := alClient;
|
||||||
|
FRowColPropsReportFrame.BorderSpacing.Left := 0;
|
||||||
|
FRowColPropsReportFrame.BorderSpacing.Top := 0;
|
||||||
|
FRowColPropsReportFrame.BorderSpacing.Bottom := 0;
|
||||||
|
FRowColPropsReportFrame.BorderSpacing.Right := 0;
|
||||||
|
InitToolbar(FRowColPropsReportFrame.ReportToolbar, tpRight);
|
||||||
|
|
||||||
|
FCellChiSqrReportFrame := TReportFrame.Create(self);
|
||||||
|
FCellChiSqrReportFrame.Name := '';
|
||||||
|
FCellChiSqrReportFrame.Parent := CellChiSqrPage;
|
||||||
|
FCellChiSqrReportFrame.Align := alClient;
|
||||||
|
FCellChiSqrReportFrame.BorderSpacing.Left := 0;
|
||||||
|
FCellChiSqrReportFrame.BorderSpacing.Top := 0;
|
||||||
|
FCellChiSqrReportFrame.BorderSpacing.Bottom := 0;
|
||||||
|
FCellChiSqrReportFrame.BorderSpacing.Right := 0;
|
||||||
|
InitToolbar(FCellChiSqrReportFrame.ReportToolbar, tpRight);
|
||||||
|
|
||||||
|
PageControl.ActivePageIndex := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TRIDITForm.AdjustConstraints;
|
procedure TRIDITForm.AdjustConstraints;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
@ -95,11 +144,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TRIDITForm.Analyze(RefCol : integer; ColNoSelected : IntDyneVec;
|
procedure TRIDITForm.Analyze(RefCol: integer; RowLabels, ColLabels: StrDyneVec;
|
||||||
RowLabels : StrDyneVec; ColLabels : StrDyneVec;
|
NoToAnalyze: integer; Freq: IntDyneMat; Props: DblDyneMat; NoRows: integer;
|
||||||
NoToAnalyze : integer; Freq : IntDyneMat;
|
AReport: TStrings);
|
||||||
Props : DblDyneMat; NoRows : integer;
|
|
||||||
AReport: TStrings);
|
|
||||||
var
|
var
|
||||||
probdists : DblDyneMat = nil;
|
probdists : DblDyneMat = nil;
|
||||||
refprob : DblDyneMat = nil;
|
refprob : DblDyneMat = nil;
|
||||||
@ -218,10 +265,13 @@ begin
|
|||||||
DynVectorPrint(Cratios, NoToAnalyze, outline, ColLabels, NoCases, AReport);
|
DynVectorPrint(Cratios, NoToAnalyze, outline, ColLabels, NoCases, AReport);
|
||||||
|
|
||||||
alpha := alpha / 2.0;
|
alpha := alpha / 2.0;
|
||||||
if (BonChk.Checked) then alpha := alpha / (NoToAnalyze - 1);
|
if BonChk.Checked then
|
||||||
Bonferroni := InverseZ(1.0 - alpha);
|
begin
|
||||||
AReport.Add('Significance level used for comparisons: %8.3f', [Bonferroni]);
|
alpha := alpha / (NoToAnalyze - 1);
|
||||||
AReport.Add('');
|
Bonferroni := InverseZ(1.0 - alpha);
|
||||||
|
AReport.Add('Significance level used for comparisons: %8.3f', [Bonferroni]);
|
||||||
|
AReport.Add('');
|
||||||
|
end;
|
||||||
|
|
||||||
for i := 0 to NoToAnalyze - 1 do
|
for i := 0 to NoToAnalyze - 1 do
|
||||||
if (i <> RefCol) then
|
if (i <> RefCol) then
|
||||||
@ -312,7 +362,6 @@ var
|
|||||||
AllRefs : boolean;
|
AllRefs : boolean;
|
||||||
i, j, RowNo, RefColNo, NoToAnalyze : integer;
|
i, j, RowNo, RefColNo, NoToAnalyze : integer;
|
||||||
Row, Col, Ncases, Nrows, Ncols, df : integer;
|
Row, Col, Ncases, Nrows, Ncols, df : integer;
|
||||||
outline : string;
|
|
||||||
ChiSquare, ProbChi : double;
|
ChiSquare, ProbChi : double;
|
||||||
yates : boolean;
|
yates : boolean;
|
||||||
Adjchisqr, Adjprobchi: double;
|
Adjchisqr, Adjprobchi: double;
|
||||||
@ -349,8 +398,7 @@ begin
|
|||||||
ColNoSelected[i+1] := GetVariableIndex(OS3MainFrm.DataGrid, ColLabels[i]);
|
ColNoSelected[i+1] := GetVariableIndex(OS3MainFrm.DataGrid, ColLabels[i]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Allocate and initialize
|
||||||
// allocate and initialize
|
|
||||||
SetLength(Freq, NRows+1, NCols+1);
|
SetLength(Freq, NRows+1, NCols+1);
|
||||||
SetLength(Prop, NRows+1, NCols+1);
|
SetLength(Prop, NRows+1, NCols+1);
|
||||||
SetLength(Expected, NRows, NCols);
|
SetLength(Expected, NRows, NCols);
|
||||||
@ -361,7 +409,7 @@ begin
|
|||||||
RowLabels[NRows] := 'Total';
|
RowLabels[NRows] := 'Total';
|
||||||
ColLabels[NCols] := 'Total';
|
ColLabels[NCols] := 'Total';
|
||||||
|
|
||||||
// get cell data
|
// Get cell data
|
||||||
NCases := 0;
|
NCases := 0;
|
||||||
for i := 1 to NoCases do
|
for i := 1 to NoCases do
|
||||||
begin
|
begin
|
||||||
@ -393,14 +441,15 @@ begin
|
|||||||
// Then get expected values and cell chi-squares
|
// Then get expected values and cell chi-squares
|
||||||
ChiSquare := 0.0;
|
ChiSquare := 0.0;
|
||||||
Adjchisqr := 0.0;
|
Adjchisqr := 0.0;
|
||||||
yates := YatesChk.Checked and (Nrows = 2) and (Ncols = 2);
|
yates := YatesChk.Checked and (NRows = 2) and (NCols = 2);
|
||||||
if (Nrows > 1) and (Ncols > 1) then
|
|
||||||
|
if (NRows > 1) and (NCols > 1) then
|
||||||
begin
|
begin
|
||||||
for i := 1 to Nrows do
|
for i := 1 to NRows do
|
||||||
begin
|
begin
|
||||||
for j := 1 to Ncols do
|
for j := 1 to NCols do
|
||||||
begin
|
begin
|
||||||
Expected[i-1,j-1] := Freq[Nrows,j-1] * Freq[i-1,Ncols] / Ncases;
|
Expected[i-1,j-1] := Freq[NRows,j-1] * Freq[i-1,NCols] / Ncases;
|
||||||
if (Expected[i-1,j-1] > 0.0) then
|
if (Expected[i-1,j-1] > 0.0) then
|
||||||
CellChi[i-1,j-1] := sqr(Freq[i-1,j-1] - Expected[i-1,j-1])/ Expected[i-1,j-1]
|
CellChi[i-1,j-1] := sqr(Freq[i-1,j-1] - Expected[i-1,j-1])/ Expected[i-1,j-1]
|
||||||
else
|
else
|
||||||
@ -411,22 +460,22 @@ begin
|
|||||||
ChiSquare := ChiSquare + CellChi[i-1,j-1];
|
ChiSquare := ChiSquare + CellChi[i-1,j-1];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
df := (Nrows - 1) * (Ncols - 1);
|
df := (NRows - 1) * (NCols - 1);
|
||||||
|
|
||||||
if yates then // 2 x 2 corrected chi-square
|
if yates then // 2 x 2 corrected chi-square
|
||||||
begin
|
begin
|
||||||
AdjChiSqr := abs((Freq[0,0] * Freq[1,1]) - (Freq[0,1] * Freq[1,0]));
|
AdjChiSqr := abs((Freq[0,0] * Freq[1,1]) - (Freq[0,1] * Freq[1,0]));
|
||||||
AdjChiSqr := sqr(AdjChiSqr - Ncases / 2.0) * Ncases; // numerator
|
AdjChiSqr := sqr(AdjChiSqr - NCases / 2.0) * NCases; // numerator
|
||||||
AdjChiSqr := AdjChiSqr / (Freq[0,2] * Freq[1,2] * Freq[2,0] * Freq[2,1]);
|
AdjChiSqr := AdjChiSqr / (Freq[0,2] * Freq[1,2] * Freq[2,0] * Freq[2,1]);
|
||||||
AdjProbChi := 1.0 - chisquaredprob(AdjChiSqr,df);
|
AdjProbChi := 1.0 - ChiSquaredProb(AdjChiSqr, df);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Nrows = 1) then // equal probability
|
if (NRows = 1) then // equal probability
|
||||||
begin
|
begin
|
||||||
for j := 0 to Ncols - 1 do
|
for j := 0 to NCols - 1 do
|
||||||
begin
|
begin
|
||||||
Expected[0,j] := Ncases / Ncols;
|
Expected[0,j] := NCases / NCols;
|
||||||
if (Expected[0][j] > 0) then
|
if (Expected[0][j] > 0) then
|
||||||
CellChi[0,j] := sqr(Freq[0,j] - Expected[0,j]) / Expected[0,j];
|
CellChi[0,j] := sqr(Freq[0,j] - Expected[0,j]) / Expected[0,j];
|
||||||
ChiSquare := ChiSquare + CellChi[0,j];
|
ChiSquare := ChiSquare + CellChi[0,j];
|
||||||
@ -434,7 +483,7 @@ begin
|
|||||||
df := Ncols - 1;
|
df := Ncols - 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Ncols = 1) then // equal probability
|
if (NCols = 1) then // equal probability
|
||||||
begin
|
begin
|
||||||
for i := 0 to Nrows - 1 do
|
for i := 0 to Nrows - 1 do
|
||||||
begin
|
begin
|
||||||
@ -448,70 +497,99 @@ begin
|
|||||||
|
|
||||||
ProbChi := 1.0 - ChiSquaredProb(ChiSquare, df); // prob. larger chi
|
ProbChi := 1.0 - ChiSquaredProb(ChiSquare, df); // prob. larger chi
|
||||||
|
|
||||||
//Print results to output form
|
// Print results to output form
|
||||||
lReport := TStringList.Create;
|
lReport := TStringList.Create;
|
||||||
try
|
try
|
||||||
|
// Print frequencies tables if requested by user
|
||||||
|
if ObsChk.Checked or ExpChk.Checked then
|
||||||
|
begin
|
||||||
|
FrequenciesPage.TabVisible := true;
|
||||||
|
|
||||||
|
lReport.Add('CHI-SQUARE ANALYSIS RESULTS');
|
||||||
|
lReport.Add('No. of Cases: %d', [Ncases]);
|
||||||
|
|
||||||
|
if ObsChk.Checked then
|
||||||
|
begin
|
||||||
|
IntArrayPrint(Freq, NRows+1, NCols+1, 'Frequencies', RowLabels, ColLabels, 'OBSERVED FREQUENCIES', lReport);
|
||||||
|
if ExpChk.Checked then
|
||||||
|
begin
|
||||||
|
lReport.Add(DIVIDER_SMALL_AUTO);
|
||||||
|
lReport.Add('');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if ExpChk.Checked then
|
||||||
|
MatPrint(Expected, Nrows, Ncols, 'EXPECTED FREQUENCIES', RowLabels, ColLabels, NoCases, lReport);
|
||||||
|
|
||||||
|
FFrequenciesReportFrame.DisplayReport(lReport);
|
||||||
|
lReport.Clear;
|
||||||
|
end else
|
||||||
|
FrequenciesPage.TabVisible := false;
|
||||||
|
|
||||||
|
// Print row/col properties
|
||||||
|
if PropChk.Checked then
|
||||||
|
begin
|
||||||
|
RowColPropsPage.TabVisible := true;
|
||||||
|
|
||||||
|
lReport.Add('CHI-SQUARE ANALYSIS RESULTS');
|
||||||
|
lReport.Add('No. of Cases: %d', [Ncases]);
|
||||||
|
|
||||||
|
for i := 1 to NRows + 1 do
|
||||||
|
begin
|
||||||
|
for j := 1 to NCols do
|
||||||
|
begin
|
||||||
|
if (Freq[i-1,NCols] > 0.0) then
|
||||||
|
Prop[i-1,j-1] := Freq[i-1,j-1] / Freq[i-1,NCols]
|
||||||
|
else
|
||||||
|
Prop[i-1,j-1] := 0.0;
|
||||||
|
end;
|
||||||
|
if (Freq[i-1,NCols] > 0.0) then
|
||||||
|
Prop[i-1,NCols] := 1.0
|
||||||
|
else
|
||||||
|
Prop[i-1,NCols] := 0.0;
|
||||||
|
end;
|
||||||
|
MatPrint(Prop, Nrows+1, Ncols+1, 'ROW PROPORTIONS', RowLabels, ColLabels, NoCases, lReport);
|
||||||
|
|
||||||
|
lReport.Add(DIVIDER_SMALL_AUTO);
|
||||||
|
lReport.Add('');
|
||||||
|
|
||||||
|
for j := 1 to Ncols + 1 do
|
||||||
|
begin
|
||||||
|
for i := 1 to Nrows do
|
||||||
|
begin
|
||||||
|
if (Freq[Nrows,j-1] > 0.0) then
|
||||||
|
Prop[i-1,j-1] := Freq[i-1,j-1] / Freq[Nrows,j-1]
|
||||||
|
else
|
||||||
|
Prop[i-1,j-1] := 0.0;
|
||||||
|
end;
|
||||||
|
if (Freq[Nrows,j-1] > 0.0) then
|
||||||
|
Prop[Nrows,j-1] := 1.0
|
||||||
|
else
|
||||||
|
Prop[Nrows,j-1] := 0.0;
|
||||||
|
end;
|
||||||
|
MatPrint(Prop, Nrows+1, Ncols+1, 'COLUMN PROPORTIONS', RowLabels, ColLabels, NoCases, lReport);
|
||||||
|
|
||||||
|
FRowColPropsReportFrame.DisplayReport(lReport);
|
||||||
|
lReport.Clear;
|
||||||
|
end else
|
||||||
|
RowColPropsPage.TabVisible := false;
|
||||||
|
|
||||||
|
// Print cell chi-sqr values if requested by user
|
||||||
|
if ChiChk.Checked then
|
||||||
|
begin
|
||||||
|
CellChiSqrPage.TabVisible := true;
|
||||||
|
lReport.Add('CHI-SQUARE ANALYSIS RESULTS');
|
||||||
|
lReport.Add('No. of Cases: %d', [Ncases]);
|
||||||
|
MatPrint(CellChi, Nrows, Ncols, 'CHI-SQUARED VALUE FOR CELLS', RowLabels, ColLabels, NoCases, lReport);
|
||||||
|
FCellChiSqrReportFrame.DisplayReport(lReport);
|
||||||
|
lReport.Clear;
|
||||||
|
end else
|
||||||
|
CellChiSqrPage.TabVisible := false;
|
||||||
|
|
||||||
lReport.Add('CHI-SQUARE ANALYSIS RESULTS');
|
lReport.Add('CHI-SQUARE ANALYSIS RESULTS');
|
||||||
lReport.Add('No. of Cases: %d', [Ncases]);
|
lReport.Add('No. of Cases: %d', [Ncases]);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
|
|
||||||
// print tables requested by use
|
|
||||||
if ObsChk.Checked then
|
|
||||||
IntArrayPrint(Freq, Nrows+1, Ncols+1, 'Frequencies', RowLabels, ColLabels, 'OBSERVED FREQUENCIES', lReport);
|
|
||||||
|
|
||||||
if ExpChk.Checked then
|
|
||||||
begin
|
|
||||||
outline := 'EXPECTED FREQUENCIES';
|
|
||||||
MatPrint(Expected, Nrows, Ncols, outline, RowLabels, ColLabels, NoCases, lReport);
|
|
||||||
end;
|
|
||||||
|
|
||||||
for i := 1 to Nrows + 1 do
|
|
||||||
begin
|
|
||||||
for j := 1 to Ncols do
|
|
||||||
begin
|
|
||||||
if (Freq[i-1,Ncols] > 0.0) then
|
|
||||||
Prop[i-1,j-1] := Freq[i-1,j-1] / Freq[i-1,Ncols]
|
|
||||||
else
|
|
||||||
Prop[i-1,j-1] := 0.0;
|
|
||||||
end;
|
|
||||||
if (Freq[i-1,Ncols] > 0.0) then
|
|
||||||
Prop[i-1,Ncols] := 1.0
|
|
||||||
else
|
|
||||||
Prop[i-1,Ncols] := 0.0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if PropChk.Checked then
|
|
||||||
begin
|
|
||||||
outline := 'ROW PROPORTIONS';
|
|
||||||
MatPrint(Prop, Nrows+1, Ncols+1, outline, RowLabels, ColLabels, NoCases, lReport);
|
|
||||||
end;
|
|
||||||
|
|
||||||
for j := 1 to Ncols + 1 do
|
|
||||||
begin
|
|
||||||
for i := 1 to Nrows do
|
|
||||||
begin
|
|
||||||
if (Freq[Nrows,j-1] > 0.0) then
|
|
||||||
Prop[i-1,j-1] := Freq[i-1,j-1] / Freq[Nrows,j-1]
|
|
||||||
else
|
|
||||||
Prop[i-1,j-1] := 0.0;
|
|
||||||
end;
|
|
||||||
if (Freq[Nrows,j-1] > 0.0) then
|
|
||||||
Prop[Nrows,j-1] := 1.0
|
|
||||||
else
|
|
||||||
Prop[Nrows,j-1] := 0.0;
|
|
||||||
end;
|
|
||||||
if (PropChk.Checked) then
|
|
||||||
begin
|
|
||||||
outline := 'COLUMN PROPORTIONS';
|
|
||||||
MatPrint(Prop, Nrows+1, Ncols+1, outline, RowLabels, ColLabels, NoCases, lReport);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if ChiChk.Checked then
|
|
||||||
begin
|
|
||||||
outline := 'CHI-SQUARED VALUE FOR CELLS';
|
|
||||||
MatPrint(CellChi, Nrows, Ncols, outline, RowLabels, ColLabels, NoCases, lReport);
|
|
||||||
end;
|
|
||||||
|
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add( 'Chi-square: %8.3f', [ChiSquare]);
|
lReport.Add( 'Chi-square: %8.3f', [ChiSquare]);
|
||||||
lReport.Add( ' with D.F. %8d', [df]);
|
lReport.Add( ' with D.F. %8d', [df]);
|
||||||
@ -539,7 +617,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
phi := sqrt(ChiSquare / Ncases);
|
phi := sqrt(ChiSquare / Ncases);
|
||||||
lReport.Add('phi correlation: %8.4f', [phi]);
|
lReport.Add('phi correlation: %8.4f', [phi]);
|
||||||
lReport.Add('');
|
|
||||||
|
|
||||||
pearsonr := 0.0;
|
pearsonr := 0.0;
|
||||||
SumX := 0.0;
|
SumX := 0.0;
|
||||||
@ -558,16 +635,13 @@ begin
|
|||||||
pearsonr := pearsonr - (SumX * SumY / Ncases);
|
pearsonr := pearsonr - (SumX * SumY / Ncases);
|
||||||
pearsonr := pearsonr / sqrt(VarX * VarY);
|
pearsonr := pearsonr / sqrt(VarX * VarY);
|
||||||
lReport.Add('Pearson Correlation r: %8.4f', [pearsonr]);
|
lReport.Add('Pearson Correlation r: %8.4f', [pearsonr]);
|
||||||
lReport.Add('');
|
|
||||||
|
|
||||||
MantelHaenszel := (Ncases-1) * (pearsonr * pearsonr);
|
MantelHaenszel := (Ncases-1) * (pearsonr * pearsonr);
|
||||||
MHprob := 1.0 - chisquaredprob(MantelHaenszel,1);
|
MHprob := 1.0 - chisquaredprob(MantelHaenszel,1);
|
||||||
lReport.Add('Mantel-Haenszel Test of Linear Association: %.3f with probability > value %.4f', [MantelHaenszel, MHprob]);
|
lReport.Add('Mantel-Haenszel Test of Linear Association: %.3f with probability > value %.4f', [MantelHaenszel, MHprob]);
|
||||||
lReport.Add('');
|
|
||||||
|
|
||||||
CoefCont := sqrt(ChiSquare / (ChiSquare + Ncases));
|
CoefCont := sqrt(ChiSquare / (ChiSquare + Ncases));
|
||||||
lReport.Add('The coefficient of contingency: %8.3f', [CoefCont]);
|
lReport.Add('The coefficient of contingency: %8.3f', [CoefCont]);
|
||||||
lReport.Add('');
|
|
||||||
|
|
||||||
if (Nrows < Ncols) then
|
if (Nrows < Ncols) then
|
||||||
CramerV := sqrt(ChiSquare / (Ncases * ((Nrows-1))))
|
CramerV := sqrt(ChiSquare / (Ncases * ((Nrows-1))))
|
||||||
@ -577,7 +651,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add('=============================================================================');
|
lReport.Add(DIVIDER_AUTO);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
|
|
||||||
// Now do RIDIT analysis
|
// Now do RIDIT analysis
|
||||||
@ -590,7 +664,13 @@ begin
|
|||||||
for i := 0 to NoToAnalyze - 1 do
|
for i := 0 to NoToAnalyze - 1 do
|
||||||
begin
|
begin
|
||||||
RefColNo := ColNoSelected[i+1] - 2;
|
RefColNo := ColNoSelected[i+1] - 2;
|
||||||
Analyze(RefColNo, ColNoSelected, RowLabels,ColLabels, NoToAnalyze, Freq, Prop, Nrows, lReport);
|
Analyze(RefColNo, RowLabels,ColLabels, NoToAnalyze, Freq, Prop, Nrows, lReport);
|
||||||
|
if i < NoToAnalyze-1 then
|
||||||
|
begin
|
||||||
|
lReport.Add('');
|
||||||
|
lReport.Add(DIVIDER_SMALL_AUTO);
|
||||||
|
lReport.Add('');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
// only one selected reference variable
|
// only one selected reference variable
|
||||||
@ -603,7 +683,7 @@ begin
|
|||||||
for j := 0 to NoToAnalyze - 1 do
|
for j := 0 to NoToAnalyze - 1 do
|
||||||
if (ColNoSelected[j+1] = RefColNo) then RefColNo := j;
|
if (ColNoSelected[j+1] = RefColNo) then RefColNo := j;
|
||||||
|
|
||||||
Analyze(RefColNo, ColNoSelected, RowLabels,ColLabels, NoToAnalyze, Freq, Prop, Nrows, lReport);
|
Analyze(RefColNo, RowLabels,ColLabels, NoToAnalyze, Freq, Prop, Nrows, lReport);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FReportFrame.DisplayReport(lReport);
|
FReportFrame.DisplayReport(lReport);
|
||||||
@ -627,6 +707,17 @@ var
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
|
FrequenciesPage.TabVisible := false;
|
||||||
|
RowColPropsPage.TabVisible := false;
|
||||||
|
CellChiSqrPage.TabVisible := false;
|
||||||
|
|
||||||
|
if FFrequenciesReportFrame <> nil then
|
||||||
|
FFrequenciesReportFrame.Clear;
|
||||||
|
if FRowColPropsReportFrame <> nil then
|
||||||
|
FRowColPropsReportframe.Clear;
|
||||||
|
if FCellChiSqrReportFrame <> nil then
|
||||||
|
FCellChiSqrReportFrame.Clear;
|
||||||
|
|
||||||
VarList.Clear;
|
VarList.Clear;
|
||||||
for i := 1 to NoVariables do
|
for i := 1 to NoVariables do
|
||||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||||
@ -671,7 +762,14 @@ end;
|
|||||||
procedure TRIDITForm.UpdateBtnStates;
|
procedure TRIDITForm.UpdateBtnStates;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
|
if FFrequenciesReportFrame <> nil then
|
||||||
|
FFrequenciesReportFrame.UpdateBtnStates;
|
||||||
|
if FRowColPropsReportFrame <> nil then
|
||||||
|
FRowColPropsReportframe.UpdateBtnStates;
|
||||||
|
if FCellChiSqrReportFrame <> nil then
|
||||||
|
FCellChiSqrReportFrame.UpdateBtnStates;
|
||||||
|
|
||||||
RowIn.Enabled := (VarList.ItemIndex > -1) and (RowEdit.Text = '');
|
RowIn.Enabled := (VarList.ItemIndex > -1) and (RowEdit.Text = '');
|
||||||
RowOut.Enabled := (RowEdit.Text <> '');
|
RowOut.Enabled := (RowEdit.Text <> '');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user