LazStats: Refactor BlkMRUnit like the others. Less hints and warning. Some report layout improvements in MReg() and MReg2().

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7357 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-04-04 23:26:20 +00:00
parent b2de717ce1
commit eac8c9b0a4
17 changed files with 413 additions and 318 deletions

View File

@ -494,7 +494,6 @@ procedure TBNestedAForm.TwoWayPlot;
VAR VAR
plottype, i: integer; plottype, i: integer;
maxmean: double; maxmean: double;
title: string;
XValue : DblDyneVec; XValue : DblDyneVec;
begin begin
case OptionsBox.ItemIndex of case OptionsBox.ItemIndex of

View File

@ -154,7 +154,7 @@ var
errorcode : integer; errorcode : integer;
errcode : boolean; errcode : boolean;
filename : string; filename : string;
cellstring, outline: string; cellstring: string;
Corrs : DblDyneMat; Corrs : DblDyneMat;
Means : DblDyneVec; Means : DblDyneVec;
Variances : DblDyneVec; Variances : DblDyneVec;

View File

@ -509,7 +509,6 @@ end;
procedure TBestRegFrm.Regress(AReport: TStrings); procedure TBestRegFrm.Regress(AReport: TStrings);
var var
i, j: integer; i, j: integer;
outline: string;
begin begin
b_zero := 0.0 ; b_zero := 0.0 ;
ss_reg := 0.0 ; ss_reg := 0.0 ;

View File

@ -97,6 +97,7 @@ object BlkMregFrm: TBlkMregFrm
Constraints.MinHeight = 220 Constraints.MinHeight = 220
ItemHeight = 0 ItemHeight = 0
MultiSelect = True MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 3 TabOrder = 3
end end
object DepInBtn: TBitBtn object DepInBtn: TBitBtn
@ -195,6 +196,7 @@ object BlkMregFrm: TBlkMregFrm
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6 TabOrder = 6
Text = 'DepVar' Text = 'DepVar'
end end
@ -216,6 +218,8 @@ object BlkMregFrm: TBlkMregFrm
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
ItemHeight = 0 ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 10 TabOrder = 10
end end
object BlockNoEdit: TEdit object BlockNoEdit: TEdit
@ -354,84 +358,65 @@ object BlkMregFrm: TBlkMregFrm
end end
end end
object ResetBtn: TButton object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 164 Left = 256
Height = 25 Height = 25
Top = 418 Top = 418
Width = 54 Width = 54
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 12 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Reset' Caption = 'Reset'
OnClick = ResetBtnClick OnClick = ResetBtnClick
TabOrder = 12 TabOrder = 12
end end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 230
Height = 25
Top = 418
Width = 62
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Cancel'
ModalResult = 2
OnClick = CancelBtnClick
TabOrder = 13
end
object ComputeBtn: TButton object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 304 Left = 318
Height = 25 Height = 25
Top = 418 Top = 418
Width = 76 Width = 76
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 12 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Compute' Caption = 'Compute'
OnClick = ComputeBtnClick OnClick = ComputeBtnClick
TabOrder = 14 TabOrder = 13
end end
object ReturnBtn: TButton object CloseBtn: TButton
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 392 Left = 402
Height = 25 Height = 25
Top = 418 Top = 418
Width = 61 Width = 55
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 12 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Return' Caption = 'Close'
ModalResult = 1 ModalResult = 11
TabOrder = 15 TabOrder = 14
end end
object Bevel1: TBevel object Bevel1: TBevel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn AnchorSideBottom.Control = CloseBtn
Left = 0 Left = 0
Height = 8 Height = 8
Top = 402 Top = 402
@ -445,7 +430,7 @@ object BlkMregFrm: TBlkMregFrm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn AnchorSideBottom.Control = CloseBtn
Left = 0 Left = 0
Height = 12 Height = 12
Top = 28 Top = 28

View File

