LazStats: Simplify option selection in WLSUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7774 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-12 16:49:08 +00:00
parent 8f0071b064
commit cf97f527e9
2 changed files with 208 additions and 215 deletions

View File

@ -1,158 +1,134 @@
inherited WLSFrm: TWLSFrm inherited WLSFrm: TWLSFrm
Left = 288 Left = 288
Height = 428 Height = 469
Top = 171 Top = 171
Width = 1024 Width = 1024
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/WeightedLeast-SquaresRegression.htm' HelpKeyword = 'html/WeightedLeast-SquaresRegression.htm'
Caption = 'Weighted Least Squares Regression' Caption = 'Weighted Least Squares Regression'
ClientHeight = 428 ClientHeight = 469
ClientWidth = 1024 ClientWidth = 1024
inherited ParamsPanel: TPanel inherited ParamsPanel: TPanel
Height = 412 Height = 453
Width = 495 Width = 280
ClientHeight = 412 ClientHeight = 453
ClientWidth = 495 ClientWidth = 280
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 440 Left = 225
Top = 387 Top = 428
TabOrder = 14 TabOrder = 14
end end
inherited ComputeBtn: TButton inherited ComputeBtn: TButton
Left = 356 Left = 141
Top = 387 Top = 428
TabOrder = 13 TabOrder = 13
end end
inherited ResetBtn: TButton inherited ResetBtn: TButton
Left = 294 Left = 79
Top = 387 Top = 428
TabOrder = 12 TabOrder = 12
end end
inherited HelpBtn: TButton inherited HelpBtn: TButton
Tag = 158 Tag = 158
Left = 235 Left = 20
Top = 387 Top = 428
TabOrder = 11 TabOrder = 11
end end
inherited ButtonBevel: TBevel inherited ButtonBevel: TBevel
Top = 371 Top = 412
Width = 495 Width = 280
end end
object OptionsGroup: TGroupBox[5] object OptionsGroup: TGroupBox[5]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideBottom.Control = ButtonBevel AnchorSideBottom.Control = ButtonBevel
Left = 0 Left = 0
Height = 112 Height = 147
Top = 259 Top = 265
Width = 483 Width = 266
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
Caption = 'Options' Caption = 'Options'
ClientHeight = 92 ClientHeight = 127
ClientWidth = 479 ClientWidth = 262
TabOrder = 10 TabOrder = 10
object OLSChk: TCheckBox
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = OptionsGroup
Left = 12
Height = 19
Top = 2
Width = 206
BorderSpacing.Left = 12
BorderSpacing.Top = 2
Caption = 'Obtain OLS , save squared residuals'
TabOrder = 0
end
object PlotChk: TCheckBox
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = OLSChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 23
Width = 216
BorderSpacing.Left = 12
BorderSpacing.Top = 2
Caption = 'Plot squared residuals vs. Indep. Vars.'
TabOrder = 1
end
object RegResChk: TCheckBox
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = PlotChk
AnchorSideTop.Side = asrBottom
Left = 12
Height = 19
Top = 44
Width = 235
BorderSpacing.Left = 12
BorderSpacing.Top = 2
Caption = 'Regress squared residuals on Indep. Vars.'
TabOrder = 2
end
object SaveChk: TCheckBox object SaveChk: TCheckBox
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = RegResChk AnchorSideTop.Control = OptionsBevel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 12
Height = 19 Height = 19
Top = 65 Top = 100
Width = 180 Width = 180
BorderSpacing.Left = 12 BorderSpacing.Left = 12
BorderSpacing.Top = 2 BorderSpacing.Top = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Save Estimated weights in grid' Caption = 'Save estimated weights in grid'
TabOrder = 3 TabOrder = 0
end
object WeightChk: TCheckBox
AnchorSideLeft.Control = RegResChk
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OptionsGroup
Left = 263
Height = 19
Top = 2
Width = 208
BorderSpacing.Left = 16
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Caption = 'Apply weights to obtain a WLS regr.'
TabOrder = 4
end end
object OriginChk: TCheckBox object OriginChk: TCheckBox
AnchorSideLeft.Control = WeightChk AnchorSideLeft.Control = WeightChk
AnchorSideTop.Control = WeightChk AnchorSideTop.Control = WeightChk
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 287 Left = 40
Height = 19 Height = 19
Top = 23 Top = 23
Width = 119 Width = 119
BorderSpacing.Left = 24 BorderSpacing.Left = 24
BorderSpacing.Top = 2
Caption = 'Through the origin' Caption = 'Through the origin'
TabOrder = 5 TabOrder = 1
end
object UserWghtsChk: TCheckBox
AnchorSideLeft.Control = WeightChk
AnchorSideTop.Control = OriginChk
AnchorSideTop.Side = asrBottom
Left = 263
Height = 19
Top = 44
Width = 187
BorderSpacing.Top = 2
Caption = 'Use weights entered by the user'
TabOrder = 6
end end
object Origin2Chk: TCheckBox object Origin2Chk: TCheckBox
AnchorSideLeft.Control = OriginChk AnchorSideLeft.Control = OriginChk
AnchorSideTop.Control = UserWghtsChk AnchorSideTop.Control = UserWeightsChk
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 287 Left = 40
Height = 19 Height = 19
Top = 65 Top = 65
Width = 119 Width = 119
BorderSpacing.Top = 2
Caption = 'Through the origin' Caption = 'Through the origin'
TabOrder = 7 TabOrder = 2
end
object WeightChk: TRadioButton
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = OptionsGroup
Left = 16
Height = 19
Top = 4
Width = 238
BorderSpacing.Left = 16
BorderSpacing.Top = 4
BorderSpacing.Right = 8
Caption = 'Apply weights to obtain a WLS regression'
OnChange = UserWeightsChkChange
TabOrder = 3
end
object UserWeightsChk: TRadioButton
AnchorSideLeft.Control = WeightChk
AnchorSideTop.Control = OriginChk
AnchorSideTop.Side = asrBottom
Left = 16
Height = 19
Top = 46
Width = 156
BorderSpacing.Top = 4
Caption = 'Use weights from column'
OnChange = UserWeightsChkChange
TabOrder = 4
end
object OptionsBevel: TBevel
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = Origin2Chk
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OptionsGroup
AnchorSideRight.Side = asrBottom
Left = 12
Height = 8
Top = 84
Width = 238
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12
BorderSpacing.Right = 12
Shape = bsBottomLine
end end
end end
object Label1: TLabel[6] object Label1: TLabel[6]
@ -169,7 +145,7 @@ inherited WLSFrm: TWLSFrm
AnchorSideLeft.Control = DepInBtn AnchorSideLeft.Control = DepInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = DepVarEdit AnchorSideBottom.Control = DepVarEdit
Left = 264 Left = 157
Height = 15 Height = 15
Top = 21 Top = 21
Width = 102 Width = 102
@ -184,7 +160,7 @@ inherited WLSFrm: TWLSFrm
AnchorSideLeft.Control = IndInBtn AnchorSideLeft.Control = IndInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = IndInBtn AnchorSideTop.Control = IndInBtn
Left = 264 Left = 157
Height = 15 Height = 15
Top = 105 Top = 105
Width = 116 Width = 116
@ -193,17 +169,18 @@ inherited WLSFrm: TWLSFrm
ParentColor = False ParentColor = False
end end
object Label4: TLabel[9] object Label4: TLabel[9]
AnchorSideLeft.Control = WghtInBtn AnchorSideLeft.Control = WeightInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = WghtVarEdit AnchorSideBottom.Control = WeightVarEdit
Left = 264 Left = 157
Height = 15 Height = 15
Top = 199 Top = 205
Width = 137 Width = 134
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'User''s Weigjhts (Optional)' Caption = 'User''s Weights (Optional)'
Enabled = False
ParentColor = False ParentColor = False
end end
object VarList: TListBox[10] object VarList: TListBox[10]
@ -213,9 +190,9 @@ inherited WLSFrm: TWLSFrm
AnchorSideRight.Control = DepInBtn AnchorSideRight.Control = DepInBtn
AnchorSideBottom.Control = OptionsGroup AnchorSideBottom.Control = OptionsGroup
Left = 0 Left = 0
Height = 234 Height = 240
Top = 17 Top = 17
Width = 230 Width = 123
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 4 BorderSpacing.Right = 4
@ -231,7 +208,7 @@ inherited WLSFrm: TWLSFrm
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
Left = 234 Left = 127
Height = 26 Height = 26
Top = 17 Top = 17
Width = 26 Width = 26
@ -246,7 +223,7 @@ inherited WLSFrm: TWLSFrm
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepInBtn AnchorSideTop.Control = DepInBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 234 Left = 127
Height = 26 Height = 26
Top = 47 Top = 47
Width = 26 Width = 26
@ -262,7 +239,7 @@ inherited WLSFrm: TWLSFrm
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = DepOutBtn AnchorSideTop.Control = DepOutBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 234 Left = 127
Height = 26 Height = 26
Top = 105 Top = 105
Width = 26 Width = 26
@ -278,7 +255,7 @@ inherited WLSFrm: TWLSFrm
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = IndInBtn AnchorSideTop.Control = IndInBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 234 Left = 127
Height = 26 Height = 26
Top = 135 Top = 135
Width = 26 Width = 26
@ -289,35 +266,35 @@ inherited WLSFrm: TWLSFrm
Spacing = 0 Spacing = 0
TabOrder = 5 TabOrder = 5
end end
object WghtInBtn: TBitBtn[15] object WeightInBtn: TBitBtn[15]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = WghtOutBtn AnchorSideBottom.Control = WeightOutBtn
Left = 234 Left = 127
Height = 26 Height = 26
Top = 195 Top = 201
Width = 26 Width = 26
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4 BorderSpacing.Bottom = 4
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 1 ImageIndex = 1
OnClick = WghtInBtnClick OnClick = WeightInBtnClick
Spacing = 0 Spacing = 0
TabOrder = 7 TabOrder = 7
end end
object WghtOutBtn: TBitBtn[16] object WeightOutBtn: TBitBtn[16]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 234 Left = 127
Height = 26 Height = 26
Top = 225 Top = 231
Width = 26 Width = 26
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
ImageIndex = 0 ImageIndex = 0
OnClick = WghtOutBtnClick OnClick = WeightOutBtnClick
Spacing = 0 Spacing = 0
TabOrder = 8 TabOrder = 8
end end
@ -329,10 +306,10 @@ inherited WLSFrm: TWLSFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = DepOutBtn AnchorSideBottom.Control = DepOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 264 Left = 157
Height = 23 Height = 23
Top = 38 Top = 38
Width = 231 Width = 123
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
@ -347,11 +324,11 @@ inherited WLSFrm: TWLSFrm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ParamsPanel AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = WghtInBtn AnchorSideBottom.Control = WeightInBtn
Left = 264 Left = 157
Height = 57 Height = 63
Top = 122 Top = 122
Width = 231 Width = 123
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Top = 2 BorderSpacing.Top = 2
@ -362,54 +339,55 @@ inherited WLSFrm: TWLSFrm
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 6 TabOrder = 6
end end
object WghtVarEdit: TEdit[19] object WeightVarEdit: TEdit[19]
AnchorSideLeft.Control = WghtInBtn AnchorSideLeft.Control = WeightInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = ParamsPanel AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = WghtOutBtn AnchorSideBottom.Control = WeightOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 264 Left = 157
Height = 23 Height = 23
Top = 216 Top = 222
Width = 231 Width = 123
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
Enabled = False
ReadOnly = True ReadOnly = True
TabOrder = 9 TabOrder = 9
Text = 'WghtVarEdit' Text = 'WeightVarEdit'
end end
end end
inherited ParamsSplitter: TSplitter inherited ParamsSplitter: TSplitter
Left = 507 Left = 292
Height = 428 Height = 469
end end
object PageControl: TPageControl[2] object PageControl: TPageControl[2]
Left = 516 Left = 301
Height = 412 Height = 453
Top = 8 Top = 8
Width = 500 Width = 715
ActivePage = ResidualsRegPage ActivePage = OLSPage
Align = alClient Align = alClient
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
TabIndex = 1 TabIndex = 0
TabOrder = 2 TabOrder = 2
object OLSPage: TTabSheet object OLSPage: TTabSheet
Caption = 'OLS Regression' Caption = 'OLS Regression'
end end
object ResidualsRegPage: TTabSheet object ResidualsRegPage: TTabSheet
Caption = 'Squared Residuals Regression' Caption = 'Squared Residuals Regression'
ClientHeight = 384 ClientHeight = 425
ClientWidth = 492 ClientWidth = 707
object ResRegPageControl: TPageControl object ResRegPageControl: TPageControl
Left = 8 Left = 8
Height = 368 Height = 409
Top = 8 Top = 8
Width = 476 Width = 691
ActivePage = ResRegReportPage ActivePage = ResRegReportPage
Align = alClient Align = alClient
BorderSpacing.Around = 8 BorderSpacing.Around = 8

