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.Bottom = 8
|
||||
ItemHeight = 0
|
||||
OnDblClick = SelectListDblClick
|
||||
OnSelectionChange = SelectListSelectionChange
|
||||
TabOrder = 4
|
||||
end
|
||||
|
@ -42,6 +42,7 @@ type
|
||||
procedure CountVarChkChange(Sender: TObject);
|
||||
procedure InBtnClick(Sender: TObject);
|
||||
procedure OutBtnClick(Sender: TObject);
|
||||
procedure SelectListDblClick(Sender: TObject);
|
||||
procedure SelectListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||
procedure VarListDblClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||
@ -50,20 +51,9 @@ type
|
||||
function ArrayPosition(ANumDims: integer;
|
||||
const Subscripts, DimSize: IntDyneVec): integer;
|
||||
|
||||
procedure UpdateMinMaxGrid;
|
||||
|
||||
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 COMBO(VAR ISET : IntDyneVec;
|
||||
N, M : Integer;
|
||||
VAR LAST : boolean);
|
||||
|
||||
procedure CONF(VAR N : integer; VAR M : integer;
|
||||
VAR MP : integer;
|
||||
@ -71,10 +61,6 @@ type
|
||||
VAR ISET : IntDyneVec; VAR JSET : IntDyneVec;
|
||||
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;
|
||||
NC, NV, IBEG, NVAR, MAX : integer;
|
||||
VAR CONFIG : IntDyneMat;
|
||||
@ -92,11 +78,26 @@ type
|
||||
VAR COORD : IntDyneVec; VAR X : DblDyneVec;
|
||||
VAR Y : DblDyneVec);
|
||||
|
||||
procedure MaxCombos(NumDims: integer; out MM, MP: integer);
|
||||
|
||||
procedure Marginals(NumDims, ArraySize: integer; const Indexes: 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
|
||||
procedure AdjustConstraints; override;
|
||||
procedure Compute; override;
|
||||
@ -161,9 +162,11 @@ begin
|
||||
|
||||
// calculate PriorSizes values
|
||||
for i := 0 to ANumDims - 2 do
|
||||
//for i := 0 to ANumDims - 1 do
|
||||
PriorSizes[i] := 1; // initialize
|
||||
|
||||
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];
|
||||
|
||||
Pos := Subscripts[0] - 1;
|
||||
@ -380,7 +383,7 @@ begin
|
||||
lReport.Add('Total Frequencies: %d', [N]);
|
||||
|
||||
lReport.Add('');
|
||||
lReport.Add(DIVIDER);
|
||||
lReport.Add(DIVIDER_AUTO);
|
||||
lReport.Add('');
|
||||
|
||||
// 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]]);
|
||||
lReport.Add(astr);
|
||||
end;
|
||||
lReport.Add('');
|
||||
|
||||
// Calculate chi-squared and G squared statistics
|
||||
chi2 := 0.0;
|
||||
@ -437,13 +441,13 @@ begin
|
||||
DF := DF * (DimSize[i] - 1);
|
||||
ProbChi2 := 1.0 - ChiSquaredProb(chi2, DF);
|
||||
ProbG2 := 1.0 - ChiSquaredProb(G2, DF);
|
||||
lReport.Add('Chisquare: %10.3f with probability %10.3f (DF %d)', [chi2, ProbChi2, DF]);
|
||||
lReport.Add('G squared: %10.3f with probability %10.3f (DF %d)', [G2, ProbG2, DF]);
|
||||
lReport.Add('Chisquare: %10.3f with probability %.3f (%d degrees of freedom)', [chi2, ProbChi2, DF]);
|
||||
lReport.Add('G squared: %10.3f with probability %.3f (%d degrees of freedom)', [G2, ProbG2, DF]);
|
||||
lReport.Add('');
|
||||
lReport.Add('U (mu) for general loglinear model: %10.2f', [U]);
|
||||
|
||||
lReport.Add('');
|
||||
lReport.Add(DIVIDER);
|
||||
lReport.Add(DIVIDER_AUTO);
|
||||
lReport.Add('');
|
||||
|
||||
// Get log linear model values for each cell
|
||||
@ -479,7 +483,7 @@ begin
|
||||
end;
|
||||
|
||||
lReport.Add('');
|
||||
lReport.Add(DIVIDER);
|
||||
lReport.Add(DIVIDER_AUTO);
|
||||
lReport.Add('');
|
||||
|
||||
// get second order interactions
|
||||
@ -519,7 +523,7 @@ begin
|
||||
end; // next i
|
||||
|
||||
lReport.Add('');
|
||||
lReport.Add(DIVIDER);
|
||||
lReport.Add(DIVIDER_AUTO);
|
||||
lReport.Add('');
|
||||
|
||||
// get maximum no. of interactions in saturated model
|
||||
@ -1085,6 +1089,21 @@ begin
|
||||
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;
|
||||
User: boolean);
|
||||
begin
|
||||
@ -1104,7 +1123,9 @@ end;
|
||||
|
||||
procedure TLogLinScreenForm.UpdateMinMaxGrid;
|
||||
var
|
||||
NumDims, j: Integer;
|
||||
NumDims, i,j, n: Integer;
|
||||
col: Integer;
|
||||
mn, mx: Integer;
|
||||
begin
|
||||
if CountVarChk.Checked then
|
||||
NumDims := SelectList.Count - 1
|
||||
@ -1115,8 +1136,24 @@ begin
|
||||
for j := 1 to MinMaxGrid.RowCount-1 do
|
||||
begin
|
||||
MinMaxGrid.Cells[0, j] := SelectList.Items[j-1];
|
||||
col := GetVariableIndex(OS3MainFrm.DataGrid, Selectlist.Items[j-1]);
|
||||
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;
|
||||
|
||||
@ -1146,6 +1183,7 @@ begin
|
||||
SelectList.Items.Add(VarList.Items[index]);
|
||||
VarList.Items.Delete(index);
|
||||
UpdateBtnStates;
|
||||
UpdateMinMaxGrid;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user