@ -1,3 +1,7 @@
{ File for testing: Longley.laz
- dependent variable: y
- independent variables: the others }
unit BlkMRegUnit; unit BlkMRegUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
@ -19,9 +23,8 @@ type
Bevel1: TBevel; Bevel1: TBevel;
Bevel3: TBevel; Bevel3: TBevel;
ResetBtn: TButton; ResetBtn: TButton;
CancelBtn: TButton;
ComputeBtn: TButton; ComputeBtn: TButton;
ReturnBtn: TButton; CloseBtn: TButton;
CPChkBox: TCheckBox; CPChkBox: TCheckBox;
CovChkBox: TCheckBox; CovChkBox: TCheckBox;
CorrsChkBox: TCheckBox; CorrsChkBox: TCheckBox;
@ -49,7 +52,6 @@ type
BlockList: TListBox; BlockList: TListBox;
VarList: TListBox; VarList: TListBox;
procedure AllBtnClick(Sender: TObject); procedure AllBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject); procedure ComputeBtnClick(Sender: TObject);
procedure DepInBtnClick(Sender: TObject); procedure DepInBtnClick(Sender: TObject);
procedure DepOutBtnClick(Sender: TObject); procedure DepOutBtnClick(Sender: TObject);
@ -60,6 +62,7 @@ type
procedure NextBlkBtnClick(Sender: TObject); procedure NextBlkBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject); procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject); procedure ResetBtnClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private private
{ private declarations } { private declarations }
FAutoSized: Boolean; FAutoSized: Boolean;
@ -67,7 +70,8 @@ type
NoBlocks : integer; NoBlocks : integer;
VarsInBlk : IntDyneVec; VarsInBlk : IntDyneVec;
NoVars : integer; NoVars : integer;
procedure UpdateBtnStates;
function Valid(out AMsg: String; out AControl: TWinControl): Boolean;
public public
{ public declarations } { public declarations }
end; end;
@ -78,39 +82,37 @@ var
implementation implementation
uses uses
Math; Utils, Math;
{ TBlkMregFrm } { TBlkMregFrm }
procedure TBlkMregFrm.ResetBtnClick(Sender: TObject); procedure TBlkMregFrm.ResetBtnClick(Sender: TObject);
VAR i : integer; var
i: integer;
begin begin
BlockList.Items.Clear; BlockList.Items.Clear;
VarList.Items.Clear; VarList.Items.Clear;
BlockNoEdit.Text := '1'; BlockNoEdit.Text := '1';
NoBlocks := 1; NoBlocks := 1;
for i := 1 to NoVariables do for i := 1 to NoVariables do
begin VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end; CPChkBox.Checked := false;
InBtn.Enabled := true; CovChkBox.Checked := false;
OutBtn.Enabled := false; CorrsChkBox.Checked := true;
DepInBtn.Enabled := true; MeansChkBox.Checked := true;
DepOutBtn.Enabled := false; VarChkBox.Checked := false;
CPChkBox.Checked := false; SDChkBox.Checked := true;
CovChkBox.Checked := false; MatSaveChkBox.Checked := false;
CorrsChkBox.Checked := true; PredictChkBox.Checked := false;
MeansChkBox.Checked := true;
VarChkBox.Checked := false;
SDChkBox.Checked := true;
MatSaveChkBox.Checked := false;
PredictChkBox.Checked := false;
// HeteroChk.Checked := false; // HeteroChk.Checked := false;
NoVars := 0;
DepVar.Text := ''; NoVars := 0;
InProb.Text := '0.05'; DepVar.Text := '';
SetLength(BlkVarCols,NoVariables,NoVariables); InProb.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL);
SetLength(VarsInBlk,NoVariables);
SetLength(BlkVarCols,NoVariables,NoVariables);
SetLength(VarsInBlk,NoVariables);
end; end;
procedure TBlkMregFrm.FormActivate(Sender: TObject); procedure TBlkMregFrm.FormActivate(Sender: TObject);
@ -119,11 +121,11 @@ var
begin begin
if FAutoSized then if FAutoSized then
exit; exit;
w := MaxValue([ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w; ResetBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w; ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w; CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := Width; Constraints.MinWidth := Width;
Constraints.MinHeight := Height; Constraints.MinHeight := Height;
@ -134,7 +136,6 @@ end;
procedure TBlkMregFrm.FormCreate(Sender: TObject); procedure TBlkMregFrm.FormCreate(Sender: TObject);
begin begin
Assert(OS3MainFrm <> nil); Assert(OS3MainFrm <> nil);
if OutputFrm = nil then Application.CreateForm(TOutputFrm, OutputFrm);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm); if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
end; end;
@ -144,33 +145,23 @@ begin
end; end;
procedure TBlkMregFrm.AllBtnClick(Sender: TObject); procedure TBlkMregFrm.AllBtnClick(Sender: TObject);
VAR count, index : integer; var
index: integer;
begin begin
count := VarList.Items.Count; for index := 0 to VarList.Items.Count-1 do
for index := 0 to count-1 do BlockList.Items.Add(VarList.Items[index]);
begin VarList.Clear;
BlockList.Items.Add(VarList.Items.Strings[index]); UpdateBtnStates;
end;
VarList.Clear;
end;
procedure TBlkMregFrm.CancelBtnClick(Sender: TObject);
begin
if VarsInBlk <> nil then VarsInBlk := nil;
if BlkVarCols <> nil then BlkVarCols := nil;
Close;
end; end;
procedure TBlkMregFrm.ComputeBtnClick(Sender: TObject); procedure TBlkMregFrm.ComputeBtnClick(Sender: TObject);
Label CleanUp;
var var
i, j, k, errorcode, NCases : integer; i, j, k, errorcode: integer;
NoIndepVars, DepVarCol, NEntered, StepNo : integer; NoIndepVars, DepVarCol, NEntered, StepNo : integer;
R2, df1, df2: double; R2, df1, df2: double;
StdErrEst, F, FProbF, OldR2 : double; StdErrEst, F, FProbF, OldR2 : double;
pdf1, pdf2, probin, prout : double; pdf1, probin, prout : double;
BetaWeights : DblDyneVec; BetaWeights : DblDyneVec;
outline : string;
corrs : DblDyneMat; corrs : DblDyneMat;
Means : DblDyneVec; Means : DblDyneVec;
Variances : DblDyneVec; Variances : DblDyneVec;
@ -184,155 +175,190 @@ var
filename : string; filename : string;
ColEntered : IntDyneVec; ColEntered : IntDyneVec;
constant : double; constant : double;
errcode : boolean = false; errcode: boolean = false;
NCases: Integer = 0;
msg: String;
C: TWinControl;
lReport: TStrings;
begin begin
SetLength(corrs,NoVariables+1,NoVariables+1); if not Valid(msg, C) then
SetLength(IndepInverse,NoVariables,NoVariables); begin
SetLength(Means,NoVariables); C.SetFocus;
SetLength(Variances,NoVariables); MessageDlg(msg, mtError, [mbOK], 0);
SetLength(StdDevs,NoVariables); exit;
SetLength(IndepIndex,NoVariables); end;
SetLength(IndColLabels,NoVariables);
SetLength(IndRowLabels,NoVariables);
SetLength(BetaWeights,NoVariables);
SetLength(Candidate,NoVariables);
SetLength(ColEntered,NoVariables);
NextBlkBtnClick(self); SetLength(corrs,NoVariables+1,NoVariables+1);
probin := StrToFloat(InProb.Text); // probability to include a block SetLength(IndepInverse,NoVariables,NoVariables);
prout := 1.0; SetLength(Means,NoVariables);
OutputFrm.RichEdit.Clear; SetLength(Variances,NoVariables);
// OutputFrm.RichEdit.ParaGraph.Alignment := taLeftJustify; SetLength(StdDevs,NoVariables);
OutputFrm.RichEdit.Lines.Add('Block Entry Multiple Regression by Bill Miller'); SetLength(IndepIndex,NoVariables);
SetLength(IndColLabels,NoVariables);
SetLength(IndRowLabels,NoVariables);
SetLength(BetaWeights,NoVariables);
SetLength(Candidate,NoVariables);
SetLength(ColEntered,NoVariables);
NextBlkBtnClick(self);
probin := StrToFloat(InProb.Text); // probability to include a block
prout := 1.0;
lReport := TStringList.Create;
try
lReport.Add('BLOCK ENTRY MULTIPLE REGRESSION by Bill Miller');
errorcode := 0; errorcode := 0;
{ get dependendent variable column } { get dependendent variable column }
if DepVar.Text = '' then if DepVar.Text = '' then
begin begin
ShowMessage('ERROR! No Dependent variable selected.'); MessageDlg('No Dependent variable selected.', mtError, [mbOK], 0);
goto CleanUp; exit;
end; end;
if BlockList.Items.Count = 0 then
begin
MessageDlg('No independent variables selected.', mtError, [mbOK], 0);
exit;
end;
DepVarCol := 0; DepVarCol := 0;
NoVars := NoVars + 1; NoVars := NoVars + 1;
for j := 1 to NoVariables do for j := 1 to NoVariables do
if DepVar.Text = OS3MainFrm.DataGrid.Cells[j,0] then DepVarCol := j; if DepVar.Text = OS3MainFrm.DataGrid.Cells[j,0] then DepVarCol := j;
R2 := 0.0; R2 := 0.0;
OldR2 := 0.0; OldR2 := 0.0;
pdf1 := 0.0; pdf1 := 0.0;
pdf2 := 0.0; for i := 1 to NoBlocks-1 do
for i := 1 to NoBlocks-1 do Candidate[i-1] := i; Candidate[i-1] := i;
{ Now, complete Mult. Regs by adding blocks in each step } { Now, complete Mult. Regs by adding blocks in each step }
for StepNo := 1 to NoBlocks-1 do for StepNo := 1 to NoBlocks-1 do
begin begin
NEntered := 0; NEntered := 0;
for i := 1 to StepNo do for i := 1 to StepNo do
begin begin
if (Candidate[StepNo-1] <> 0) then if (Candidate[StepNo-1] <> 0) then
begin begin
for j := 1 to VarsInBlk[i-1] do for j := 1 to VarsInBlk[i-1] do
begin begin
NEntered := NEntered + 1; NEntered := NEntered + 1;
ColEntered[NEntered-1] := BlkVarCols[i-1,j-1]; ColEntered[NEntered-1] := BlkVarCols[i-1,j-1];
k := BlkVarCols[i-1,j-1]; k := BlkVarCols[i-1,j-1];
IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0]; IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0];
IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0]; IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0];
end; end;
end; end;
end; end;
NEntered := NEntered + 1; // dependent variable last NEntered := NEntered + 1; // dependent variable last
ColEntered[NEntered-1] := DepVarCol; ColEntered[NEntered-1] := DepVarCol;
IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[DepVarCol,0]; IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[DepVarCol,0];
IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[DepVarCol,0]; IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[DepVarCol,0];
OutputFrm.RichEdit.Lines.Add('');
outline := format('----------------- Trial Block %d Variables Added ------------------',[StepNo]); lReport.Add('');
OutputFrm.RichEdit.Lines.Add(outline); lReport.Add('----------------- Trial Block %d Variables Added ------------------', [StepNo]);
if CPChkBox.Checked = true then if CPChkBox.Checked then
begin begin
title := 'Cross-Products Matrix'; title := 'Cross-Products Matrix';
GridXProd(NEntered,ColEntered,Corrs,errcode,NCases); GridXProd(NEntered,ColEntered,Corrs,errcode,NCases);
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases); MatPrint(Corrs, NEntered, NEntered, title, IndRowLabels, IndColLabels, NCases, lReport);
end; end;
if CovChkBox.Checked = true then
begin if CovChkBox.Checked then
title := 'Variance-Covariance Matrix'; begin
GridCovar(NEntered,ColEntered,Corrs,Means,Variances, title := 'Variance-Covariance Matrix';
StdDevs,errcode,NCases); GridCovar(NEntered, ColEntered, Corrs, Means, Variances, StdDevs, errcode, NCases);
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases); MatPrint(Corrs, NEntered, NEntered, title, IndRowLabels, IndColLabels, NCases, lReport);
end; end;
Correlations(NEntered,ColEntered,Corrs,Means,Variances,
StdDevs,errcode,NCases); Correlations(NEntered, ColEntered, Corrs, Means, Variances, StdDevs, errcode, NCases);
if CorrsChkBox.Checked = true then if CorrsChkBox.Checked then
begin begin
title := 'Product-Moment Correlations Matrix'; title := 'Product-Moment Correlations Matrix';
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases); MatPrint(Corrs, NEntered, NEntered, title, IndRowLabels, IndColLabels, NCases, lReport);
end; end;
if MeansChkBox.Checked then
begin
title := 'Means'; title := 'Means';
if MeansChkBox.Checked = true then DynVectorPrint(Means, NEntered, title, IndColLabels, NCases, lReport);
DynVectorPrint(Means,NEntered,title,IndColLabels,NCases); end;
if VarChkBox.Checked then
begin
title := 'Variances'; title := 'Variances';
if VarChkBox.Checked = true then DynVectorPrint(Variances, NEntered, title, IndColLabels, NCases, lReport);
DynVectorPrint(Variances,NEntered,title,IndColLabels,NCases); end;
if SDChkBox.Checked then
begin
title := 'Standard Deviations'; title := 'Standard Deviations';
if SDChkBox.Checked = true then DynVectorPrint(StdDevs, NEntered, title, IndColLabels, NCases, lReport);
DynVectorPrint(StdDevs,NEntered,title,IndColLabels,NCases); end;
if errorcode > 0 then
begin if errorcode > 0 then
ShowMessage('ERROR! A selected variable has no variability-run aborted.'); begin
goto CleanUp; DisplayReport(lReport);
end; MessageDlg('A selected variable has no variability-run aborted.', mtError,[mbOK], 0);
NoIndepVars := NEntered - 1; exit;
for i := 1 to NoIndepVars do IndepIndex[i-1] := i; end;
MReg2(NCases,NEntered,NoIndepVars,IndepIndex,corrs,IndepInverse,
IndRowLabels,R2,BetaWeights, NoIndepVars := NEntered - 1;
Means,Variances,errorcode,StdErrEst,constant,prout,true, false,false, OutputFrm.RichEdit.Lines); for i := 1 to NoIndepVars do IndepIndex[i-1] := i;
outline := format('Increase in R Squared = %6.3f',[R2-OldR2]);
OutputFrm.RichEdit.Lines.Add(outline); MReg2(NCases,NEntered, NoIndepVars, IndepIndex, corrs, IndepInverse,
df1 := NoIndepVars - pdf1; IndRowLabels, R2, BetaWeights,
df2 := NCases - NoIndepVars - 1; Means, Variances, errorcode, StdErrEst, constant, prout, true, false, false, lReport
F := ((R2 - OldR2) / (1.0 - R2)) * df2 / df1; );
FProbF := probf(F,df1,df2);
outline := format('F = %6.3f with probability = %6.3f',[F,FProbF]); lReport.Add('');
OutputFrm.RichEdit.Lines.Add(outline); lReport.Add('Increase in R Squared: %10.3f', [R2-OldR2]);
if FProbF < probin then
begin df1 := NoIndepVars - pdf1;
outline := format('Block %d met entry requirements',[StepNo]); df2 := NCases - NoIndepVars - 1;
OutputFrm.RichEdit.Lines.Add(outline); F := ((R2 - OldR2) / (1.0 - R2)) * df2 / df1;
end FProbF := probf(F, df1, df2);
else lReport.Add('F: %26.3f', [F]);
begin lReport.Add('with probability %10.3f', [FProbF]);
Candidate[StepNo-1] := 0; if FProbF < probin then
NoIndepVars := NoIndepVars - VarsInBlk[StepNo-1]; lReport.Add('Block %d met entry requirements', [StepNo])
outline := format('Block %d did not meet entry requirements',[StepNo]); else
OutputFrm.RichEdit.Lines.Add(outline); begin
end; Candidate[StepNo-1] := 0;
OldR2 := R2; NoIndepVars := NoIndepVars - VarsInBlk[StepNo-1];
pdf1 := NoIndepVars; lReport.Add('Block %d did not meet entry requirements', [StepNo]);
end;
OldR2 := R2;
pdf1 := NoIndepVars;
end; end;
{ add [predicted scores, residual scores, etc. to grid if options elected } { add [predicted scores, residual scores, etc. to grid if options elected }
if PredictChkBox.Checked = true then if PredictChkBox.Checked then
begin begin
prout := 1.0; prout := 1.0;
Correlations(NEntered,ColEntered,Corrs,Means,Variances, Correlations(NEntered, ColEntered, Corrs, Means, Variances, StdDevs, errcode, NCases);
StdDevs,errcode,NCases);
MReg2(NCases,NEntered,NoIndepVars,IndepIndex,corrs,IndepInverse, MReg2(NCases, NEntered, NoIndepVars, IndepIndex, corrs, IndepInverse,
IndRowLabels,R2,BetaWeights, IndRowLabels, R2, BetaWeights,
Means,Variances,errorcode,StdErrEst,constant,prout,true, false,false, OutputFrm.RichEdit.Lines); Means, Variances, errorcode, StdErrEst, constant, prout, true, false, false, lReport
);
Predict(ColEntered, NEntered, IndepInverse, Means, StdDevs, Predict(ColEntered, NEntered, IndepInverse, Means, StdDevs,
BetaWeights, StdErrEst, IndepIndex, NoIndepVars); BetaWeights, StdErrEst, IndepIndex, NoIndepVars
end; );
end;
{ if HeteroChk.Checked = true then // do BPG test { if HeteroChk.Checked = true then // do BPG test
begin begin
OutputFrm.RichEdit.Lines.Add(''); lReport.Add('');
OutputFrm.RichEdit.Lines.Add('====================================================='); lReport.Add('=====================================================');
OutputFrm.RichEdit.Lines.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity'); lReport.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity');
OutputFrm.RichEdit.Lines.Add('====================================================='); lReport.Add('=====================================================');
OutputFrm.RichEdit.Lines.Add(''); lReport.Add('');
OutputFrm.RichEdit.Lines.Add('Auxiliary Regression'); lReport.Add('Auxiliary Regression');
OutputFrm.RichEdit.Lines.Add(''); lReport.Add('');
BPG := 0.0; BPG := 0.0;
col := NoVariables + 1; col := NoVariables + 1;
DictionaryFrm.NewVar(col); DictionaryFrm.NewVar(col);
@ -375,41 +401,43 @@ begin
if CorrsChkBox.Checked = true then if CorrsChkBox.Checked = true then
begin begin
title := 'Product-Moment Correlations Matrix'; title := 'Product-Moment Correlations Matrix';
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases); MatPrint(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases, lReport);
end; end;
title := 'Means'; title := 'Means';
if MeansChkBox.Checked = true then if MeansChkBox.Checked = true then
DynVectorPrint(Means,NEntered,title,IndColLabels,NCases); DynVectorPrint(Means,NEntered,title,IndColLabels,NCases, lReport);
title := 'Variances'; title := 'Variances';
if VarChkBox.Checked = true then if VarChkBox.Checked = true then
DynVectorPrint(Variances,NEntered,title,IndColLabels,NCases); DynVectorPrint(Variances,NEntered,title,IndColLabels,NCases, lReport);
title := 'Standard Deviations'; title := 'Standard Deviations';
if SDChkBox.Checked = true then if SDChkBox.Checked = true then
DynVectorPrint(StdDevs,NEntered,title,IndColLabels,NCases); DynVectorPrint(StdDevs,NEntered,title,IndColLabels,NCases, lReport);
MReg2(NCases,NEntered,NoIndepVars,IndepIndex,corrs,IndepInverse, MReg2(NCases,NEntered,NoIndepVars,IndepIndex,corrs,IndepInverse,
IndRowLabels,R2,BetaWeights, IndRowLabels,R2,BetaWeights,
Means,Variances,errorcode,StdErrEst,constant,prout,true, false,false); Means,Variances,errorcode,StdErrEst,constant,prout,true, false,false, lReport);
BPG := ( R2 * Variances[NEntered-1] * (Ncases-1) ) / 2; BPG := ( R2 * Variances[NEntered-1] * (Ncases-1) ) / 2;
chiprob := 1.0 - chisquaredprob(BPG,NEntered-1); chiprob := 1.0 - chisquaredprob(BPG,NEntered-1);
OutputFrm.RichEdit.Lines.Add(''); lReport.Add('');
OutputFrm.RichEdit.Lines.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity'); lReport.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity');
outline := format('Chi-Square = %8.3f with probability greater value = %8.3f',[BPG,chiprob]); lReport.Add('Chi-Square = %8.3f with probability greater value = %8.3f',[BPG,chiprob]);
OutputFrm.RichEdit.Lines.Add(outline); lReport.Add('');
OutputFrm.RichEdit.Lines.Add('');
end; end;
} }
if MatSaveChkBox.Checked = true then DisplayReport(lReport);
if MatSaveChkBox.Checked then
begin begin
SaveDialog1.Filter := 'FreeStat matrix files (*.MAT)|*.MAT|All files (*.*)|*.*'; SaveDialog1.Filter := 'LazStats matrix files (*.mat)|*.mat;*.MAT|All files (*.*)|*.*';
SaveDialog1.FilterIndex := 1; SaveDialog1.FilterIndex := 1;
if SaveDialog1.Execute then if SaveDialog1.Execute then
begin begin
filename := SaveDialog1.FileName; filename := SaveDialog1.FileName;
MATSAVE(Corrs,NoVars,NoVars,Means,StdDevs,NCases,IndRowLabels,IndColLabels,filename); MatSave(Corrs, NoVars, NoVars, Means, StdDevs, NCases, IndRowLabels, IndColLabels, filename);
end; end;
end; end;
OutputFrm.ShowModal;
CleanUp: finally
lReport.Free;
ColEntered := nil; ColEntered := nil;
Candidate := nil; Candidate := nil;
BetaWeights := nil; BetaWeights := nil;
@ -423,86 +451,170 @@ CleanUp:
corrs := nil; corrs := nil;
VarsInBlk := nil; VarsInBlk := nil;
BlkVarCols := nil; BlkVarCols := nil;
end;
end; end;
procedure TBlkMregFrm.DepInBtnClick(Sender: TObject); procedure TBlkMregFrm.DepInBtnClick(Sender: TObject);
VAR index : integer; var
index: integer;
begin begin
index := VarList.ItemIndex; index := VarList.ItemIndex;
DepVar.Text := VarList.Items.Strings[index]; if (index > -1) and (DepVar.Text = '') then
VarList.Items.Delete(index); begin
DepOutBtn.Enabled := true; DepVar.Text := VarList.Items[index];
DepInBtn.Enabled := false; VarList.Items.Delete(index);
end;
UpdateBtnStates;
end; end;
procedure TBlkMregFrm.DepOutBtnClick(Sender: TObject); procedure TBlkMregFrm.DepOutBtnClick(Sender: TObject);
begin begin
VarList.Items.Add(DepVar.Text); if DepVar.Text <> '' then
DepVar.Text := ''; begin
DepInBtn.Enabled := true; VarList.Items.Add(DepVar.Text);
DepVar.Text := '';
end;
UpdateBtnStates;
end; end;
procedure TBlkMregFrm.InBtnClick(Sender: TObject); procedure TBlkMregFrm.InBtnClick(Sender: TObject);
VAR i, index : integer; var
i: integer;
begin begin
index := VarList.Items.Count; i := 0;
i := 0; while i < VarList.Items.Count do
while i < index do begin
begin if VarList.Selected[i] then
if (VarList.Selected[i]) then begin
begin BlockList.Items.Add(VarList.Items[i]);
BlockList.Items.Add(VarList.Items.Strings[i]); VarList.Items.Delete(i);
VarList.Items.Delete(i); i := 0;
index := index - 1; end else
i := 0; i := i + 1;
end end;
else i := i + 1; UpdateBtnStates;
end;
OutBtn.Enabled := true;
end; end;
procedure TBlkMregFrm.NextBlkBtnClick(Sender: TObject); procedure TBlkMregFrm.NextBlkBtnClick(Sender: TObject);
var var
blkno, i, j, count : integer; blkno, i, j, count: integer;
cellstring : string; cellstring: string;
begin begin
{save columns of variables in the current block } {save columns of variables in the current block }
count := BlockList.Items.Count; count := BlockList.Items.Count;
if count = 0 then if count = 0 then
begin begin
VarsInBlk[NoBlocks-1] := 0; VarsInBlk[NoBlocks-1] := 0;
exit; exit;
end; end;
VarsInBlk[NoBlocks-1] := count;
for i := 0 to count-1 do VarsInBlk[NoBlocks-1] := count;
begin for i := 0 to count-1 do
for j := 1 to NoVariables do begin
begin for j := 1 to NoVariables do
cellstring := OS3MainFrm.DataGrid.Cells[j,0]; begin
if cellstring = BlockList.Items.Strings[i] then cellstring := OS3MainFrm.DataGrid.Cells[j,0];
begin if cellstring = BlockList.Items.Strings[i] then
BlkVarCols[NoBlocks-1,i] := j; begin
NoVars := NoVars + 1; BlkVarCols[NoBlocks-1,i] := j;
end; NoVars := NoVars + 1;
end; end;
end; end;
blkno := StrToInt(BlockNoEdit.Text); end;
blkno := blkno + 1;
BlockNoEdit.Text := IntToStr(blkno); blkno := StrToInt(BlockNoEdit.Text);
NoBlocks := blkno; blkno := blkno + 1;
BlockList.Clear; BlockNoEdit.Text := IntToStr(blkno);
NoBlocks := blkno;
//BlockList.Clear;
end; end;
procedure TBlkMregFrm.OutBtnClick(Sender: TObject); procedure TBlkMregFrm.OutBtnClick(Sender: TObject);
VAR index : integer; var
i: integer;
begin begin
index := BlockList.ItemIndex; i := 0;
VarList.Items.Add(BlockList.Items.Strings[index]); while i < BlockList.Items.Count do
BlockList.Items.Delete(index); begin
InBtn.Enabled := true; if BlockList.Selected[i] then
if BlockList.Items.Count = 0 then OutBtn.Enabled := false; begin
VarList.Items.Add(BlockList.Items[i]);
BlockList.Items.Delete(i);
i := 0;
end else
i := i + 1;
end;
UpdateBtnStates;
end; end;
procedure TBlkMregFrm.UpdateBtnStates;
var
lSelected: Boolean;
begin
lSelected := AnySelected(VarList);
DepInBtn.Enabled := lSelected and (DepVar.Text = '');
InBtn.Enabled := lSelected;
DepOutBtn.Enabled := (DepVar.Text <> '');
OutBtn.Enabled := AnySelected(BlockList);
AllBtn.Enabled := VarList.Items.Count > 0;
end;
function TBlkMregFrm.Valid(out AMsg: String; out AControl: TWinControl): Boolean;
var
n: Integer;
x: Double;
begin
Result := false;
if BlockNoEdit.Text = '' then
begin
AControl := BlockNoEdit;
AMsg := 'Block No. not specified.';
exit;
end;
if not TryStrToInt(BlockNoEdit.Text, n) then
begin
AControl := BlockNoEdit;
AMsg := 'Block No. is not a valid integer.';
exit;
end;
if (n <= 0) then
begin
AControl := BlockNoEdit;
AMsg := 'Posivitve value required.';
exit;
end;
if InProb.Text = '' then
begin
AControl := InProb;
AMsg := 'Minimum probability to enter block not specified.';
exit;
end;
if not TryStrToFloat(InProb.Text, x) then
begin
AControl := InProb;
AMsg := 'Minimum probability to enter block is not a valid number.';
exit;
end;
if (x <= 0.0) then
begin
AControl := InProb;
AMsg := 'Positive value required.';
exit;
end;
Result := true;
end;
procedure TBlkMregFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization initialization
{$I blkmregunit.lrs} {$I blkmregunit.lrs}

