LazStats: Refactor CurSimUnit. Add its pdf to chm help. Some cleanup.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7441 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-05-08 21:31:22 +00:00
parent 4f87712dd6
commit c2da67888c
8 changed files with 376 additions and 286 deletions

Binary file not shown.

View File

@ -125,7 +125,6 @@ var
cumfreq : DblDyneVec;
prank : DblDyneVec;
grpsize : IntDyneVec;
scrgrp : DblDyneVec;
done : boolean;
NoSelected : integer;
ColNoSelected : IntDyneVec;
@ -173,7 +172,7 @@ begin
NoGrps := maxgrp - mingrp + 1;
if NoGrps > 30 then
begin
MessageDlg('Too many groups for meaningful plot.', mtError, [mbOK], 0);
MessageDlg('Too many groups for a meaningful plot.', mtError, [mbOK], 0);
exit;
end;
@ -189,7 +188,6 @@ begin
SetLength(tenpcntile,NoGrps+1);
SetLength(ninetypcntile,NoGrps+1);
SetLength(median,NoGrps+1);
SetLength(scrgrp,NoGrps+1);
// initialize
for j := 1 to NoGrps do
@ -325,7 +323,6 @@ begin
lReport.Free;
// Clean up
scrgrp := nil;
median := nil;
ninetypcntile := nil;
tenpcntile := nil;

View File

@ -81,7 +81,7 @@ var
i, j, btn, nscores: integer;
RawScores: array[0..50] of double;
RawFreq: array[0..50] of double;
temp, X, Y: double;
X: double;
begin
if DistUseGroup.ItemIndex < 0 then
exit;
@ -105,13 +105,9 @@ begin
for i := 1 to ncases - 1 do
begin
for j := i+1 to ncases do
begin
X := RawScores[i-1];
Y := RawScores[j-1];
if RawScores[i-1] < RawScores[j-1] then // switch
Exchange(RawScores[i-1], RawScores[j-1]);
end;
end;
// get frequency of each score
nints := 1;

View File

