Lazstats: Cleanup

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7396 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-04-21 20:45:15 +00:00
parent 3019ff51ba
commit 21987bd7d9
17 changed files with 125 additions and 92 deletions

View File

@ -116,7 +116,7 @@ var
SSrows, SScols, SSwrows, SSerr, SStot: double;
MSrows, MScols, MSwrows, MSerr, MStot: double;
dfrows, dfcols, dfwrows, dferr, dftot: double;
f1, f2, probf1, GrandMean, Term1, Term2, Term3, Term4: double;
f1, probf1, GrandMean, Term1, Term2, Term3, Term4: double;
r1, r2, r3, r4, X, avgvar, avgcov: double;
determ1, determ2, M2, C2, chi2, prob: double;
errorfound: boolean;
@ -351,7 +351,6 @@ begin
M2 := 0.0;
C2 := 0.0;
chi2 := 0.0;
f2 := 0;
prob := 0.0;
Determ(vcmat,NoSelected,NoSelected,determ1,errorfound);
if determ1 < 0.0 then determ1 := 0.0;

View File

@ -669,8 +669,10 @@ begin
for i := 1 to NoPts do
begin
X := pts[i-1];
if (MeanChk.Checked = true) then covzero := covzero + (X * X)
else covzero := covzero + ((X - mean) * (X - mean));
if (MeanChk.Checked = true) then
covzero := covzero + sqr(X)
else
covzero := covzero + sqr(X - mean);
end;
covzero := covzero / count;

View File

@ -157,7 +157,7 @@ const
SEPARATOR = '===========================================================================';
var
i, j, k, count, a_size, b_size, no_factors, novars, IER: integer;
outline, cellstring, gridstring: string;
cellstring, gridstring: string;
s, m, n, df1, df2, q, w, pcnt_extracted, trace : double;
minroot, critical_prob, Lambda, Pillia : double;
chisqr, HLTrace, chiprob, ftestprob, Roys, f, Hroot : double;

View File

@ -195,7 +195,7 @@ var
PredVars, CntrlVars: IntDyneVec;
MatVars: IntDyneVec;
outline, varstring: string;
i, j, K, L, NCases : integer;
i, j, K, L: integer;
errorcode: boolean;
vtimesw, W1, v: DblDyneMat;
@ -213,7 +213,6 @@ begin
end;
TotNoVars := NoPredVars + NoCntrlVars + 1;
count := NoCases;
NCases := NoCases;
// Allocate space required
SetLength(vtimesw,NoVariables,NoVariables);

View File

@ -576,7 +576,7 @@ var
Title, astr : string;
NewRowMarg,NewColMarg,NewSliceMarg : DblDyneVec;
LogRowMarg, LogColMarg, LogSliceMarg : DblDyneVec;
NewTotal : double;
NewTotal: double = 0.0;
ABLogs, ACLogs, BCLogs : DblDyneMat;
LogTotal, mu, Ysqr : double;
DF : integer;

View File

@ -249,7 +249,7 @@ end;
procedure TTwoWayLogLinFrm.ComputeBtnClick(Sender: TObject);
var
Data : DblDyneMat;
NewData : DblDyneMat;
NewData : DblDyneMat = nil;
Prop : DblDyneMat;
LogData : DblDyneMat;
Expected : DblDyneMat;
@ -262,7 +262,7 @@ var
ColLogs : DblDyneVec;
CellLambdas : DblDyneCube;
Total : double;
NewTotal : double;
NewTotal: double = 0.0;
TotalLogs : double;
mu : double;
row, col : integer;

View File

@ -148,7 +148,7 @@ end;
procedure TCompRelFrm.AllBtnClick(Sender: TObject);
var
i, count : integer;
i: integer;
cellstring : string;
begin
cellstring := '1.0';
@ -171,7 +171,7 @@ var
Weights, Reliabilities, VectProd, means, variances, stddevs: DblDyneVec;
CompRel, numerator, denominator, compscore: double;
colnoselected: IntDyneVec;
outline, cellstring: string;
cellstring: string;
title: string;
RowLabels: StrDyneVec;
lReport: TStrings;
@ -314,6 +314,7 @@ var
cellstring: string;
begin
cellstring := '1.0';
i := 0;
while i < VarList.Items.Count do
begin
if VarList.Selected[i] then
@ -339,6 +340,7 @@ procedure TCompRelFrm.OutBtnClick(Sender: TObject);
var
i: Integer;
begin
i := 0;
while i < ItemList.Items.Count do
begin
if ItemList.Selected[i] then