View File

@ -141,13 +141,12 @@ begin
end; end;
procedure TLSMregForm.ComputeBtnClick(Sender: TObject); procedure TLSMregForm.ComputeBtnClick(Sender: TObject);
Label CleanUp;
var var
i, j, NCases: integer; i, j, NCases: integer;
NoIndepVars, DepVarCol, NEntered: integer; NoIndepVars, DepVarCol, NEntered: integer;
R2, df1, df2: double; R2, df1, df2: double;
StdErrEst, F, FProbF, OldR2 : double; StdErrEst, F, FProbF, OldR2 : double;
pdf1, pdf2, probin, prout : double; pdf1, probin, prout : double;
errorcode : boolean; errorcode : boolean;
BetaWeights : DblDyneVec; BetaWeights : DblDyneVec;
BWeights : DblDyneVec; BWeights : DblDyneVec;
@ -215,7 +214,6 @@ begin
R2 := 0.0; R2 := 0.0;
OldR2 := 0.0; OldR2 := 0.0;
pdf1 := 0.0; pdf1 := 0.0;
pdf2 := 0.0;
NEntered := 0; NEntered := 0;
{ get independendent variable column } { get independendent variable column }

View File

@ -112,7 +112,7 @@ var
StdErr, df1, df2, x, determinant : double; StdErr, df1, df2, x, determinant : double;
errorcode : boolean = false; errorcode : boolean = false;
filename : string; filename : string;
cellstring, outline, valstring : string; cellstring, valstring : string;
Corrs : DblDyneMat; Corrs : DblDyneMat;
Means : DblDyneVec; Means : DblDyneVec;
Variances : DblDyneVec; Variances : DblDyneVec;