View File

@ -15,6 +15,7 @@ type
{ TWLSFrm } { TWLSFrm }
TWLSFrm = class(TBasicStatsParamsForm) TWLSFrm = class(TBasicStatsParamsForm)
OptionsBevel: TBevel;
DepInBtn: TBitBtn; DepInBtn: TBitBtn;
DepOutBtn: TBitBtn; DepOutBtn: TBitBtn;
IndInBtn: TBitBtn; IndInBtn: TBitBtn;
@ -24,19 +25,16 @@ type
ResRegPageControl: TPageControl; ResRegPageControl: TPageControl;
ResidualsRegPage: TTabSheet; ResidualsRegPage: TTabSheet;
ResRegReportPage: TTabSheet; ResRegReportPage: TTabSheet;
UserWeightsChk: TRadioButton;
WeightChk: TRadioButton;
WLSPage: TTabSheet; WLSPage: TTabSheet;
WghtInBtn: TBitBtn; WeightInBtn: TBitBtn;
WghtOutBtn: TBitBtn; WeightOutBtn: TBitBtn;
OLSChk: TCheckBox;
PlotChk: TCheckBox;
RegResChk: TCheckBox;
SaveChk: TCheckBox; SaveChk: TCheckBox;
WeightChk: TCheckBox;
OriginChk: TCheckBox; OriginChk: TCheckBox;
UserWghtsChk: TCheckBox;
Origin2Chk: TCheckBox; Origin2Chk: TCheckBox;
DepVarEdit: TEdit; DepVarEdit: TEdit;
WghtVarEdit: TEdit; WeightVarEdit: TEdit;
OptionsGroup: TGroupBox; OptionsGroup: TGroupBox;
Label1: TLabel; Label1: TLabel;
Label2: TLabel; Label2: TLabel;
@ -49,10 +47,11 @@ type
procedure IndInBtnClick(Sender: TObject); procedure IndInBtnClick(Sender: TObject);
procedure IndOutBtnClick(Sender: TObject); procedure IndOutBtnClick(Sender: TObject);
procedure IndVarListDblClick(Sender: TObject); procedure IndVarListDblClick(Sender: TObject);
procedure UserWeightsChkChange(Sender: TObject);
procedure VarListDblClick(Sender: TObject); procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
procedure WghtInBtnClick(Sender: TObject); procedure WeightInBtnClick(Sender: TObject);
procedure WghtOutBtnClick(Sender: TObject); procedure WeightOutBtnClick(Sender: TObject);
private private
OLSReportFrame: TReportFrame; OLSReportFrame: TReportFrame;
@ -99,6 +98,7 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Math,
TAChartUtils, TAChartAxisUtils, TALegend, TASources, TACustomSeries, TAChartUtils, TAChartAxisUtils, TALegend, TASources, TACustomSeries,
Utils, GridProcs; Utils, GridProcs;
@ -146,7 +146,10 @@ begin
ParamsPanel.Constraints.MinHeight := DepInBtn.Top + (IndOutBtn.Top - DepInBtn.Top)*2 + DepInBtn.Top + ParamsPanel.Constraints.MinHeight := DepInBtn.Top + (IndOutBtn.Top - DepInBtn.Top)*2 + DepInBtn.Top +
OptionsGroup.Height + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; OptionsGroup.Height + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
ParamsPanel.Constraints.MinWidth := OptionsGroup.Width; ParamsPanel.Constraints.MinWidth := Max(
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
OptionsGroup.Width
);
end; end;
procedure TWLSFrm.Compute; procedure TWLSFrm.Compute;
@ -204,7 +207,7 @@ begin
// SetLength(RowLabels, NoIndep); // SetLength(RowLabels, NoIndep);
depCol := GetVariableIndex(OS3MainFrm.DataGrid, DepVarEdit.Text); depCol := GetVariableIndex(OS3MainFrm.DataGrid, DepVarEdit.Text);
wghtCol := GetVariableIndex(OS3MainFrm.DataGrid, WghtVarEdit.Text); wghtCol := GetVariableIndex(OS3MainFrm.DataGrid, WeightVarEdit.Text);
for i := 0 to NoIndep-1 do for i := 0 to NoIndep-1 do
begin begin
IndepCols[i] := GetVariableIndex(OS3MainFrm.DataGrid, IndVarList.Items[i]); IndepCols[i] := GetVariableIndex(OS3MainFrm.DataGrid, IndVarList.Items[i]);
@ -220,7 +223,7 @@ begin
for i := 0 to NoVariables - 1 do for i := 0 to NoVariables - 1 do
begin begin
if (OS3MainFrm.DataGrid.Cells[i+1,0] = DepVarEdit.Text) then DepCol := i+1; if (OS3MainFrm.DataGrid.Cells[i+1,0] = DepVarEdit.Text) then DepCol := i+1;
if (OS3MainFrm.DataGrid.Cells[i+1,0] = WghtVarEdit.Text) then WghtCol := i+1; if (OS3MainFrm.DataGrid.Cells[i+1,0] = WeightVarEdit.Text) then WghtCol := i+1;
for j := 0 to Noindep - 1 do for j := 0 to Noindep - 1 do
begin begin
if (OS3MainFrm.DataGrid.Cells[i+1,0] = IndVarList.Items.Strings[j]) then if (OS3MainFrm.DataGrid.Cells[i+1,0] = IndVarList.Items.Strings[j]) then
@ -269,40 +272,34 @@ begin
IndepCols[NoIndep] := depCol; IndepCols[NoIndep] := depCol;
oldDepCol := DepCol; // save dependent column so we can reuse DepCol oldDepCol := DepCol; // save dependent column so we can reuse DepCol
// Get OLS regression // *** Get OLS regression ***
if OLSChk.Checked then lReport.Clear;
begin lReport.Add('ORDINARY LEAST SQUARES (OLS) REGRESSION RESULTS');
lReport.Clear; lReport.Add('');
lReport.Add('ORDINARY LEAST SQUARES (OLS) REGRESSION RESULTS'); MReg(Noindep, IndepCols, DepCol, RowLabels, Means, Variances, StdDevs,
lReport.Add(''); BWeights, BetaWeights, BStdErrs, Bttests, tprobs, R2, stderrest,
MReg(Noindep, IndepCols, DepCol, RowLabels, Means, Variances, StdDevs, NCases, errorcode, PrintDesc, lReport);
BWeights, BetaWeights, BStdErrs, Bttests, tprobs, R2, stderrest,
NCases, errorcode, PrintDesc, lReport);
// Get predicted z score, residual z score, predicted raw score, // Get predicted z score, residual z score, predicted raw score,
// residual raw score and squared raw residual score. Place in the DataGrid // residual raw score and squared raw residual score. Place in the DataGrid
PredictIt(IndepCols, Noindep+1, Means, StdDevs, BetaWeights, stderrest, NoIndep); PredictIt(IndepCols, Noindep+1, Means, StdDevs, BetaWeights, stderrest, NoIndep);
OLSReportFrame.DisplayReport(lReport); OLSReportFrame.DisplayReport(lReport);
lReport.Clear; lReport.Clear;
end;
if RegResChk.Checked and OLSChk.Checked then // *** Regress the squared residuals on the predictors ***
begin depCol := NoVariables;
// Regress the squared residuals on the predictors lReport.Clear;
depCol := NoVariables; lReport.Add('REGRESSION OF SQUARED RESIDUALS ON INDEPENDENT VARIABLES');
lReport.Clear; lReport.Add('');
lReport.Add('REGRESSION OF SQUARED RESIDUALS ON INDEPENDENT VARIABLES'); MReg(Noindep, IndepCols, DepCol, RowLabels, Means, Variances, StdDevs,
lReport.Add(''); BWeights, BetaWeights, BStdErrs, Bttests, tprobs, R2, stderrest,
MReg(Noindep, IndepCols, DepCol, RowLabels, Means, Variances, StdDevs, NCases, errorcode, PrintDesc, lReport);
BWeights, BetaWeights, BStdErrs, Bttests, tprobs, R2, stderrest,
NCases, errorcode, PrintDesc, lReport);
ResidualsRegReportFrame.DisplayReport(lReport); ResidualsRegReportFrame.DisplayReport(lReport);
lReport.Clear; lReport.Clear;
end;
if WeightChk.Checked and RegResChk.Checked then if WeightChk.Checked then
begin begin
// Get predicted squared residuals and save recipricols as weights // Get predicted squared residuals and save recipricols as weights
col := NoVariables + 1; col := NoVariables + 1;
@ -341,11 +338,10 @@ begin
end; // next i end; // next i
end; // if regresChk end; // if regresChk
// Display squared residuals for each independent variable // *** Display squared residuals for each independent variable ***
if RegResChk.Checked then PlotSquaredResiduals(IndepCols, NoIndep, DepCol, 0.95);
PlotSquaredResiduals(IndepCols, NoIndep, DepCol, 0.95);
if not UserWghtsChk.Checked then if not UserWeightsChk.Checked then
begin begin
// Weight variables and do OLS regression on weighted variables // Weight variables and do OLS regression on weighted variables
DepCol := olddepcol; DepCol := olddepcol;
@ -403,7 +399,7 @@ begin
end // if useweightschk checked end // if useweightschk checked
else else
// use the weights entered by the user // use the weights entered by the user
if (UserWghtsChk.Checked) then if (UserWeightsChk.Checked) then
begin begin
// Weight variables and do OLS regression on weighted variables // Weight variables and do OLS regression on weighted variables
DepCol := olddepcol; DepCol := olddepcol;
@ -419,7 +415,7 @@ begin
OS3MainFrm.DataGrid.Cells[pos,i] := FloatToStr(X); OS3MainFrm.DataGrid.Cells[pos,i] := FloatToStr(X);
end; end;
end; end;
if (OriginChk.Checked) then // get means of variables and subtract from the values if (Origin2Chk.Checked) then // get means of variables and subtract from the values
begin begin
for j := 0 to Noindep do for j := 0 to Noindep do
begin begin
@ -823,22 +819,22 @@ begin
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i+1,0]); VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i+1,0]);
IndVarList.Clear; IndVarList.Clear;
DepVarEdit.Text := ''; DepVarEdit.Clear;
WghtVarEdit.Text := ''; WeightVarEdit.Clear;
if OLSReportFrame <> nil then
OLSReportFrame.Clear;
if ResidualsRegReportFrame <> nil then
ResidualsRegReportFrame.clear;
if WLSReportFrame <> nil then
WLSReportFrame.Clear;
DepInBtn.Enabled := true;
DepOutBtn.Enabled := false;
IndInBtn.Enabled := true;
IndOutBtn.Enabled := false;
WghtInBtn.Enabled := true;
WghtOutBtn.Enabled := false;
OLSChk.Checked := true;
PlotChk.Checked := true;
RegResChk.Checked := true;
WeightChk.Checked := true; WeightChk.Checked := true;
UserWghtsChk.Checked := false; UserWeightsChk.Checked := false;
OriginChk.Checked := true; OriginChk.Checked := false;
Origin2Chk.Checked := true; Origin2Chk.Checked := false;
UpdateBtnStates;
end; end;
@ -858,7 +854,7 @@ begin
end; end;
DepInBtn.Enabled := lSelected and (DepVarEdit.Text = ''); DepInBtn.Enabled := lSelected and (DepVarEdit.Text = '');
IndInBtn.Enabled := lSelected; IndInBtn.Enabled := lSelected;
WghtInBtn.Enabled := lSelected and (WghtVarEdit.Text = ''); WeightInBtn.Enabled := lSelected and (WeightVarEdit.Text = '') and UserWeightsChk.Checked;
lSelected := false; lSelected := false;
for i:=0 to IndVarList.Items.Count-1 do for i:=0 to IndVarList.Items.Count-1 do
@ -869,7 +865,24 @@ begin
end; end;
DepOutBtn.Enabled := (DepVarEdit.Text <> ''); DepOutBtn.Enabled := (DepVarEdit.Text <> '');
IndOutBtn.Enabled := lSelected; IndOutBtn.Enabled := lSelected;
WghtOutBtn.Enabled := (WghtVarEdit.Text <> ''); WeightOutBtn.Enabled := (WeightVarEdit.Text <> '') and UserWeightsChk.Checked;
if OLSReportFrame <> nil then
OLSReportFrame.UpdateBtnStates;
if ResidualsRegReportFrame <> nil then
ResidualsRegReportFrame.UpdateBtnStates;
if WLSReportFrame <> nil then
WLSReportFrame.UpdateBtnStates;
end;
procedure TWLSFrm.UserWeightsChkChange(Sender: TObject);
begin
WeightVarEdit.Enabled := UserWeightsChk.Checked;
Label4.Enabled := WeightVarEdit.Enabled;
WeightInBtn.Enabled := UserWeightsChk.Checked and (VarList.ItemIndex > -1) and (WeightVarEdit.Text = '');
WeightOutBtn.Enabled := UserWeightsChk.Checked and (WeightVarEdit.Text <> '');
end; end;
@ -918,26 +931,26 @@ begin
end; end;
procedure TWLSFrm.WghtInBtnClick(Sender: TObject); procedure TWLSFrm.WeightInBtnClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
index := VarList.ItemIndex; index := VarList.ItemIndex;
if (index > -1) and (WghtVarEdit.Text = '') then if (index > -1) and (WeightVarEdit.Text = '') then
begin begin
WghtVarEdit.Text := VarList.Items[index]; WeightVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index); VarList.Items.Delete(index);
end; end;
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TWLSFrm.WghtOutBtnClick(Sender: TObject); procedure TWLSFrm.WeightOutBtnClick(Sender: TObject);
begin begin
if (WghtVarEdit.Text <> '') then if (WeightVarEdit.Text <> '') then
begin begin
VarList.Items.Add(WghtVarEdit.Text); VarList.Items.Add(WeightVarEdit.Text);
WghtVarEdit.Text := ''; WeightVarEdit.Text := '';
end; end;
UpdateBtnStates; UpdateBtnStates;
end; end;
@ -951,12 +964,14 @@ var
begin begin
lReport := TStringList.Create; lReport := TStringList.Create;
try try
{
lReport.Add('Data file: %s', [OS3MainFrm.FileNameEdit.Text]); lReport.Add('Data file: %s', [OS3MainFrm.FileNameEdit.Text]);
lReport.Add(''); lReport.Add('');
lReport.Add('Variables:'); lReport.Add('Variables:');
lReport.Add(' X: %s', [xLabel]); lReport.Add(' X: %s', [xLabel]);
lReport.Add(' Y: %s', [yLabel]); lReport.Add(' Y: %s', [yLabel]);
lReport.Add(''); lReport.Add('');
}
lReport.Add('Variable Mean Variance Std.Dev.'); lReport.Add('Variable Mean Variance Std.Dev.');
lReport.Add('---------- -------- -------- --------'); lReport.Add('---------- -------- -------- --------');
with ARegressionResults do with ARegressionResults do