View File

@ -94,7 +94,7 @@ object DIFFrm: TDIFFrm
Height = 19
Top = 167
Width = 137
Caption = 'Item Char. Curves'
Caption = 'Plot Item Curves'
TabOrder = 7
end
object CountsChk: TCheckBox

View File

@ -1,8 +1,9 @@
// Test file: DIFData.laz
// Data file not 100% clear, bus seems to be: DIFData.laz
// - Reference Group Code: 1
// - Focal Group Code: 2
// - No. of Score Levels: 11
// - Lower/Upper Bounds: 0-3, 4-7, 8-11, 12-15, 16-19, 20-23, 24-27, 28-31, 32-35, 36-39, 40-43
// The result obtained this way match the pdf file.
unit DifUnit;

View File

@ -369,6 +369,7 @@ object PolyDIFFrm: TPolyDIFFrm
BorderSpacing.Right = 8
OnEditingDone = LevelsEditEditingDone
TabOrder = 4
Text = 'LevelsEdit'
end
object GroupBox1: TGroupBox
AnchorSideLeft.Control = GroupBox2
@ -378,7 +379,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom
Left = 0
Height = 51
Top = 307
Top = 328
Width = 188
Anchors = [akTop, akLeft, akRight]
AutoSize = True
@ -471,19 +472,19 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Control = Panel3
AnchorSideRight.Side = asrBottom
Left = 0
Height = 132
Height = 153
Top = 163
Width = 188
AutoSize = True
BorderSpacing.Top = 12
BorderSpacing.Right = 8
Caption = 'Enter Bounds for Levels'
ClientHeight = 112
ClientHeight = 133
ClientWidth = 184
TabOrder = 5
object Panel2: TPanel
Left = 8
Height = 104
Height = 125
Top = 0
Width = 168
AutoSize = True
@ -491,7 +492,7 @@ object PolyDIFFrm: TPolyDIFFrm
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 104
ClientHeight = 125
ClientWidth = 168
TabOrder = 0
object Label6: TLabel
@ -534,7 +535,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Control = LowBoundEdit
Left = 50
Height = 15
Top = 54
Top = 50
Width = 70
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
@ -547,7 +548,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Control = UpBoundEdit
Left = 50
Height = 15
Top = 85
Top = 77
Width = 70
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
@ -572,16 +573,17 @@ object PolyDIFFrm: TPolyDIFFrm
OnChange = LevelScrollChange
end
object LowBoundEdit: TEdit
AnchorSideTop.Control = LevelNoEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 128
Height = 23
Top = 50
Top = 46
Width = 40
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Top = 4
OnEditingDone = LowBoundEditEditingDone
TabOrder = 2
Text = 'LowBoundEdit'
@ -593,14 +595,14 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom
Left = 128
Height = 23
Top = 81
Top = 73
Width = 40
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Top = 4
OnEditingDone = UpBoundEditEditingDone
TabOrder = 3
Text = 'Edit1'
Text = 'UpBoundEdit'
end
object LevelNoEdit: TStaticText
AnchorSideTop.Control = Label8
@ -617,6 +619,22 @@ object PolyDIFFrm: TPolyDIFFrm
BorderStyle = sbsSingle
TabOrder = 1
end
object NextBtn: TButton
AnchorSideTop.Control = UpBoundEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UpBoundEdit
AnchorSideRight.Side = asrBottom
Left = 90
Height = 25
Top = 100
Width = 78
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 4
Caption = 'Next level'
OnClick = NextBtnClick
TabOrder = 4
end
end
end
end

View File