View File

@ -81,7 +81,6 @@ procedure TBinomialFrm.ComputeBtnClick(Sender: TObject);
var var
p, Q, Probability, z, CorrectedA, SumProb : double; p, Q, Probability, z, CorrectedA, SumProb : double;
A, b, N, X, i: integer; A, b, N, X, i: integer;
outline : string;
lReport: TStrings; lReport: TStrings;
msg: String; msg: String;
C: TWinControl; C: TWinControl;

View File

@ -112,10 +112,10 @@ end;
procedure TCochranQFrm.ComputeBtnClick(Sender: TObject); procedure TCochranQFrm.ComputeBtnClick(Sender: TObject);
var var
i, j, k, col : integer; i, j, k, col: integer;
ColNoSelected : IntDyneVec; ColNoSelected: IntDyneVec;
R1, L1, L2, C1, g1, Q, g2, chiprob : double; R1, L1, L2, C1, g1, Q, g2, chiprob: double;
cellstring, outline : string; cellstring: string;
lReport: TStrings; lReport: TStrings;
begin begin
if SelList.Items.Count = 0 then if SelList.Items.Count = 0 then

View File

@ -153,7 +153,7 @@ Var
RowLabels, ColLabels : StrDyneVec; RowLabels, ColLabels : StrDyneVec;
index : IntDyneVec; index : IntDyneVec;
GrpNo : IntdyneMat; GrpNo : IntdyneMat;
cellstring, outline: string; cellstring: string;
title : string; title : string;
ties : boolean; ties : boolean;
ColNoSelected : IntDyneVec; ColNoSelected : IntDyneVec;