@ -1589,7 +1589,7 @@ end;
// Call HTML help (.chm file)
// Is is expected that help topics are specified as HelpKeyword (HelpType = htContext).
// Using numeric HelpContext values will crash the application.
function TOS3MainFrm.HelpHandler(Command:word; Data:PtrInt;
function TOS3MainFrm.HelpHandler(Command: Word; Data: PtrInt;
var CallHelp: Boolean): Boolean;
var
topic: UnicodeString;
@ -1599,6 +1599,9 @@ begin
// Don't call regular help
CallHelp := False;
// silence the compiler, function result not needed
Result := true;
end;
{$ENDIF}
{$ENDIF}

View File

@ -3,10 +3,11 @@ object CorSimFrm: TCorSimFrm
Height = 447
Top = 126
Width = 857
HelpType = htKeyword
HelpKeyword = 'BivariateScatterPlot.htm'
Caption = 'Correlation Simulation'
ClientHeight = 447
ClientWidth = 857
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
@ -114,6 +115,7 @@ object CorSimFrm: TCorSimFrm
Height = 23
Top = 2
Width = 43
Alignment = taRightJustify
BorderSpacing.Left = 6
OnKeyPress = MeanXKeyPress
TabOrder = 0
@ -127,6 +129,7 @@ object CorSimFrm: TCorSimFrm
Height = 23
Top = 2
Width = 46
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = MeanYKeyPress
TabOrder = 1
@ -140,6 +143,7 @@ object CorSimFrm: TCorSimFrm
Height = 23
Top = 2
Width = 50
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = SDXKeyPress
TabOrder = 2
@ -153,6 +157,7 @@ object CorSimFrm: TCorSimFrm
Height = 23
Top = 2
Width = 39
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = SDYKeyPress
TabOrder = 3
@ -166,14 +171,15 @@ object CorSimFrm: TCorSimFrm
Height = 23
Top = 2
Width = 44
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = CorrKeyPress
TabOrder = 4
Text = 'Corr'
end
object ComputeBtn: TButton
AnchorSideTop.Control = ReturnBtn
AnchorSideRight.Control = ReturnBtn
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = CloseBtn
Left = 702
Height = 26
Top = 0
@ -182,9 +188,9 @@ object CorSimFrm: TCorSimFrm
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
TabOrder = 6
end
object ReturnBtn: TButton
object CloseBtn: TButton
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Panel1
@ -194,9 +200,9 @@ object CorSimFrm: TCorSimFrm
Top = 0
Width = 66
Anchors = [akTop, akRight]
Caption = 'Return'
ModalResult = 1
TabOrder = 6
Caption = 'Close'
ModalResult = 11
TabOrder = 7
end
object Nobs: TEdit
AnchorSideLeft.Control = Label6
@ -206,9 +212,10 @@ object CorSimFrm: TCorSimFrm
Height = 23
Top = 2
Width = 40
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NobsKeyPress
TabOrder = 7
TabOrder = 5
Text = 'Nobs'
end
end

View File

@ -18,7 +18,7 @@ type
Nobs: TEdit;
Image1: TImage;
Label6: TLabel;
ReturnBtn: TButton;
CloseBtn: TButton;
ComputeBtn: TButton;
Corr: TEdit;
Label5: TLabel;
@ -33,7 +33,6 @@ type
Panel1: TPanel;
procedure ComputeBtnClick(Sender: TObject);
procedure CorrKeyPress(Sender: TObject; var Key: char);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure MeanXKeyPress(Sender: TObject; var Key: char);
procedure MeanYKeyPress(Sender: TObject; var Key: char);
@ -48,7 +47,8 @@ type
x, y: DblDyneVec;
freqx, freqy: IntDyneVec;
N: integer;
procedure plot(Sender: TObject);
procedure Plot;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
public
{ public declarations }
end;
@ -62,31 +62,34 @@ implementation
procedure TCorSimFrm.MeanXKeyPress(Sender: TObject; var Key: char);
begin
if Ord(Key) = 13 then MeanY.SetFocus;
if Key = #13 then MeanY.SetFocus;
end;
procedure TCorSimFrm.CorrKeyPress(Sender: TObject; var Key: char);
begin
if Ord(Key) = 13 then Nobs.SetFocus;
end;
procedure TCorSimFrm.FormCreate(Sender: TObject);
begin
if OutputFrm = nil then
Application.CreateForm(TOutputFrm, OutputFrm);
if Key = #13 then Nobs.SetFocus;
end;
procedure TCorSimFrm.ComputeBtnClick(Sender: TObject);
var
outline : string;
i: integer;
msg: String;
C: TWinControl;
lReport: TStrings;
begin
if not Validate(msg, C) then begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOk], 0);
exit;
end;
N := StrToInt(NObs.Text);
xmean := StrToFloat(MeanX.Text);
ymean := StrToFloat(MeanY.Text);
xsd := StrToFloat(SDX.Text);
ysd := StrToFloat(SDY.Text);
corxy := StrToFloat(Corr.Text);
Randomize;
SetLength(freqx, N + 1);
@ -101,7 +104,7 @@ begin
errvariance := yvariance - predvar;
stderror := sqrt(errvariance);
b := corxy * (ysd / xsd);
constant := ymean - (b * xmean);
constant := ymean - b * xmean;
newxmean := 0.0;
newymean := 0.0;
@ -112,67 +115,77 @@ begin
begin
x[i] := RandG(xmean, xsd);
randomerror := RandG(0.0, stderror);
y[i] := (b * x[i]) + constant + randomerror;
y[i] := b * x[i] + constant + randomerror;
newxmean := newxmean + x[i];
newymean := newymean + y[i];
newxsd := newxsd + (x[i] * x[i]);
newysd := newysd + (y[i] * y[i]);
newcorr := newcorr + (x[i] * y[i]);
newxsd := newxsd + sqr(x[i]);
newysd := newysd + sqr(y[i]);
newcorr := newcorr + x[i] * y[i];
end;
newxsd := newxsd - ((newxmean * newxmean) / N);
newxsd := newxsd / (N - 1.0);
newxsd := newxsd - sqr(newxmean) / N;
newxsd := newxsd / (N - 1);
newxsd := sqrt(newxsd);
newysd := newysd - ((newymean * newymean) / N);
newysd := newysd / (N - 1.0);
newysd := newysd - sqr(newymean) / N;
newysd := newysd / (N - 1);
newysd := sqrt(newysd);
newcorr := newcorr - ((newxmean * newymean) / N);
newcorr := newcorr / (N - 1.0);
newcorr := newcorr - newxmean * newymean / N;
newcorr := newcorr / (N - 1);
newcorr := newcorr / (newxsd * newysd);
newxmean := newxmean / N;
newymean := newymean / N;
newb := newcorr * (newysd / newxsd);
newconstant := newymean - (newb * newxmean);
OutputFrm.RichEdit.Lines.Clear;
outline := 'POPULATION PARAMETERS FOR THE SIMULATION';
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
outline := format('Mean X := %8.3f, Std. Dev. X := %8.3f',[xmean, xsd]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Mean Y := %8.3f, Std. Dev. Y := %8.3f',[ymean, ysd]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Product-Moment Correlation := %8.3f',[corxy]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Regression line slope := %8.3f, constant := %8.3f',
[b, constant]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('');
outline := format('SAMPLE STATISTICS FOR %d OBSERVATIONS FROM THE POPULATION',[N]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
outline := format('Mean X := %8.3f, Std. Dev. X := %8.3f',[newxmean, newxsd]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Mean Y := %8.3f, Std. Dev. Y := %8.3f',[newymean, newysd]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Product-Moment Correlation := %8.3f',[newcorr]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Regression line slope := %8.3f, constant := %8.3f',
[newb, newconstant]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.RichEdit.Lines.Add('');
OutputFrm.RichEdit.Lines.Add('Pair No. X Y');
newconstant := newymean - newb * newxmean;
lReport := TStringList.Create;
try
lReport.Add('POPULATION PARAMETERS FOR THE SIMULATION');
lReport.Add('');
lReport.Add('Mean X: %8.3f', [xmean]);
lReport.Add('Std. Dev. X: %8.3f', [xsd]);
lReport.Add('');
lReport.Add('Mean Y: %8.3f', [ymean]);
lReport.Add('Std. Dev. Y: %8.3f', [ysd]);
lReport.Add('');
lReport.Add('Product-Moment Correlation: %8.3f', [corxy]);
lReport.Add('Regression line slope: %8.3f', [b]);
lReport.Add(' constant: %8.3f', [constant]);
lReport.Add('');
lReport.Add(DIVIDER);
lReport.Add('');
lReport.Add('SAMPLE STATISTICS FOR %d OBSERVATIONS FROM THE POPULATION', [N]);
lReport.Add('');
lReport.Add('Mean X: %8.3f', [newxmean]);
lReport.Add('Std. Dev. X: %8.3f', [newxsd]);
lReport.Add('');
lReport.Add('Mean Y: %8.3f', [newymean]);
lReport.Add('Std. Dev. Y: %8.3f', [newysd]);
lReport.Add('');
lReport.Add('Product-Moment Correlation: %8.3f', [newcorr]);
lReport.Add('Regression line slope: %8.3f', [newb]);
lReport.Add(' constant: %8.3f', [newconstant]);
lReport.Add('');
lReport.Add(DIVIDER);
lReport.Add('');
lReport.Add('Pair No. X Y ');
lReport.Add('-------- --------- ---------');
for i := 1 to N do
begin
outline := format(' %3d %9.3f %9.3f',[i,x[i],y[i]]);
OutputFrm.RichEdit.Lines.Add(outline);
end;
OutputFrm.ShowModal;
plot(self);
lReport.Add(' %4d %8.3f %8.3f', [i, x[i], y[i]]);
DisplayReport(lReport);
Plot();
finally
lReport.Free;
freqx := nil;
freqy := nil;
x := nil;
y := nil;
ReturnBtn.SetFocus;
end;
end;
procedure TCorSimFrm.FormShow(Sender: TObject);
@ -180,7 +193,7 @@ begin
Image1.Canvas.Pen.Color := clBlack;
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
//Image1.Canvas.FloodFill(1,1,clWhite,fsborder);
MeanX.Text := '100';
MeanY.Text := '100';
SDX.Text := '15';
@ -191,25 +204,25 @@ end;
procedure TCorSimFrm.MeanYKeyPress(Sender: TObject; var Key: char);
begin
if Ord(Key) = 13 then SDX.SetFocus;
if Key = #13 then SDX.SetFocus;
end;
procedure TCorSimFrm.NobsKeyPress(Sender: TObject; var Key: char);
begin
if Ord(Key) = 13 then ComputeBtn.SetFocus;
if Key = #13 then ComputeBtn.SetFocus;
end;
procedure TCorSimFrm.SDXKeyPress(Sender: TObject; var Key: char);
begin
if Ord(Key) = 13 then SDY.SetFocus;
if Key = #13 then SDY.SetFocus;
end;
procedure TCorSimFrm.SDYKeyPress(Sender: TObject; var Key: char);
begin
if Ord(Key) = 13 then Corr.SetFocus;
if Key = #13 then Corr.SetFocus;
end;
procedure TCorSimFrm.plot(Sender: TObject);
procedure TCorSimFrm.Plot;
var
minx, maxx, miny, maxy, xincrement, yincrement: double;
predy1, predy2, lowerx, upperx, frange, prop: double;
@ -240,35 +253,35 @@ begin
yoffset := winheight div 5;
xaxislong := winwidth - xoffset- winwidth div 10;
yaxislong := winheight - yoffset - winheight div 10;
Image1.Canvas.Pen.Color := clBlack;
Image1.Canvas.MoveTo(xoffset,yaxislong);
Image1.Canvas.LineTo(winwidth,yaxislong);
Image1.Canvas.MoveTo(xoffset,yaxislong);
Image1.Canvas.LineTo(xoffset,0);
xspacing := xaxislong div 10;
yspacing := yaxislong div 10;
Image1.Canvas.Pen.Color := clBlack;
Image1.Canvas.Line(xoffset, yaxislong, winwidth, yaxislong);
Image1.canvas.Line(xoffset, yaxislong, xoffset, 0);
// do xaxis
for i := 0 to 11 do
begin
Image1.Canvas.MoveTo(xoffset + (i * xspacing),yaxislong);
Image1.Canvas.LineTo(xoffset + (i * xspacing),yaxislong + 10);
charlabel := format('%8.3f',[minx + (i * xincrement)]);
Image1.Canvas.Line(xoffset + i * xspacing, yaxislong, xoffset + i * xspacing, yaxislong + 10);
charlabel := Format('%.3f', [minx + i * xincrement]);
labelwidth := Image1.Canvas.TextWidth(charlabel);
xpos := xoffset + (i * xspacing)-labelwidth div 2;
xpos := xoffset + i * xspacing - labelwidth div 2;
ypos := yaxislong + 12;
Image1.Canvas.TextOut(xpos, ypos, charlabel);
end;
// do yaxis
for i := 0 to 11 do
begin
Image1.Canvas.MoveTo(xoffset, yaxislong - (i * yspacing));
Image1.Canvas.LineTo(xoffset-10,yaxislong - (i * yspacing));
charlabel := format('%8.3f',[miny + (i * yincrement)]);
Image1.Canvas.Line(xoffset, yaxislong - i * yspacing, xoffset-10, yaxislong - i * yspacing);
charlabel := Format('%.3f', [miny + i * yincrement]);
labelwidth := Image1.Canvas.TextWidth(charlabel);
xpos := xoffset - 10 - labelwidth;
ypos := yaxislong - (i * yspacing);
ypos := yaxislong - i * yspacing;
Image1.Canvas.TextOut(xpos, ypos, charlabel);
end;
// plot points
Image1.Canvas.Pen.Color := clRed;
for i := 1 to N do
@ -277,6 +290,7 @@ begin
ypos := round(yaxislong - ((y[i] - miny) / (maxy - miny) * yaxislong));
Image1.Canvas.Ellipse(xpos, ypos, xpos+5, ypos+5);
end;
// draw regression line
Image1.Canvas.Pen.Color := clBlack;
predy1 := newb * minx + newconstant;
@ -285,69 +299,75 @@ begin
xpos2 := xoffset + xaxislong;
ypos1 := round(yaxislong - ((predy1 - miny) / (maxy - miny) * yaxislong));
ypos2 := round(yaxislong - ((predy2 - miny) / (maxy - miny) * yaxislong));
Image1.Canvas.MoveTo(xpos1,ypos1);
Image1.Canvas.LineTo(xpos2,ypos2);
Image1.Canvas.Line(xpos1, ypos1, xpos2, ypos2);
// do x frequency distribution
xincrement := (maxx - minx) / 50.0;
xspacing := xaxislong div 50;
for j := 1 to 51 do freqx[j] := 0;
for j := 1 to 51 do
freqx[j] := 0;
for i := 1 to N do
begin
for j := 1 to 51 do
begin
lowerx := minx + (j * xincrement);
upperx := minx + ((j+1) * xincrement);
if ((x[i] >= lowerx) and (x[i] < upperx)) then freqx[j] := freqx[j] + 1;
lowerx := minx + j * xincrement;
upperx := minx + (j+1) * xincrement;
if (x[i] >= lowerx) and (x[i] < upperx) then
freqx[j] := freqx[j] + 1;
end;
end;
// plot the x frequencies
minfreq := N;
maxfreq := 0;
for j := 1 to 51 do
begin
if (freqx[j] > maxfreq) then maxfreq := freqx[j];
if (freqx[j] < minfreq) then minfreq := freqx[j];
if (freqx[j] > maxfreq) then
maxfreq := freqx[j];
if (freqx[j] < minfreq) then
minfreq := freqx[j];
end;
flength := winheight - (yaxislong + 25) - Panel1.Height;
for j := 1 to 51 do
begin
xpos := xoffset + (j * xspacing);
ypos1 := round(yaxislong + 25 +
((freqx[j] - minfreq)/ (maxfreq-minfreq) * (flength)));
xpos := xoffset + j * xspacing;
ypos1 := round(yaxislong + 25 + (freqx[j] - minfreq)/ (maxfreq-minfreq) * flength);
ypos2 := yaxislong + 25;
Image1.Canvas.MoveTo(xpos,ypos1);
Image1.Canvas.LineTo(xpos,ypos2);
Image1.Canvas.Line(xpos, ypos1, xpos, ypos2);
end;
Image1.Canvas.MoveTo(xoffset,yaxislong+25);
Image1.Canvas.LineTo(winwidth,yaxislong+25);
Image1.Canvas.Line(xoffset, yaxislong+25, winwidth, yaxislong+25);
xpos := 20;
ypos := yaxislong+30;
Image1.Canvas.TextOut(xpos, ypos, 'X DISTRIBUTION');
theight := Image1.Canvas.TextHeight('X');
ypos := ypos + theight;
charlabel := format('correlation := %6.3f',[newcorr]);
charlabel := Format('Correlation: %.3f', [newcorr]);
Image1.Canvas.TextOut(xpos, ypos, charlabel);
ypos := ypos + theight;
charlabel := format('Mean X := %8.3f, Mean Y := %8.3f',[newxmean, newymean]);
charlabel := Format('Mean X: %.3f; Mean Y: %.3f', [newxmean, newymean]);
Image1.Canvas.TextOut(xpos, ypos, charlabel);
charlabel := format('SD X := %8.3f, SD Y := %8.3f',[newxsd, newysd]);
charlabel := Format('SD X: %.3f; SD Y: %.3f', [newxsd, newysd]);
ypos := ypos + theight;
Image1.Canvas.TextOut(xpos,ypos,charlabel);
// do y frequency distribution
yincrement := (maxy-miny) / 50.0;
yspacing := yaxislong div 50;
for j := 1 to 51 do freqy[j] := 0;
for j := 1 to 51 do
freqy[j] := 0;
for i := 1 to N do
begin
for j := 1 to 51 do
begin
lowery := round(miny + (j * yincrement));
lowery := round(miny + j * yincrement);
uppery := round(miny + ((j+1) * yincrement));
if ((y[i] >= lowery) and (y[i] < uppery)) then freqy[j] := freqy[j] + 1;
if (y[i] >= lowery) and (y[i] < uppery) then
freqy[j] := freqy[j] + 1;
end;
end;
// plot the y frequencies
minfreq := N;
maxfreq := 0;
@ -359,19 +379,86 @@ begin
flength := winwidth - (xaxislong + 150);
for j := 1 to 51 do
begin
ypos := yaxislong - (j * yspacing);
ypos := yaxislong - j * yspacing;
frange := maxfreq - minfreq;
prop := (freqy[j] - minfreq) / frange;
xpos1 := round(xoffset - 50 - (prop * flength));
xpos1 := round(xoffset - 50 - prop * flength);
xpos2 := xoffset - 50;
Image1.Canvas.MoveTo(xpos1,ypos);
Image1.Canvas.LineTo(xpos2,ypos);
Image1.Canvas.Line(xpos1, ypos, xpos2, ypos);
end;
Image1.Canvas.MoveTo(xoffset - 50,yaxislong);
Image1.Canvas.LineTo(xoffset - 50,0);
Image1.Canvas.Line(xoffset - 50, yaxislong, xoffset - 50, 0);
Image1.Canvas.TextOut(0,0,'Y DISTRIBUTION');
end;
function TCorSimFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
begin
Result := false;
if (MeanX.Text = '') or (MeanY.Text = '') or
(SDX.Text = '') or (SDY.Text = '') or
(Corr.Text = '') or (NObs.Text = '') then
begin
if MeanX.Text = '' then
AControl := MeanX
else if MeanY.Text = '' then
AControl := MeanY
else if SDX.Text = '' then
AControl := SDX
else if SDY.Text = '' then
AControl := SDY
else if Corr.Text = '' then
AControl := Corr
else if NObs.Text = '' then
AControl := NObs;
AMsg := 'Input cannot be empty.';
exit;
end;
if not TryStrToFloat(MeanX.Text, xMean) then
begin
AControl := MeanX;
AMsg := 'Mean X must be a valid number.';
exit;
end;
if not TryStrToFloat(MeanY.Text, yMean) then
begin
AControl := MeanY;
AMsg := 'Mean Y must be a valid number.';
exit;
end;
if not TryStrToFloat(SDX.Text, xSD) or (xSD <= 0) then
begin
AControl := SDX;
AMsg := 'Std.Dev X must be a valid positive number.';
exit;
end;
if not TryStrToFloat(SDY.Text, ySD) or (ySD <= 0) then
begin
AControl := SDY;
AMsg := 'Std.Dev Y must be a valid positive number.';
exit;
end;
if not TryStrToFloat(Corr.Text, corXY) then
begin
AControl := Corr;
AMsg := 'Correlation XY must be a valid number.';
exit;
end;
if not TryStrToInt(NObs.Text, N) or (N <= 0) then
begin
AControl := NObs;
AMsg := 'Number of observations must be a valid positive integer.';
exit;
end;
Result := true;
end;
initialization
{$I corsimunit.lrs}

View File

@ -78,7 +78,7 @@ procedure MReg(NoIndep : integer;
procedure MReg(NoIndep: integer; const IndepCols: IntDyneVec; DepCol: integer;
const RowLabels: StrDyneVec;
const Means, Variances, StdDevs, BWeights, BetaWeights, BStdErrs, Bttests, tProbs: DblDyneVec;
out R2, StdErrEst: double; out NCases: integer; out ErrorCode: boolean;
out R2, StdErrEst: double; NCases: integer; out ErrorCode: boolean;
PrintAll: boolean; AReport: TStrings);
procedure Dynnonsymroots(var a : DblDyneMat; nv : integer;
@ -699,7 +699,7 @@ end;
procedure MReg(NoIndep: integer; const IndepCols: IntDyneVec; DepCol: integer;
const RowLabels: StrDyneVec;
const Means, Variances, StdDevs, BWeights, BetaWeights, BStdErrs, Bttests, tProbs: DblDyneVec;
out R2, StdErrEst: double; out NCases: integer; out ErrorCode: boolean;
out R2, StdErrEst: double; NCases: integer; out ErrorCode: boolean;
PrintAll: boolean; AReport: TStrings);
var
i, j, N: integer;