@ -7,6 +7,7 @@
// - Level 1: lower bound 0, upper bound 1
// - Level 2: lower bound 2, upper bound 3
// - Level 3: lower bound 4, upper bound 5
// - Lower/upper bounds: 0-1, 2-3, 4-5
// The results obtained this way match the pdf file.
unit PolyDifUnit;
@ -26,6 +27,7 @@ type
TPolyDIFFrm = class(TForm)
Bevel1: TBevel;
NextBtn: TButton;
GroupBox2: TGroupBox;
HelpBtn: TButton;
LevelNoEdit: TStaticText;
@ -79,6 +81,7 @@ type
procedure LevelScrollChange(Sender: TObject);
procedure LevelsEditEditingDone(Sender: TObject);
procedure LowBoundEditEditingDone(Sender: TObject);
procedure NextBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure UpBoundEditEditingDone(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
@ -147,16 +150,18 @@ end;
procedure TPolyDIFFrm.UpBoundEditEditingDone(Sender: TObject);
var
level: Integer;
n: Integer;
begin
level := StrToInt(LevelNoEdit.Caption) - 1;
Ubounds[level] := StrToInt(UpBoundEdit.Text);
if level + 1 = StrToInt(LevelsEdit.Text) then
if TryStrToInt(UpBoundEdit.Text, n) then
begin
ComputeBtn.Enabled := true;
Ubounds[level] := n;
if level + 1 = StrToInt(LevelsEdit.Text) then
exit;
end;
// LowBoundEdit.Text := IntToStr(UBounds[level]); //IntToStr(Ubounds[level] + 1);
// LowBoundEdit.SetFocus;
if LBounds[level + 1] = -1 then
lBounds[level + 1] := UBounds[level] + 1;
end else
MessageDlg(Format('No valid number in upper bound at level #%d.', [level+1]), mtError, [mbOk], 0);
end;
procedure TPolyDIFFrm.FormActivate(Sender: TObject);
@ -289,17 +294,24 @@ begin
LevelScroll.Max := Max(L - 1, 0);
LevelScroll.Min := 0;
LevelNoEdit.Caption := IntToStr(LevelScroll.Position + 1);
//LevelScroll.Enabled := true;
//LowBoundEdit.SetFocus;
end;
end;
procedure TPolyDIFFrm.LowBoundEditEditingDone(Sender: TObject);
var
level: integer;
n: Integer;
begin
level := LevelScroll.Position;
Lbounds[level] := StrToInt(LowBoundEdit.Text);
if TryStrToInt(LowBoundEdit.Text, n) then
Lbounds[level] := n
else
Messagedlg(Format('No valid number in lower bound at level #%d.', [level+1]), mtError, [mbOK], 0);
end;
procedure TPolyDIFFrm.NextBtnClick(Sender: TObject);
begin
LevelScroll.Position := LevelScroll.Position + 1;
end;
procedure TPolyDIFFrm.AllBtnClick(Sender: TObject);
@ -334,6 +346,7 @@ var
Zc, Vart, BigJ, SumE, SumV, Term1, MY, prob: double;
X, BigDnum, BigDden, BigD, BigDS, Zd, M2, E, VarE, Ti, dftot: double;
loscore, hiscore: integer;
morePlots: Boolean;
lReport: TStrings;
begin
NoItems := ItemsList.Items.Count;
@ -376,7 +389,6 @@ begin
end;
end;
lReport := TStringList.Create;
try
lReport.Add('POLYTOMOUS ITEM DIF ANALYSIS');
@ -491,6 +503,7 @@ begin
lReport.Add('');
// obtain statistics and print frequency in categories for each item
morePlots := true;
for i := 1 to NoItems do
begin
lReport.Add('ITEM ' + IntToStr(i));
@ -631,11 +644,11 @@ begin
lReport.Add(DIVIDER);
lReport.Add('');
if GraphChk.Checked then
if GraphChk.Checked and morePlots then
begin
GraphFrm.nosets := 2;
GraphFrm.nbars := nolevels;
GraphFrm.Heading := 'Level Means';
GraphFrm.Heading := 'Level Means, Item ' + IntToStr(i);
GraphFrm.XTitle := 'Level';
GraphFrm.YTitle := 'Mean';
SetLength(GraphFrm.Ypoints, 2, nolevels+1);
@ -656,7 +669,7 @@ begin
GraphFrm.BackColor := GRAPH_BACK_COLOR;
GraphFrm.WallColor := GRAPH_WALL_COLOR;
GraphFrm.FloorColor := GRAPH_FLOOR_COLOR;
GraphFrm.ShowModal;
morePlots := (GraphFrm.ShowModal = mrOK);
end;
end; // next item

View File

@ -110,7 +110,7 @@ VAR
means, variances, stddevs: DblDyneVec;
determinant, chisquare, probability: double;
i, j, df, p, ncases, colno: integer;
aline, strvalue, title, probvalue, chivalue: string;
title: string;
ColNoSelected: IntDyneVec;
dblvalue: double;
DataGrid: DblDyneMat;

View File

@ -419,8 +419,10 @@ begin
FrmOutPut.ShowModal();
}
// get no. of categories
nocats := 0;
for i := 0 to NoCases do
if ((Deaths[i] > 0) or (Censored[i] > 0)) then nocats := nocats + 1;
if (Deaths[i] > 0) or (Censored[i] > 0) then
nocats := nocats + 1;
SetLength(Time, nocats + 2);
SetLength(AtRisk, nocats + 2);
SetLength(Dead, nocats + 2);