View File

@ -107,7 +107,6 @@ begin
end; end;
procedure TKWAnovaFrm.ComputeBtnClick(Sender: TObject); procedure TKWAnovaFrm.ComputeBtnClick(Sender: TObject);
label cleanup, Check1, Check2;
var var
i, j, k, m, ind_var, dep_var, min_grp, max_grp, group, total_n : integer; i, j, k, m, ind_var, dep_var, min_grp, max_grp, group, total_n : integer;
NoTies, NoTieGroups, nogroups, NoSelected, npairs, n1, n2 : integer; NoTies, NoTieGroups, nogroups, NoSelected, npairs, n1, n2 : integer;
@ -118,7 +117,7 @@ var
Correction, Temp, TieSum, alpha, U, U2, SD, z, prob : double; Correction, Temp, TieSum, alpha, U, U2, SD, z, prob : double;
Ranks, X : DblDyneMat; Ranks, X : DblDyneMat;
RankSums : DblDyneVec; RankSums : DblDyneVec;
cellstring, outline : string; cellstring, outline: string;
lReport: TStrings; lReport: TStrings;
begin begin
// Check for data // Check for data
@ -460,7 +459,6 @@ begin
lReport.Add('%3d %10.3f %5d', [j, RankSums[group], group_count[1]]); lReport.Add('%3d %10.3f %5d', [j, RankSums[group], group_count[1]]);
lReport.Add(''); lReport.Add('');
lReport.Add( 'No. of tied rank groups: %8d', [NoTieGroups]); lReport.Add( 'No. of tied rank groups: %8d', [NoTieGroups]);
lReport.Add(outline);
if (n1 > n2) then largestn := n1 else largestn := n2; if (n1 > n2) then largestn := n1 else largestn := n2;
if (largestn < 20) then if (largestn < 20) then
outline := Format( 'Statistic U: %8.4f',[U]) outline := Format( 'Statistic U: %8.4f',[U])

