You've already forked lazarus-ccr
LazStats: More improvements in LogLinScreenUnit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7921 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -156,6 +156,7 @@ inherited LogLinScreenForm: TLogLinScreenForm
|
|||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
|
OnDblClick = SelectListDblClick
|
||||||
OnSelectionChange = SelectListSelectionChange
|
OnSelectionChange = SelectListSelectionChange
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
|
@ -42,6 +42,7 @@ type
|
|||||||
procedure CountVarChkChange(Sender: TObject);
|
procedure CountVarChkChange(Sender: TObject);
|
||||||
procedure InBtnClick(Sender: TObject);
|
procedure InBtnClick(Sender: TObject);
|
||||||
procedure OutBtnClick(Sender: TObject);
|
procedure OutBtnClick(Sender: TObject);
|
||||||
|
procedure SelectListDblClick(Sender: TObject);
|
||||||
procedure SelectListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
procedure SelectListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||||
procedure VarListDblClick(Sender: TObject);
|
procedure VarListDblClick(Sender: TObject);
|
||||||
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||||
@ -50,20 +51,9 @@ type
|
|||||||
function ArrayPosition(ANumDims: integer;
|
function ArrayPosition(ANumDims: integer;
|
||||||
const Subscripts, DimSize: IntDyneVec): integer;
|
const Subscripts, DimSize: IntDyneVec): integer;
|
||||||
|
|
||||||
procedure UpdateMinMaxGrid;
|
procedure COMBO(VAR ISET : IntDyneVec;
|
||||||
|
N, M : Integer;
|
||||||
procedure Screen(VAR NVAR : integer;
|
VAR LAST : boolean);
|
||||||
VAR MP : integer; VAR MM : integer;
|
|
||||||
VAR NTAB : integer; VAR TABLE : DblDyneVec;
|
|
||||||
VAR DIM : IntDyneVec; VAR GSQ : DblDyneVec;
|
|
||||||
VAR DGFR : IntDyneVec; VAR PART : DblDyneMat;
|
|
||||||
VAR MARG : DblDyneMat; VAR DFS : IntDyneMat;
|
|
||||||
VAR IP : IntDyneMat; VAR IM : IntDyneMat;
|
|
||||||
VAR ISET : IntDyneVec; VAR JSET : IntDyneVec;
|
|
||||||
VAR CONFIG : IntDyneMat; VAR FIT : DblDyneVec;
|
|
||||||
VAR SIZE : IntDyneVec; VAR COORD : IntDyneVec;
|
|
||||||
VAR X : DblDyneVec; VAR Y : DblDyneVec;
|
|
||||||
VAR IFAULT : integer);
|
|
||||||
|
|
||||||
procedure CONF(VAR N : integer; VAR M : integer;
|
procedure CONF(VAR N : integer; VAR M : integer;
|
||||||
VAR MP : integer;
|
VAR MP : integer;
|
||||||
@ -71,10 +61,6 @@ type
|
|||||||
VAR ISET : IntDyneVec; VAR JSET : IntDyneVec;
|
VAR ISET : IntDyneVec; VAR JSET : IntDyneVec;
|
||||||
VAR IP : IntDyneMat; VAR IM : IntDyneMat; VAR NP : integer);
|
VAR IP : IntDyneMat; VAR IM : IntDyneMat; VAR NP : integer);
|
||||||
|
|
||||||
procedure COMBO(VAR ISET : IntDyneVec;
|
|
||||||
N, M : Integer;
|
|
||||||
VAR LAST : boolean);
|
|
||||||
|
|
||||||
procedure EVAL(VAR IAR : IntDyneMat;
|
procedure EVAL(VAR IAR : IntDyneMat;
|
||||||
NC, NV, IBEG, NVAR, MAX : integer;
|
NC, NV, IBEG, NVAR, MAX : integer;
|
||||||
VAR CONFIG : IntDyneMat;
|
VAR CONFIG : IntDyneMat;
|
||||||
@ -92,11 +78,26 @@ type
|
|||||||
VAR COORD : IntDyneVec; VAR X : DblDyneVec;
|
VAR COORD : IntDyneVec; VAR X : DblDyneVec;
|
||||||
VAR Y : DblDyneVec);
|
VAR Y : DblDyneVec);
|
||||||
|
|
||||||
procedure MaxCombos(NumDims: integer; out MM, MP: integer);
|
|
||||||
|
|
||||||
procedure Marginals(NumDims, ArraySize: integer; const Indexes: IntDyneMat;
|
procedure Marginals(NumDims, ArraySize: integer; const Indexes: IntDyneMat;
|
||||||
const Data: DblDyneVec; const Margins: IntDyneMat);
|
const Data: DblDyneVec; const Margins: IntDyneMat);
|
||||||
|
|
||||||
|
procedure MaxCombos(NumDims: integer; out MM, MP: integer);
|
||||||
|
|
||||||
|
procedure Screen(VAR NVAR : integer;
|
||||||
|
VAR MP : integer; VAR MM : integer;
|
||||||
|
VAR NTAB : integer; VAR TABLE : DblDyneVec;
|
||||||
|
VAR DIM : IntDyneVec; VAR GSQ : DblDyneVec;
|
||||||
|
VAR DGFR : IntDyneVec; VAR PART : DblDyneMat;
|
||||||
|
VAR MARG : DblDyneMat; VAR DFS : IntDyneMat;
|
||||||
|
VAR IP : IntDyneMat; VAR IM : IntDyneMat;
|
||||||
|
VAR ISET : IntDyneVec; VAR JSET : IntDyneVec;
|
||||||
|
VAR CONFIG : IntDyneMat; VAR FIT : DblDyneVec;
|
||||||
|
VAR SIZE : IntDyneVec; VAR COORD : IntDyneVec;
|
||||||
|
VAR X : DblDyneVec; VAR Y : DblDyneVec;
|
||||||
|
VAR IFAULT : integer);
|
||||||
|
|
||||||
|
procedure UpdateMinMaxGrid;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
procedure AdjustConstraints; override;
|
procedure AdjustConstraints; override;
|
||||||
procedure Compute; override;
|
procedure Compute; override;
|
||||||
@ -161,9 +162,11 @@ begin
|
|||||||
|
|
||||||
// calculate PriorSizes values
|
// calculate PriorSizes values
|
||||||
for i := 0 to ANumDims - 2 do
|
for i := 0 to ANumDims - 2 do
|
||||||
|
//for i := 0 to ANumDims - 1 do
|
||||||
PriorSizes[i] := 1; // initialize
|
PriorSizes[i] := 1; // initialize
|
||||||
|
|
||||||
for i := ANumDims - 2 downto 0 do
|
for i := ANumDims - 2 downto 0 do
|
||||||
|
//for i := ANumDims - 1 downto 0 do
|
||||||
for j := 0 to i do PriorSizes[i] := PriorSizes[i] * DimSize[j];
|
for j := 0 to i do PriorSizes[i] := PriorSizes[i] * DimSize[j];
|
||||||
|
|
||||||
Pos := Subscripts[0] - 1;
|
Pos := Subscripts[0] - 1;
|
||||||
@ -380,7 +383,7 @@ begin
|
|||||||
lReport.Add('Total Frequencies: %d', [N]);
|
lReport.Add('Total Frequencies: %d', [N]);
|
||||||
|
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add(DIVIDER);
|
lReport.Add(DIVIDER_AUTO);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
|
|
||||||
// Get Expected cell values
|
// Get Expected cell values
|
||||||
@ -422,6 +425,7 @@ begin
|
|||||||
astr := astr + Format('%10.0f %10.2f %10.3f',[Data[i-1], Expected[i-1], LogM[i-1]]);
|
astr := astr + Format('%10.0f %10.2f %10.3f',[Data[i-1], Expected[i-1], LogM[i-1]]);
|
||||||
lReport.Add(astr);
|
lReport.Add(astr);
|
||||||
end;
|
end;
|
||||||
|
lReport.Add('');
|
||||||
|
|
||||||
// Calculate chi-squared and G squared statistics
|
// Calculate chi-squared and G squared statistics
|
||||||
chi2 := 0.0;
|
chi2 := 0.0;
|
||||||
@ -435,15 +439,15 @@ begin
|
|||||||
DF := 1;
|
DF := 1;
|
||||||
for i := 0 to nDims-1 do
|
for i := 0 to nDims-1 do
|
||||||
DF := DF * (DimSize[i] - 1);
|
DF := DF * (DimSize[i] - 1);
|
||||||
ProbChi2 := 1.0 - ChiSquaredProb(chi2,DF);
|
ProbChi2 := 1.0 - ChiSquaredProb(chi2, DF);
|
||||||
ProbG2 := 1.0 - ChiSquaredProb(G2,DF);
|
ProbG2 := 1.0 - ChiSquaredProb(G2, DF);
|
||||||
lReport.Add('Chisquare: %10.3f with probability %10.3f (DF %d)', [chi2, ProbChi2, DF]);
|
lReport.Add('Chisquare: %10.3f with probability %.3f (%d degrees of freedom)', [chi2, ProbChi2, DF]);
|
||||||
lReport.Add('G squared: %10.3f with probability %10.3f (DF %d)', [G2, ProbG2, DF]);
|
lReport.Add('G squared: %10.3f with probability %.3f (%d degrees of freedom)', [G2, ProbG2, DF]);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add('U (mu) for general loglinear model: %10.2f', [U]);
|
lReport.Add('U (mu) for general loglinear model: %10.2f', [U]);
|
||||||
|
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add(DIVIDER);
|
lReport.Add(DIVIDER_AUTO);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
|
|
||||||
// Get log linear model values for each cell
|
// Get log linear model values for each cell
|
||||||
@ -479,7 +483,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add(DIVIDER);
|
lReport.Add(DIVIDER_AUTO);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
|
|
||||||
// get second order interactions
|
// get second order interactions
|
||||||
@ -519,7 +523,7 @@ begin
|
|||||||
end; // next i
|
end; // next i
|
||||||
|
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
lReport.Add(DIVIDER);
|
lReport.Add(DIVIDER_AUTO);
|
||||||
lReport.Add('');
|
lReport.Add('');
|
||||||
|
|
||||||
// get maximum no. of interactions in saturated model
|
// get maximum no. of interactions in saturated model
|
||||||
@ -1085,6 +1089,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TLogLinScreenForm.SelectListDblClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
index: Integer;
|
||||||
|
begin
|
||||||
|
index := SelectList.ItemIndex;
|
||||||
|
if index > -1 then
|
||||||
|
begin
|
||||||
|
VarList.Items.Add(SelectList.Items[index]);
|
||||||
|
SelectList.Items.Delete(index);
|
||||||
|
UpdateMinMaxGrid;
|
||||||
|
UpdateBtnStates;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TLogLinScreenForm.SelectListSelectionChange(Sender: TObject;
|
procedure TLogLinScreenForm.SelectListSelectionChange(Sender: TObject;
|
||||||
User: boolean);
|
User: boolean);
|
||||||
begin
|
begin
|
||||||
@ -1104,7 +1123,9 @@ end;
|
|||||||
|
|
||||||
procedure TLogLinScreenForm.UpdateMinMaxGrid;
|
procedure TLogLinScreenForm.UpdateMinMaxGrid;
|
||||||
var
|
var
|
||||||
NumDims, j: Integer;
|
NumDims, i,j, n: Integer;
|
||||||
|
col: Integer;
|
||||||
|
mn, mx: Integer;
|
||||||
begin
|
begin
|
||||||
if CountVarChk.Checked then
|
if CountVarChk.Checked then
|
||||||
NumDims := SelectList.Count - 1
|
NumDims := SelectList.Count - 1
|
||||||
@ -1115,8 +1136,24 @@ begin
|
|||||||
for j := 1 to MinMaxGrid.RowCount-1 do
|
for j := 1 to MinMaxGrid.RowCount-1 do
|
||||||
begin
|
begin
|
||||||
MinMaxGrid.Cells[0, j] := SelectList.Items[j-1];
|
MinMaxGrid.Cells[0, j] := SelectList.Items[j-1];
|
||||||
MinMaxGrid.Cells[1, j] := '';
|
col := GetVariableIndex(OS3MainFrm.DataGrid, Selectlist.Items[j-1]);
|
||||||
MinMaxGrid.Cells[2, j] := '';
|
mn := MaxInt;
|
||||||
|
mx := -mn;
|
||||||
|
for i := 1 to OS3MainFrm.DataGrid.RowCount-1 do
|
||||||
|
if TryStrToInt(OS3MainFrm.DataGrid.Cells[col, i], n) then
|
||||||
|
begin
|
||||||
|
if n < mn then mn := n;
|
||||||
|
if n > mx then mx := n;
|
||||||
|
end;
|
||||||
|
if mn = MaxInt then
|
||||||
|
begin
|
||||||
|
MinMaxGrid.Cells[1, j] := '';
|
||||||
|
MinMaxGrid.Cells[2, j] := '';
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
MinMaxGrid.Cells[1, j] := IntToStr(mn);
|
||||||
|
MinMaxGrid.Cells[2, j] := IntToStr(mx);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1146,6 +1183,7 @@ begin
|
|||||||
SelectList.Items.Add(VarList.Items[index]);
|
SelectList.Items.Add(VarList.Items[index]);
|
||||||
VarList.Items.Delete(index);
|
VarList.Items.Delete(index);
|
||||||
UpdateBtnStates;
|
UpdateBtnStates;
|
||||||
|
UpdateMinMaxGrid;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user