View File

@ -134,7 +134,7 @@ const
var
i, j, GrpVar, MeasVar, mingrp, maxgrp, G, range, grpsize : integer;
oldgrpsize : integer;
X, UCL, LCL, Sigma, UpperSpec, LowerSpec, TargetSpec : double;
X, UCL, LCL, UpperSpec, LowerSpec, TargetSpec : double;
xmin, xmax, GrandMean, GrandSD, semean, D3Value, D4Value : double;
GrandSigma, C4, gamma, B : double;
means, stddev: DblDyneVec;
@ -165,7 +165,6 @@ begin
GrpVar := 1;
MeasVar := 2;
Sigma := 3.0;
UpperSpec := 0.0;
LowerSpec := 0.0;
TargetSpec := 0.0;

View File

@ -406,7 +406,7 @@ begin
x2 := x1 + bwidth;
x3 := x2 + triwidth;
x4 := x1 + triwidth;
y1 := YStart - yoffset - round(ydist);
y1 := YStart - yoffset {%H-}- round(ydist);
y2 := y1 - triheight;
Image1.Canvas.Polygon([Point(x1,y1),Point(x2,y1),Point(x3,y2),Point(x4,y2)]);
end;
@ -643,7 +643,7 @@ begin
y2 := y1 - triheight;
yprop := (YPoints[i-1,j] - YMin) / (YMax - YMin);
ydist := round(yprop * YAxisLength);
y3 := ystart - yoffset - round(ydist);
y3 := ystart - yoffset {%H-}- round(ydist);
y4 := y3 - triheight;
points[0] := Point(x1,y1);
points[1] := Point(x2,y2);
@ -1124,7 +1124,7 @@ begin
x2 := x1 + bwidth;
x3 := x2 + triwidth;
x4 := x1 + triwidth;
y1 := YStart - yoffset - round(ydist);
y1 := YStart - yoffset {%H-}- round(ydist);
y2 := y1 - triheight;
Printer.Canvas.Polygon([Point(x1,y1),Point(x2,y1),Point(x3,y2),Point(x4,y2)]);
end;

View File

@ -95,7 +95,6 @@ var
determ, n3, r1, s8, s9, d2, x, y, mean : double;
linestring : string;
cellstring : string;
singular : boolean;
title : string;
RowLabels: StrDyneVec;
ColLabels: StrDyneVec;
@ -127,7 +126,6 @@ begin
end;
// get determinant of Rho matrix, i.e. check for singularity
singular := FALSE;
for i := 0 to NoVars-1 do
begin
for j := 0 to NoVars - 1 do

View File

@ -1954,7 +1954,7 @@ procedure scatplot(const x, y: DblDyneVec; NoCases: integer;
var
i, j, l, row, xslot : integer;
maxy: double;
incrementx, incrementy, rangex, rangey, swap : double;
incrementx, incrementy, rangex, rangey: double;
plotstring : array[0..51,0..61] of char;
height : integer;
overlap : boolean;