View File

@ -198,7 +198,6 @@ var
varcols : IntDyneVec; varcols : IntDyneVec;
AtRisk, ProbDie, CumProbLive, StdErr, Up95, Low95 : double; AtRisk, ProbDie, CumProbLive, StdErr, Up95, Low95 : double;
N, P, Q, mu, CI, z : double; N, P, Q, mu, CI, z : double;
outline : string;
begin begin
if ObsStartEdit.Text = '' then if ObsStartEdit.Text = '' then
begin begin

View File

@ -144,7 +144,7 @@ begin
SetLength(selected,noselected); SetLength(selected,noselected);
SetLength(Values,NoCases,noselected+1); SetLength(Values,NoCases,noselected+1);
SetLength(Slopes,NoCases,NoCases); SetLength(Slopes,NoCases,NoCases);
SetLength(RankedQ,NoVars); SetLength(RankedQ,NoVars); // !!!!!!!!!!!!!!!!!!! NoVars is not initialized !!!!!!!!!!!!!!!!!!!!!!
SetLength(Sorted,NoCases); SetLength(Sorted,NoCases);
SetLength(AvgSlopes,NoCases,NoCases); SetLength(AvgSlopes,NoCases,NoCases);

View File

@ -154,7 +154,7 @@ var
DifSigns : IntDyneVec; DifSigns : IntDyneVec;
p, Q, Probability, z, NoDiff, CorrectedA, x1, x2 : double; p, Q, Probability, z, NoDiff, CorrectedA, x1, x2 : double;
SumProb : double; SumProb : double;
cellstring, outline : string; cellstring: string;
lReport: TStrings; lReport: TStrings;
begin begin
if Var1Edit.Text = '' then if Var1Edit.Text = '' then

