You've already forked lazarus-ccr
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:
Binary file not shown.
Binary file not shown.
@ -494,7 +494,6 @@ procedure TBNestedAForm.TwoWayPlot;
|
||||
VAR
|
||||
plottype, i: integer;
|
||||
maxmean: double;
|
||||
title: string;
|
||||
XValue : DblDyneVec;
|
||||
begin
|
||||
case OptionsBox.ItemIndex of
|
||||
|
@ -154,7 +154,7 @@ var
|
||||
errorcode : integer;
|
||||
errcode : boolean;
|
||||
filename : string;
|
||||
cellstring, outline: string;
|
||||
cellstring: string;
|
||||
Corrs : DblDyneMat;
|
||||
Means : DblDyneVec;
|
||||
Variances : DblDyneVec;
|
||||
|
@ -509,7 +509,6 @@ end;
|
||||
procedure TBestRegFrm.Regress(AReport: TStrings);
|
||||
var
|
||||
i, j: integer;
|
||||
outline: string;
|
||||
begin
|
||||
b_zero := 0.0 ;
|
||||
ss_reg := 0.0 ;
|
||||
|
@ -97,6 +97,7 @@ object BlkMregFrm: TBlkMregFrm
|
||||
Constraints.MinHeight = 220
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 3
|
||||
end
|
||||
object DepInBtn: TBitBtn
|
||||
@ -195,6 +196,7 @@ object BlkMregFrm: TBlkMregFrm
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 12
|
||||
ReadOnly = True
|
||||
TabOrder = 6
|
||||
Text = 'DepVar'
|
||||
end
|
||||
@ -216,6 +218,8 @@ object BlkMregFrm: TBlkMregFrm
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 10
|
||||
end
|
||||
object BlockNoEdit: TEdit
|
||||
@ -354,84 +358,65 @@ object BlkMregFrm: TBlkMregFrm
|
||||
end
|
||||
end
|
||||
object ResetBtn: TButton
|
||||
AnchorSideRight.Control = CancelBtn
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 164
|
||||
Left = 256
|
||||
Height = 25
|
||||
Top = 418
|
||||
Width = 54
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 12
|
||||
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
|
||||
AnchorSideRight.Control = ReturnBtn
|
||||
AnchorSideRight.Control = CloseBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 304
|
||||
Left = 318
|
||||
Height = 25
|
||||
Top = 418
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Compute'
|
||||
OnClick = ComputeBtnClick
|
||||
TabOrder = 14
|
||||
TabOrder = 13
|
||||
end
|
||||
object ReturnBtn: TButton
|
||||
object CloseBtn: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 392
|
||||
Left = 402
|
||||
Height = 25
|
||||
Top = 418
|
||||
Width = 61
|
||||
Width = 55
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Return'
|
||||
ModalResult = 1
|
||||
TabOrder = 15
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
TabOrder = 14
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ReturnBtn
|
||||
AnchorSideBottom.Control = CloseBtn
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 402
|
||||
@ -445,7 +430,7 @@ object BlkMregFrm: TBlkMregFrm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ReturnBtn
|
||||
AnchorSideBottom.Control = CloseBtn
|
||||
Left = 0
|
||||
Height = 12
|
||||
Top = 28
|
||||
|
@ -1,3 +1,7 @@
|
||||
{ File for testing: Longley.laz
|
||||
- dependent variable: y
|
||||
- independent variables: the others }
|
||||
|
||||
unit BlkMRegUnit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
@ -19,9 +23,8 @@ type
|
||||
Bevel1: TBevel;
|
||||
Bevel3: TBevel;
|
||||
ResetBtn: TButton;
|
||||
CancelBtn: TButton;
|
||||
ComputeBtn: TButton;
|
||||
ReturnBtn: TButton;
|
||||
CloseBtn: TButton;
|
||||
CPChkBox: TCheckBox;
|
||||
CovChkBox: TCheckBox;
|
||||
CorrsChkBox: TCheckBox;
|
||||
@ -49,7 +52,6 @@ type
|
||||
BlockList: TListBox;
|
||||
VarList: TListBox;
|
||||
procedure AllBtnClick(Sender: TObject);
|
||||
procedure CancelBtnClick(Sender: TObject);
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure DepInBtnClick(Sender: TObject);
|
||||
procedure DepOutBtnClick(Sender: TObject);
|
||||
@ -60,6 +62,7 @@ type
|
||||
procedure NextBlkBtnClick(Sender: TObject);
|
||||
procedure OutBtnClick(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
private
|
||||
{ private declarations }
|
||||
FAutoSized: Boolean;
|
||||
@ -67,7 +70,8 @@ type
|
||||
NoBlocks : integer;
|
||||
VarsInBlk : IntDyneVec;
|
||||
NoVars : integer;
|
||||
|
||||
procedure UpdateBtnStates;
|
||||
function Valid(out AMsg: String; out AControl: TWinControl): Boolean;
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
@ -78,39 +82,37 @@ var
|
||||
implementation
|
||||
|
||||
uses
|
||||
Math;
|
||||
Utils, Math;
|
||||
|
||||
{ TBlkMregFrm }
|
||||
|
||||
procedure TBlkMregFrm.ResetBtnClick(Sender: TObject);
|
||||
VAR i : integer;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
BlockList.Items.Clear;
|
||||
VarList.Items.Clear;
|
||||
BlockNoEdit.Text := '1';
|
||||
NoBlocks := 1;
|
||||
for i := 1 to NoVariables do
|
||||
begin
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
end;
|
||||
InBtn.Enabled := true;
|
||||
OutBtn.Enabled := false;
|
||||
DepInBtn.Enabled := true;
|
||||
DepOutBtn.Enabled := false;
|
||||
CPChkBox.Checked := false;
|
||||
CovChkBox.Checked := false;
|
||||
CorrsChkBox.Checked := true;
|
||||
MeansChkBox.Checked := true;
|
||||
VarChkBox.Checked := false;
|
||||
SDChkBox.Checked := true;
|
||||
MatSaveChkBox.Checked := false;
|
||||
PredictChkBox.Checked := false;
|
||||
BlockList.Items.Clear;
|
||||
VarList.Items.Clear;
|
||||
BlockNoEdit.Text := '1';
|
||||
NoBlocks := 1;
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
|
||||
CPChkBox.Checked := false;
|
||||
CovChkBox.Checked := false;
|
||||
CorrsChkBox.Checked := true;
|
||||
MeansChkBox.Checked := true;
|
||||
VarChkBox.Checked := false;
|
||||
SDChkBox.Checked := true;
|
||||
MatSaveChkBox.Checked := false;
|
||||
PredictChkBox.Checked := false;
|
||||
// HeteroChk.Checked := false;
|
||||
NoVars := 0;
|
||||
DepVar.Text := '';
|
||||
InProb.Text := '0.05';
|
||||
SetLength(BlkVarCols,NoVariables,NoVariables);
|
||||
SetLength(VarsInBlk,NoVariables);
|
||||
|
||||
NoVars := 0;
|
||||
DepVar.Text := '';
|
||||
InProb.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL);
|
||||
|
||||
SetLength(BlkVarCols,NoVariables,NoVariables);
|
||||
SetLength(VarsInBlk,NoVariables);
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.FormActivate(Sender: TObject);
|
||||
@ -119,11 +121,11 @@ var
|
||||
begin
|
||||
if FAutoSized then
|
||||
exit;
|
||||
w := MaxValue([ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
|
||||
|
||||
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
|
||||
ResetBtn.Constraints.MinWidth := w;
|
||||
CancelBtn.Constraints.MinWidth := w;
|
||||
ComputeBtn.Constraints.MinWidth := w;
|
||||
ReturnBtn.Constraints.MinWidth := w;
|
||||
CloseBtn.Constraints.MinWidth := w;
|
||||
|
||||
Constraints.MinWidth := Width;
|
||||
Constraints.MinHeight := Height;
|
||||
@ -134,7 +136,6 @@ end;
|
||||
procedure TBlkMregFrm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Assert(OS3MainFrm <> nil);
|
||||
if OutputFrm = nil then Application.CreateForm(TOutputFrm, OutputFrm);
|
||||
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
|
||||
end;
|
||||
|
||||
@ -144,33 +145,23 @@ begin
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.AllBtnClick(Sender: TObject);
|
||||
VAR count, index : integer;
|
||||
var
|
||||
index: integer;
|
||||
begin
|
||||
count := VarList.Items.Count;
|
||||
for index := 0 to count-1 do
|
||||
begin
|
||||
BlockList.Items.Add(VarList.Items.Strings[index]);
|
||||
end;
|
||||
VarList.Clear;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.CancelBtnClick(Sender: TObject);
|
||||
begin
|
||||
if VarsInBlk <> nil then VarsInBlk := nil;
|
||||
if BlkVarCols <> nil then BlkVarCols := nil;
|
||||
Close;
|
||||
for index := 0 to VarList.Items.Count-1 do
|
||||
BlockList.Items.Add(VarList.Items[index]);
|
||||
VarList.Clear;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.ComputeBtnClick(Sender: TObject);
|
||||
Label CleanUp;
|
||||
var
|
||||
i, j, k, errorcode, NCases : integer;
|
||||
i, j, k, errorcode: integer;
|
||||
NoIndepVars, DepVarCol, NEntered, StepNo : integer;
|
||||
R2, df1, df2: double;
|
||||
StdErrEst, F, FProbF, OldR2 : double;
|
||||
pdf1, pdf2, probin, prout : double;
|
||||
pdf1, probin, prout : double;
|
||||
BetaWeights : DblDyneVec;
|
||||
outline : string;
|
||||
corrs : DblDyneMat;
|
||||
Means : DblDyneVec;
|
||||
Variances : DblDyneVec;
|
||||
@ -184,155 +175,190 @@ var
|
||||
filename : string;
|
||||
ColEntered : IntDyneVec;
|
||||
constant : double;
|
||||
errcode : boolean = false;
|
||||
errcode: boolean = false;
|
||||
NCases: Integer = 0;
|
||||
msg: String;
|
||||
C: TWinControl;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
SetLength(corrs,NoVariables+1,NoVariables+1);
|
||||
SetLength(IndepInverse,NoVariables,NoVariables);
|
||||
SetLength(Means,NoVariables);
|
||||
SetLength(Variances,NoVariables);
|
||||
SetLength(StdDevs,NoVariables);
|
||||
SetLength(IndepIndex,NoVariables);
|
||||
SetLength(IndColLabels,NoVariables);
|
||||
SetLength(IndRowLabels,NoVariables);
|
||||
SetLength(BetaWeights,NoVariables);
|
||||
SetLength(Candidate,NoVariables);
|
||||
SetLength(ColEntered,NoVariables);
|
||||
if not Valid(msg, C) then
|
||||
begin
|
||||
C.SetFocus;
|
||||
MessageDlg(msg, mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
NextBlkBtnClick(self);
|
||||
probin := StrToFloat(InProb.Text); // probability to include a block
|
||||
prout := 1.0;
|
||||
OutputFrm.RichEdit.Clear;
|
||||
// OutputFrm.RichEdit.ParaGraph.Alignment := taLeftJustify;
|
||||
OutputFrm.RichEdit.Lines.Add('Block Entry Multiple Regression by Bill Miller');
|
||||
SetLength(corrs,NoVariables+1,NoVariables+1);
|
||||
SetLength(IndepInverse,NoVariables,NoVariables);
|
||||
SetLength(Means,NoVariables);
|
||||
SetLength(Variances,NoVariables);
|
||||
SetLength(StdDevs,NoVariables);
|
||||
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;
|
||||
|
||||
{ get dependendent variable column }
|
||||
if DepVar.Text = '' then
|
||||
begin
|
||||
ShowMessage('ERROR! No Dependent variable selected.');
|
||||
goto CleanUp;
|
||||
MessageDlg('No Dependent variable selected.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if BlockList.Items.Count = 0 then
|
||||
begin
|
||||
MessageDlg('No independent variables selected.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
DepVarCol := 0;
|
||||
NoVars := NoVars + 1;
|
||||
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;
|
||||
OldR2 := 0.0;
|
||||
pdf1 := 0.0;
|
||||
pdf2 := 0.0;
|
||||
for i := 1 to NoBlocks-1 do Candidate[i-1] := i;
|
||||
for i := 1 to NoBlocks-1 do
|
||||
Candidate[i-1] := i;
|
||||
|
||||
{ Now, complete Mult. Regs by adding blocks in each step }
|
||||
for StepNo := 1 to NoBlocks-1 do
|
||||
begin
|
||||
NEntered := 0;
|
||||
for i := 1 to StepNo do
|
||||
begin
|
||||
if (Candidate[StepNo-1] <> 0) then
|
||||
begin
|
||||
for j := 1 to VarsInBlk[i-1] do
|
||||
begin
|
||||
NEntered := NEntered + 1;
|
||||
ColEntered[NEntered-1] := BlkVarCols[i-1,j-1];
|
||||
k := BlkVarCols[i-1,j-1];
|
||||
IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0];
|
||||
IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
NEntered := NEntered + 1; // dependent variable last
|
||||
ColEntered[NEntered-1] := DepVarCol;
|
||||
IndRowLabels[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]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
if CPChkBox.Checked = true then
|
||||
begin
|
||||
title := 'Cross-Products Matrix';
|
||||
GridXProd(NEntered,ColEntered,Corrs,errcode,NCases);
|
||||
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases);
|
||||
end;
|
||||
if CovChkBox.Checked = true then
|
||||
begin
|
||||
title := 'Variance-Covariance Matrix';
|
||||
GridCovar(NEntered,ColEntered,Corrs,Means,Variances,
|
||||
StdDevs,errcode,NCases);
|
||||
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases);
|
||||
end;
|
||||
Correlations(NEntered,ColEntered,Corrs,Means,Variances,
|
||||
StdDevs,errcode,NCases);
|
||||
if CorrsChkBox.Checked = true then
|
||||
begin
|
||||
title := 'Product-Moment Correlations Matrix';
|
||||
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases);
|
||||
end;
|
||||
NEntered := 0;
|
||||
for i := 1 to StepNo do
|
||||
begin
|
||||
if (Candidate[StepNo-1] <> 0) then
|
||||
begin
|
||||
for j := 1 to VarsInBlk[i-1] do
|
||||
begin
|
||||
NEntered := NEntered + 1;
|
||||
ColEntered[NEntered-1] := BlkVarCols[i-1,j-1];
|
||||
k := BlkVarCols[i-1,j-1];
|
||||
IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0];
|
||||
IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[k,0];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
NEntered := NEntered + 1; // dependent variable last
|
||||
ColEntered[NEntered-1] := DepVarCol;
|
||||
IndRowLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[DepVarCol,0];
|
||||
IndColLabels[NEntered-1] := OS3MainFrm.DataGrid.Cells[DepVarCol,0];
|
||||
|
||||
lReport.Add('');
|
||||
lReport.Add('----------------- Trial Block %d Variables Added ------------------', [StepNo]);
|
||||
if CPChkBox.Checked then
|
||||
begin
|
||||
title := 'Cross-Products Matrix';
|
||||
GridXProd(NEntered,ColEntered,Corrs,errcode,NCases);
|
||||
MatPrint(Corrs, NEntered, NEntered, title, IndRowLabels, IndColLabels, NCases, lReport);
|
||||
end;
|
||||
|
||||
if CovChkBox.Checked then
|
||||
begin
|
||||
title := 'Variance-Covariance Matrix';
|
||||
GridCovar(NEntered, ColEntered, Corrs, Means, Variances, StdDevs, errcode, NCases);
|
||||
MatPrint(Corrs, NEntered, NEntered, title, IndRowLabels, IndColLabels, NCases, lReport);
|
||||
end;
|
||||
|
||||
Correlations(NEntered, ColEntered, Corrs, Means, Variances, StdDevs, errcode, NCases);
|
||||
if CorrsChkBox.Checked then
|
||||
begin
|
||||
title := 'Product-Moment Correlations Matrix';
|
||||
MatPrint(Corrs, NEntered, NEntered, title, IndRowLabels, IndColLabels, NCases, lReport);
|
||||
end;
|
||||
|
||||
if MeansChkBox.Checked then
|
||||
begin
|
||||
title := 'Means';
|
||||
if MeansChkBox.Checked = true then
|
||||
DynVectorPrint(Means,NEntered,title,IndColLabels,NCases);
|
||||
DynVectorPrint(Means, NEntered, title, IndColLabels, NCases, lReport);
|
||||
end;
|
||||
|
||||
if VarChkBox.Checked then
|
||||
begin
|
||||
title := 'Variances';
|
||||
if VarChkBox.Checked = true then
|
||||
DynVectorPrint(Variances,NEntered,title,IndColLabels,NCases);
|
||||
DynVectorPrint(Variances, NEntered, title, IndColLabels, NCases, lReport);
|
||||
end;
|
||||
|
||||
if SDChkBox.Checked then
|
||||
begin
|
||||
title := 'Standard Deviations';
|
||||
if SDChkBox.Checked = true then
|
||||
DynVectorPrint(StdDevs,NEntered,title,IndColLabels,NCases);
|
||||
if errorcode > 0 then
|
||||
begin
|
||||
ShowMessage('ERROR! A selected variable has no variability-run aborted.');
|
||||
goto CleanUp;
|
||||
end;
|
||||
NoIndepVars := NEntered - 1;
|
||||
for i := 1 to NoIndepVars do IndepIndex[i-1] := i;
|
||||
MReg2(NCases,NEntered,NoIndepVars,IndepIndex,corrs,IndepInverse,
|
||||
IndRowLabels,R2,BetaWeights,
|
||||
Means,Variances,errorcode,StdErrEst,constant,prout,true, false,false, OutputFrm.RichEdit.Lines);
|
||||
outline := format('Increase in R Squared = %6.3f',[R2-OldR2]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
df1 := NoIndepVars - pdf1;
|
||||
df2 := NCases - NoIndepVars - 1;
|
||||
F := ((R2 - OldR2) / (1.0 - R2)) * df2 / df1;
|
||||
FProbF := probf(F,df1,df2);
|
||||
outline := format('F = %6.3f with probability = %6.3f',[F,FProbF]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
if FProbF < probin then
|
||||
begin
|
||||
outline := format('Block %d met entry requirements',[StepNo]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
end
|
||||
else
|
||||
begin
|
||||
Candidate[StepNo-1] := 0;
|
||||
NoIndepVars := NoIndepVars - VarsInBlk[StepNo-1];
|
||||
outline := format('Block %d did not meet entry requirements',[StepNo]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
end;
|
||||
OldR2 := R2;
|
||||
pdf1 := NoIndepVars;
|
||||
DynVectorPrint(StdDevs, NEntered, title, IndColLabels, NCases, lReport);
|
||||
end;
|
||||
|
||||
if errorcode > 0 then
|
||||
begin
|
||||
DisplayReport(lReport);
|
||||
MessageDlg('A selected variable has no variability-run aborted.', mtError,[mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
NoIndepVars := NEntered - 1;
|
||||
for i := 1 to NoIndepVars do IndepIndex[i-1] := i;
|
||||
|
||||
MReg2(NCases,NEntered, NoIndepVars, IndepIndex, corrs, IndepInverse,
|
||||
IndRowLabels, R2, BetaWeights,
|
||||
Means, Variances, errorcode, StdErrEst, constant, prout, true, false, false, lReport
|
||||
);
|
||||
|
||||
lReport.Add('');
|
||||
lReport.Add('Increase in R Squared: %10.3f', [R2-OldR2]);
|
||||
|
||||
df1 := NoIndepVars - pdf1;
|
||||
df2 := NCases - NoIndepVars - 1;
|
||||
F := ((R2 - OldR2) / (1.0 - R2)) * df2 / df1;
|
||||
FProbF := probf(F, df1, df2);
|
||||
lReport.Add('F: %26.3f', [F]);
|
||||
lReport.Add('with probability %10.3f', [FProbF]);
|
||||
if FProbF < probin then
|
||||
lReport.Add('Block %d met entry requirements', [StepNo])
|
||||
else
|
||||
begin
|
||||
Candidate[StepNo-1] := 0;
|
||||
NoIndepVars := NoIndepVars - VarsInBlk[StepNo-1];
|
||||
lReport.Add('Block %d did not meet entry requirements', [StepNo]);
|
||||
end;
|
||||
|
||||
OldR2 := R2;
|
||||
pdf1 := NoIndepVars;
|
||||
end;
|
||||
|
||||
{ add [predicted scores, residual scores, etc. to grid if options elected }
|
||||
if PredictChkBox.Checked = true then
|
||||
begin
|
||||
{ add [predicted scores, residual scores, etc. to grid if options elected }
|
||||
if PredictChkBox.Checked then
|
||||
begin
|
||||
prout := 1.0;
|
||||
Correlations(NEntered,ColEntered,Corrs,Means,Variances,
|
||||
StdDevs,errcode,NCases);
|
||||
Correlations(NEntered, ColEntered, Corrs, Means, Variances, StdDevs, errcode, NCases);
|
||||
|
||||
MReg2(NCases,NEntered,NoIndepVars,IndepIndex,corrs,IndepInverse,
|
||||
IndRowLabels,R2,BetaWeights,
|
||||
Means,Variances,errorcode,StdErrEst,constant,prout,true, false,false, OutputFrm.RichEdit.Lines);
|
||||
MReg2(NCases, NEntered, NoIndepVars, IndepIndex, corrs, IndepInverse,
|
||||
IndRowLabels, R2, BetaWeights,
|
||||
Means, Variances, errorcode, StdErrEst, constant, prout, true, false, false, lReport
|
||||
);
|
||||
|
||||
Predict(ColEntered, NEntered, IndepInverse, Means, StdDevs,
|
||||
BetaWeights, StdErrEst, IndepIndex, NoIndepVars);
|
||||
end;
|
||||
BetaWeights, StdErrEst, IndepIndex, NoIndepVars
|
||||
);
|
||||
end;
|
||||
|
||||
{ if HeteroChk.Checked = true then // do BPG test
|
||||
begin
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
OutputFrm.RichEdit.Lines.Add('=====================================================');
|
||||
OutputFrm.RichEdit.Lines.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity');
|
||||
OutputFrm.RichEdit.Lines.Add('=====================================================');
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
OutputFrm.RichEdit.Lines.Add('Auxiliary Regression');
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
lReport.Add('');
|
||||
lReport.Add('=====================================================');
|
||||
lReport.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity');
|
||||
lReport.Add('=====================================================');
|
||||
lReport.Add('');
|
||||
lReport.Add('Auxiliary Regression');
|
||||
lReport.Add('');
|
||||
BPG := 0.0;
|
||||
col := NoVariables + 1;
|
||||
DictionaryFrm.NewVar(col);
|
||||
@ -375,41 +401,43 @@ begin
|
||||
if CorrsChkBox.Checked = true then
|
||||
begin
|
||||
title := 'Product-Moment Correlations Matrix';
|
||||
MAT_PRINT(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases);
|
||||
MatPrint(Corrs,NEntered,NEntered,title,IndRowLabels,IndColLabels,NCases, lReport);
|
||||
end;
|
||||
title := 'Means';
|
||||
if MeansChkBox.Checked = true then
|
||||
DynVectorPrint(Means,NEntered,title,IndColLabels,NCases);
|
||||
DynVectorPrint(Means,NEntered,title,IndColLabels,NCases, lReport);
|
||||
title := 'Variances';
|
||||
if VarChkBox.Checked = true then
|
||||
DynVectorPrint(Variances,NEntered,title,IndColLabels,NCases);
|
||||
DynVectorPrint(Variances,NEntered,title,IndColLabels,NCases, lReport);
|
||||
title := 'Standard Deviations';
|
||||
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,
|
||||
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;
|
||||
chiprob := 1.0 - chisquaredprob(BPG,NEntered-1);
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
OutputFrm.RichEdit.Lines.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity');
|
||||
outline := format('Chi-Square = %8.3f with probability greater value = %8.3f',[BPG,chiprob]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
lReport.Add('');
|
||||
lReport.Add('Breusch-Pagan-Godfrey Test of Heteroscedasticity');
|
||||
lReport.Add('Chi-Square = %8.3f with probability greater value = %8.3f',[BPG,chiprob]);
|
||||
lReport.Add('');
|
||||
end;
|
||||
}
|
||||
if MatSaveChkBox.Checked = true then
|
||||
DisplayReport(lReport);
|
||||
|
||||
if MatSaveChkBox.Checked then
|
||||
begin
|
||||
SaveDialog1.Filter := 'FreeStat matrix files (*.MAT)|*.MAT|All files (*.*)|*.*';
|
||||
SaveDialog1.Filter := 'LazStats matrix files (*.mat)|*.mat;*.MAT|All files (*.*)|*.*';
|
||||
SaveDialog1.FilterIndex := 1;
|
||||
if SaveDialog1.Execute then
|
||||
begin
|
||||
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;
|
||||
OutputFrm.ShowModal;
|
||||
CleanUp:
|
||||
|
||||
finally
|
||||
lReport.Free;
|
||||
ColEntered := nil;
|
||||
Candidate := nil;
|
||||
BetaWeights := nil;
|
||||
@ -423,86 +451,170 @@ CleanUp:
|
||||
corrs := nil;
|
||||
VarsInBlk := nil;
|
||||
BlkVarCols := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.DepInBtnClick(Sender: TObject);
|
||||
VAR index : integer;
|
||||
var
|
||||
index: integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
DepVar.Text := VarList.Items.Strings[index];
|
||||
VarList.Items.Delete(index);
|
||||
DepOutBtn.Enabled := true;
|
||||
DepInBtn.Enabled := false;
|
||||
index := VarList.ItemIndex;
|
||||
if (index > -1) and (DepVar.Text = '') then
|
||||
begin
|
||||
DepVar.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.DepOutBtnClick(Sender: TObject);
|
||||
begin
|
||||
VarList.Items.Add(DepVar.Text);
|
||||
DepVar.Text := '';
|
||||
DepInBtn.Enabled := true;
|
||||
if DepVar.Text <> '' then
|
||||
begin
|
||||
VarList.Items.Add(DepVar.Text);
|
||||
DepVar.Text := '';
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.InBtnClick(Sender: TObject);
|
||||
VAR i, index : integer;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
index := VarList.Items.Count;
|
||||
i := 0;
|
||||
while i < index do
|
||||
begin
|
||||
if (VarList.Selected[i]) then
|
||||
begin
|
||||
BlockList.Items.Add(VarList.Items.Strings[i]);
|
||||
VarList.Items.Delete(i);
|
||||
index := index - 1;
|
||||
i := 0;
|
||||
end
|
||||
else i := i + 1;
|
||||
end;
|
||||
OutBtn.Enabled := true;
|
||||
i := 0;
|
||||
while i < VarList.Items.Count do
|
||||
begin
|
||||
if VarList.Selected[i] then
|
||||
begin
|
||||
BlockList.Items.Add(VarList.Items[i]);
|
||||
VarList.Items.Delete(i);
|
||||
i := 0;
|
||||
end else
|
||||
i := i + 1;
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.NextBlkBtnClick(Sender: TObject);
|
||||
var
|
||||
blkno, i, j, count : integer;
|
||||
cellstring : string;
|
||||
blkno, i, j, count: integer;
|
||||
cellstring: string;
|
||||
begin
|
||||
{save columns of variables in the current block }
|
||||
count := BlockList.Items.Count;
|
||||
if count = 0 then
|
||||
begin
|
||||
VarsInBlk[NoBlocks-1] := 0;
|
||||
exit;
|
||||
end;
|
||||
VarsInBlk[NoBlocks-1] := count;
|
||||
for i := 0 to count-1 do
|
||||
begin
|
||||
for j := 1 to NoVariables do
|
||||
begin
|
||||
cellstring := OS3MainFrm.DataGrid.Cells[j,0];
|
||||
if cellstring = BlockList.Items.Strings[i] then
|
||||
begin
|
||||
BlkVarCols[NoBlocks-1,i] := j;
|
||||
NoVars := NoVars + 1;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
blkno := StrToInt(BlockNoEdit.Text);
|
||||
blkno := blkno + 1;
|
||||
BlockNoEdit.Text := IntToStr(blkno);
|
||||
NoBlocks := blkno;
|
||||
BlockList.Clear;
|
||||
{save columns of variables in the current block }
|
||||
count := BlockList.Items.Count;
|
||||
if count = 0 then
|
||||
begin
|
||||
VarsInBlk[NoBlocks-1] := 0;
|
||||
exit;
|
||||
end;
|
||||
|
||||
VarsInBlk[NoBlocks-1] := count;
|
||||
for i := 0 to count-1 do
|
||||
begin
|
||||
for j := 1 to NoVariables do
|
||||
begin
|
||||
cellstring := OS3MainFrm.DataGrid.Cells[j,0];
|
||||
if cellstring = BlockList.Items.Strings[i] then
|
||||
begin
|
||||
BlkVarCols[NoBlocks-1,i] := j;
|
||||
NoVars := NoVars + 1;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
blkno := StrToInt(BlockNoEdit.Text);
|
||||
blkno := blkno + 1;
|
||||
BlockNoEdit.Text := IntToStr(blkno);
|
||||
NoBlocks := blkno;
|
||||
//BlockList.Clear;
|
||||
end;
|
||||
|
||||
procedure TBlkMregFrm.OutBtnClick(Sender: TObject);
|
||||
VAR index : integer;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
index := BlockList.ItemIndex;
|
||||
VarList.Items.Add(BlockList.Items.Strings[index]);
|
||||
BlockList.Items.Delete(index);
|
||||
InBtn.Enabled := true;
|
||||
if BlockList.Items.Count = 0 then OutBtn.Enabled := false;
|
||||
i := 0;
|
||||
while i < BlockList.Items.Count do
|
||||
begin
|
||||
if BlockList.Selected[i] then
|
||||
begin
|
||||
VarList.Items.Add(BlockList.Items[i]);
|
||||
BlockList.Items.Delete(i);
|
||||
i := 0;
|
||||
end else
|
||||
i := i + 1;
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
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
|
||||
{$I blkmregunit.lrs}
|
||||
|
||||
|
@ -141,13 +141,12 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLSMregForm.ComputeBtnClick(Sender: TObject);
|
||||
Label CleanUp;
|
||||
var
|
||||
i, j, NCases: integer;
|
||||
NoIndepVars, DepVarCol, NEntered: integer;
|
||||
R2, df1, df2: double;
|
||||
StdErrEst, F, FProbF, OldR2 : double;
|
||||
pdf1, pdf2, probin, prout : double;
|
||||
pdf1, probin, prout : double;
|
||||
errorcode : boolean;
|
||||
BetaWeights : DblDyneVec;
|
||||
BWeights : DblDyneVec;
|
||||
@ -215,7 +214,6 @@ begin
|
||||
R2 := 0.0;
|
||||
OldR2 := 0.0;
|
||||
pdf1 := 0.0;
|
||||
pdf2 := 0.0;
|
||||
NEntered := 0;
|
||||
|
||||
{ get independendent variable column }
|
||||
|
@ -112,7 +112,7 @@ var
|
||||
StdErr, df1, df2, x, determinant : double;
|
||||
errorcode : boolean = false;
|
||||
filename : string;
|
||||
cellstring, outline, valstring : string;
|
||||
cellstring, valstring : string;
|
||||
Corrs : DblDyneMat;
|
||||
Means : DblDyneVec;
|
||||
Variances : DblDyneVec;
|
||||
|
@ -81,7 +81,6 @@ procedure TBinomialFrm.ComputeBtnClick(Sender: TObject);
|
||||
var
|
||||
p, Q, Probability, z, CorrectedA, SumProb : double;
|
||||
A, b, N, X, i: integer;
|
||||
outline : string;
|
||||
lReport: TStrings;
|
||||
msg: String;
|
||||
C: TWinControl;
|
||||
|
@ -112,10 +112,10 @@ end;
|
||||
|
||||
procedure TCochranQFrm.ComputeBtnClick(Sender: TObject);
|
||||
var
|
||||
i, j, k, col : integer;
|
||||
ColNoSelected : IntDyneVec;
|
||||
R1, L1, L2, C1, g1, Q, g2, chiprob : double;
|
||||
cellstring, outline : string;
|
||||
i, j, k, col: integer;
|
||||
ColNoSelected: IntDyneVec;
|
||||
R1, L1, L2, C1, g1, Q, g2, chiprob: double;
|
||||
cellstring: string;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
if SelList.Items.Count = 0 then
|
||||
|
@ -153,7 +153,7 @@ Var
|
||||
RowLabels, ColLabels : StrDyneVec;
|
||||
index : IntDyneVec;
|
||||
GrpNo : IntdyneMat;
|
||||
cellstring, outline: string;
|
||||
cellstring: string;
|
||||
title : string;
|
||||
ties : boolean;
|
||||
ColNoSelected : IntDyneVec;
|
||||
|
@ -107,7 +107,6 @@ begin
|
||||
end;
|
||||
|
||||
procedure TKWAnovaFrm.ComputeBtnClick(Sender: TObject);
|
||||
label cleanup, Check1, Check2;
|
||||
var
|
||||
i, j, k, m, ind_var, dep_var, min_grp, max_grp, group, total_n : integer;
|
||||
NoTies, NoTieGroups, nogroups, NoSelected, npairs, n1, n2 : integer;
|
||||
@ -118,7 +117,7 @@ var
|
||||
Correction, Temp, TieSum, alpha, U, U2, SD, z, prob : double;
|
||||
Ranks, X : DblDyneMat;
|
||||
RankSums : DblDyneVec;
|
||||
cellstring, outline : string;
|
||||
cellstring, outline: string;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
// Check for data
|
||||
@ -460,7 +459,6 @@ begin
|
||||
lReport.Add('%3d %10.3f %5d', [j, RankSums[group], group_count[1]]);
|
||||
lReport.Add('');
|
||||
lReport.Add( 'No. of tied rank groups: %8d', [NoTieGroups]);
|
||||
lReport.Add(outline);
|
||||
if (n1 > n2) then largestn := n1 else largestn := n2;
|
||||
if (largestn < 20) then
|
||||
outline := Format( 'Statistic U: %8.4f',[U])
|
||||
|
@ -198,7 +198,6 @@ var
|
||||
varcols : IntDyneVec;
|
||||
AtRisk, ProbDie, CumProbLive, StdErr, Up95, Low95 : double;
|
||||
N, P, Q, mu, CI, z : double;
|
||||
outline : string;
|
||||
begin
|
||||
if ObsStartEdit.Text = '' then
|
||||
begin
|
||||
|
@ -144,7 +144,7 @@ begin
|
||||
SetLength(selected,noselected);
|
||||
SetLength(Values,NoCases,noselected+1);
|
||||
SetLength(Slopes,NoCases,NoCases);
|
||||
SetLength(RankedQ,NoVars);
|
||||
SetLength(RankedQ,NoVars); // !!!!!!!!!!!!!!!!!!! NoVars is not initialized !!!!!!!!!!!!!!!!!!!!!!
|
||||
SetLength(Sorted,NoCases);
|
||||
SetLength(AvgSlopes,NoCases,NoCases);
|
||||
|
||||
|
@ -154,7 +154,7 @@ var
|
||||
DifSigns : IntDyneVec;
|
||||
p, Q, Probability, z, NoDiff, CorrectedA, x1, x2 : double;
|
||||
SumProb : double;
|
||||
cellstring, outline : string;
|
||||
cellstring: string;
|
||||
lReport: TStrings;
|
||||
begin
|
||||
if Var1Edit.Text = '' then
|
||||
|
@ -811,7 +811,9 @@ begin
|
||||
VarY := VarY / (NCases - 1);
|
||||
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 ;
|
||||
|
||||
// augment the matrix
|
||||
@ -937,22 +939,24 @@ begin
|
||||
end;
|
||||
|
||||
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);
|
||||
SVDinverse(XTX, NoIndep);
|
||||
for i := 0 to NoIndep do
|
||||
begin
|
||||
VIF := XTX[i,i];
|
||||
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
|
||||
]);
|
||||
end;
|
||||
AReport.Add('');
|
||||
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('Residual %3d %9.3f %9.3f', [(NCases-N), SSres, SSres/(NCases-N)]); // df2
|
||||
AReport.Add('Total %3d %9.3f', [NCases-1, SSY]);
|
||||
AReport.Add('SOURCE DF SS MS F Prob. > F');
|
||||
AReport.Add('---------- --- -------------- -------------- -------------- ----------');
|
||||
AReport.Add('Regression %3d %14.3f %14.3f %14.4f %10.4', [N-1, SSreg, SSreg/(N-1), F, Prob]); // df1
|
||||
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('R2: %10.4f', [R2]);
|
||||
@ -1391,10 +1395,11 @@ begin
|
||||
F := 0.0;
|
||||
FProbF := probf(F,df1,df2);
|
||||
|
||||
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('Residual %3.0f %9.3f %9.3f', [df2, SSres, SSres/df2]);
|
||||
AReport.Add('Total %3.0f %9.3f', [df3, SSt]);
|
||||
AReport.Add('SOURCE DF SS MS F Prob. > F');
|
||||
AReport.Add('---------- ---- -------------- -------------- -------------- ---------');
|
||||
AReport.Add('Regression %4.0f %14.3f %14.3f %14.3f %9.3f', [df1, SSreg, SSreg/df1, F, FprobF]);
|
||||
AReport.Add('Residual %4.0f %14.3f %14.3f', [df2, SSres, SSres/df2]);
|
||||
AReport.Add('Total %4.0f %14.3f', [df3, SSt]);
|
||||
AReport.Add('');
|
||||
|
||||
AdjR2 := 1.0 - (1.0 - R2) * (NCases - 1) / df2;
|
||||
@ -1402,13 +1407,15 @@ begin
|
||||
begin
|
||||
AReport.Add('Dependent Variable: ' + deplabel);
|
||||
AReport.Add('');
|
||||
AReport.Add('%8s%10s%10s%12s%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('%8s %10s %10s %10s %5s %5s', ['R', 'R2', 'F', 'Prob.>F', '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('');
|
||||
AReport.Add('Std. Error of Estimate: %10.3f', [StdErrEst]);
|
||||
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;
|
||||
|
||||
df1 := 1.0;
|
||||
@ -1439,7 +1446,7 @@ begin
|
||||
if PrintIt then
|
||||
begin
|
||||
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]);
|
||||
if FprobF > ProbOut then
|
||||
outline := outline + ' Exceeds limit - to be removed.';
|
||||
@ -1523,7 +1530,6 @@ var
|
||||
i, j, first, last, nflds: integer;
|
||||
done : boolean;
|
||||
outline: string;
|
||||
valstring: string;
|
||||
begin
|
||||
AReport.Add('');
|
||||
AReport.Add(Title);
|
||||
|
Reference in New Issue
Block a user