View File

@ -811,7 +811,9 @@ begin
VarY := VarY / (NCases - 1); VarY := VarY / (NCases - 1);
SDY := sqrt(VarY); SDY := sqrt(VarY);
AReport.Add('Variance Y = %10.3f SSY = %10.3f SDY = %10.3f',[VarY,SSY,SDY]); AReport.Add('Variance Y: %10.3f', [VarY]);
AReport.Add('SSY: %10.3f', [SSY]);
AReport.Add('SDY: %10.3f', [SDY]);
// OutputFrm.ShowModal ; // OutputFrm.ShowModal ;
// augment the matrix // augment the matrix
@ -937,22 +939,24 @@ begin
end; end;
RowLabels[N-1] := 'Intercept'; RowLabels[N-1] := 'Intercept';
AReport.Add(' Variable Beta B Std.Err. t prob VIF TOL'); AReport.Add(' Variable Beta B Std.Err. t prob VIF TOL');
AReport.Add('---------- ---------- ---------- ---------- ---------- ---------- --------- ----------');
Correlations(NoIndep, IndepCols, XTX, Means, Variances, StdDevs, errcode, NCases); Correlations(NoIndep, IndepCols, XTX, Means, Variances, StdDevs, errcode, NCases);
SVDinverse(XTX, NoIndep); SVDinverse(XTX, NoIndep);
for i := 0 to NoIndep do for i := 0 to NoIndep do
begin begin
VIF := XTX[i,i]; VIF := XTX[i,i];
if VIF > 0.0 then TOL := 1.0 / VIF else TOL := 0.0; if VIF > 0.0 then TOL := 1.0 / VIF else TOL := 0.0;
AReport.Add('%10s%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f', [ AReport.Add('%10s %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f', [
RowLabels[i], BetaWeights[i], BWeights[i], BStdErrs[i], Bttests[i], tprobs[i], VIF, TOL RowLabels[i], BetaWeights[i], BWeights[i], BStdErrs[i], Bttests[i], tprobs[i], VIF, TOL
]); ]);
end; end;
AReport.Add(''); AReport.Add('');
AReport.Add('SOURCE DF SS MS F Prob.>F'); AReport.Add('SOURCE DF SS MS F Prob. > F');
AReport.Add('Regression %3d %9.3f %9.3f %6.4f', [N-1, SSreg, SSreg/(N-1), F, Prob]); // df1 AReport.Add('---------- --- -------------- -------------- -------------- ----------');
AReport.Add('Residual %3d %9.3f %9.3f', [(NCases-N), SSres, SSres/(NCases-N)]); // df2 AReport.Add('Regression %3d %14.3f %14.3f %14.4f %10.4', [N-1, SSreg, SSreg/(N-1), F, Prob]); // df1
AReport.Add('Total %3d %9.3f', [NCases-1, SSY]); AReport.Add('Residual %3d %14.3f %14.3f', [(NCases-N), SSres, SSres/(NCases-N)]); // df2
AReport.Add('Total %3d %14.3f', [NCases-1, SSY]);
AReport.Add(''); AReport.Add('');
AReport.Add('R2: %10.4f', [R2]); AReport.Add('R2: %10.4f', [R2]);
@ -1391,10 +1395,11 @@ begin
F := 0.0; F := 0.0;
FProbF := probf(F,df1,df2); FProbF := probf(F,df1,df2);
AReport.Add('SOURCE DF SS MS F Prob.>F'); AReport.Add('SOURCE DF SS MS F Prob. > F');
AReport.Add('Regression %3.0f %9.3f %9.3f %9.3f %9.3f', [df1, SSreg, SSreg/df1, F, FprobF]); AReport.Add('---------- ---- -------------- -------------- -------------- ---------');
AReport.Add('Residual %3.0f %9.3f %9.3f', [df2, SSres, SSres/df2]); AReport.Add('Regression %4.0f %14.3f %14.3f %14.3f %9.3f', [df1, SSreg, SSreg/df1, F, FprobF]);
AReport.Add('Total %3.0f %9.3f', [df3, SSt]); AReport.Add('Residual %4.0f %14.3f %14.3f', [df2, SSres, SSres/df2]);
AReport.Add('Total %4.0f %14.3f', [df3, SSt]);
AReport.Add(''); AReport.Add('');
AdjR2 := 1.0 - (1.0 - R2) * (NCases - 1) / df2; AdjR2 := 1.0 - (1.0 - R2) * (NCases - 1) / df2;
@ -1402,13 +1407,15 @@ begin
begin begin
AReport.Add('Dependent Variable: ' + deplabel); AReport.Add('Dependent Variable: ' + deplabel);
AReport.Add(''); AReport.Add('');
AReport.Add('%8s%10s%10s%12s%5s%5s', ['R', 'R2', 'F', 'Prob.>F', 'DF1', 'DF2']); AReport.Add('%8s %10s %10s %10s %5s %5s', ['R', 'R2', 'F', 'Prob.>F', 'DF1', 'DF2']);
AReport.Add('%8.3f%10.3f%10.3f%10.3f%5.0f%5.0f', [sqrt(R2), R2, F, FProbF, df1, df2]); AReport.Add('-------- ---------- ---------- ---------- ----- -----');
AReport.Add('%8.3f %10.3f %10.3f %10.3f %5.0f %5.0f', [sqrt(R2), R2, F, FProbF, df1, df2]);
AReport.Add('Adjusted R Squared: %10.3f', [AdjR2]); AReport.Add('Adjusted R Squared: %10.3f', [AdjR2]);
AReport.Add(''); AReport.Add('');
AReport.Add('Std. Error of Estimate: %10.3f', [StdErrEst]); AReport.Add('Std. Error of Estimate: %10.3f', [StdErrEst]);
AReport.Add(''); AReport.Add('');
AReport.Add('Variable Beta B Std.Error t Prob.>t VIF TOL'); AReport.Add('Variable Beta B Std.Error t Prob. > t VIF TOL');
Areport.Add('---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------');
end; end;
df1 := 1.0; df1 := 1.0;
@ -1439,7 +1446,7 @@ begin
if PrintIt then if PrintIt then
begin begin
valstring := Format('%10s', [IndRowLabels[i]]); valstring := Format('%10s', [IndRowLabels[i]]);
outline := Format('%10s%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f', outline := Format('%10s %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f',
[valstring, beta ,B, StdErrB, F, FProbF, VIF, TOL]); [valstring, beta ,B, StdErrB, F, FProbF, VIF, TOL]);
if FprobF > ProbOut then if FprobF > ProbOut then
outline := outline + ' Exceeds limit - to be removed.'; outline := outline + ' Exceeds limit - to be removed.';
@ -1523,7 +1530,6 @@ var
i, j, first, last, nflds: integer; i, j, first, last, nflds: integer;
done : boolean; done : boolean;
outline: string; outline: string;
valstring: string;
begin begin
AReport.Add(''); AReport.Add('');
AReport.Add(Title); AReport.Add(Title);