LazStats: Inherit SimpleChiSqrUnit from TBasicStatsReportForm. Some refactoring.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7840 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-03 15:09:13 +00:00
parent d660825c51
commit 4613e36150
3 changed files with 219 additions and 464 deletions

View File

@ -69,3 +69,4 @@ correlation, means, standard deviations and confidence interval for each correla
165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button. 165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button.
166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis. 166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis.
167=Notes: This is a non-parametric analysis of ordinal data.\nIt is similar to a two-way Analysis of Variance but utilizes a chi-square statistic (H) for determining the significance of the row, column and interaction effects. The dependent value, if not initially rank data, may be obtained first by creating a new variable with the "transformation" procedure available under the "Variables" menu. The output of this procedure contains the results both of a "traditional" 2-way ANOVA as well as the SRH results.\nIt should be noted that the power of the SRH analysis is less than that of the traditional ANOVA. It is suggested that there be at least 5 or more cases in each cell and that the design is a balanced design of fixed levels.\nThe H statistic is obtained as the division of the sum of squares for an effect by the mean square of the total and the test is performed by a chi-squared probability with the degrees of freedom equal to the SS of the effect being tested. 167=Notes: This is a non-parametric analysis of ordinal data.\nIt is similar to a two-way Analysis of Variance but utilizes a chi-square statistic (H) for determining the significance of the row, column and interaction effects. The dependent value, if not initially rank data, may be obtained first by creating a new variable with the "transformation" procedure available under the "Variables" menu. The output of this procedure contains the results both of a "traditional" 2-way ANOVA as well as the SRH results.\nIt should be noted that the power of the SRH analysis is less than that of the traditional ANOVA. It is suggested that there be at least 5 or more cases in each cell and that the design is a balanced design of fixed levels.\nThe H statistic is obtained as the division of the sum of squares for an effect by the mean square of the total and the test is performed by a chi-squared probability with the degrees of freedom equal to the SS of the effect being tested.
168=This procedure lets you enter the number of observed values and the number of expected values for one or more categories.\nEnter the values as indicated and when finished, press the compute button.

View File

@ -1,24 +1,39 @@
object SimpleChiSqrForm: TSimpleChiSqrForm inherited SimpleChiSqrForm: TSimpleChiSqrForm
Left = 827 Left = 827
Height = 436 Height = 266
Top = 221 Top = 221
Width = 408 Width = 703
Caption = 'Simple ChiSquare for Categories' Caption = 'Simple ChiSquare for Categories'
ClientHeight = 436 ClientHeight = 266
ClientWidth = 408 ClientWidth = 703
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 250
OnResize = FormResize ClientHeight = 250
OnShow = ResetBtnClick inherited CloseBtn: TButton
Position = poMainFormCenter Top = 225
LCLVersion = '2.1.0.0' TabOrder = 5
object Label1: TLabel end
AnchorSideTop.Control = NcatsEdit inherited ComputeBtn: TButton
Top = 225
TabOrder = 4
end
inherited ResetBtn: TButton
Top = 225
TabOrder = 3
end
inherited HelpBtn: TButton
Tag = 168
Top = 225
TabOrder = 2
end
inherited ButtonBevel: TBevel
Top = 209
end
object Label1: TLabel[5]
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NcatsEdit Left = 59
Left = 168
Height = 30 Height = 30
Top = 65 Top = 0
Width = 166 Width = 166
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
@ -26,332 +41,83 @@ object SimpleChiSqrForm: TSimpleChiSqrForm
Caption = 'Enter the number of categories:'#13#10'Click the mouse after entering.' Caption = 'Enter the number of categories:'#13#10'Click the mouse after entering.'
ParentColor = False ParentColor = False
end end
object NcatsEdit: TEdit object ObsLabel: TLabel[6]
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 342
Height = 23
Top = 69
Width = 58
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 16
BorderSpacing.Right = 8
BorderSpacing.Bottom = 16
OnClick = NcatsEditExit
OnExit = NcatsEditExit
TabOrder = 0
Text = '1'
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 251
Height = 25
Top = 403
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 185
Height = 25
Top = 403
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 4
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 339
Height = 25
Top = 403
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 6
end
object Label5: TLabel
AnchorSideTop.Control = TotChiSqrEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = TotChiSqrEdit
Left = 152
Height = 15
Top = 341
Width = 96
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Total ChiSquare = '
ParentColor = False
end
object TotChiSqrEdit: TEdit
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ProbEdit
Left = 256
Height = 23
Top = 337
Width = 144
Alignment = taRightJustify
Anchors = [akRight, akBottom]
BorderSpacing.Top = 12
BorderSpacing.Bottom = 4
ReadOnly = True
TabOrder = 2
end
object Label6: TLabel
AnchorSideTop.Control = ProbEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ProbEdit
Left = 172
Height = 15
Top = 368
Width = 76
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Probability >='
ParentColor = False
end
object ProbEdit: TEdit
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 256
Height = 23
Top = 364
Width = 144
Alignment = taRightJustify
Anchors = [akRight, akBottom]
BorderSpacing.Top = 3
ReadOnly = True
TabOrder = 3
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0 Left = 0
Height = 8
Top = 387
Width = 408
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 45
Top = 8
Width = 392
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 8
Caption = 'This procedure lets you enter the number of observed values and the number of expected values for one or more categories. Enter the values as indicated and when finished, press the compute button.'
ParentColor = False
WordWrap = True
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = NcatsEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = TotChiSqrEdit
Left = 8
Height = 217
Top = 108
Width = 392
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 24
ChildSizing.EnlargeHorizontal = crsScaleChilds
ChildSizing.EnlargeVertical = crsScaleChilds
ChildSizing.ShrinkHorizontal = crsHomogenousChildResize
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 217
ClientWidth = 392
TabOrder = 1
object Panel2: TPanel
Left = 0
Height = 217
Top = 0
Width = 115
BevelOuter = bvNone
ClientHeight = 217
ClientWidth = 115
TabOrder = 0
object Label2: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel2
Left = 18
Height = 15 Height = 15
Top = 0 Top = 56
Width = 79 Width = 63
BorderSpacing.Left = 8 Caption = 'Frequencies'
Caption = 'Freq. Observed'
Constraints.MinHeight = 15 Constraints.MinHeight = 15
ParentColor = False ParentColor = False
end end
object ObservedGrid: TStringGrid object Bevel1: TBevel[7]
AnchorSideLeft.Control = Panel2 AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label2 AnchorSideLeft.Side = asrCenter
Left = 137
Height = 68
Top = 104
Width = 16
Shape = bsSpacer
end
object DataGrid: TStringGrid[8]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ObsLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2 AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel2 AnchorSideBottom.Control = ButtonBevel
AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 200 Height = 136
Top = 17 Top = 73
Width = 115 Width = 291
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
AutoAdvance = aaDown
AutoFillColumns = True AutoFillColumns = True
BorderSpacing.Top = 2 BorderSpacing.Top = 2
ColCount = 1 ColCount = 3
Constraints.MinHeight = 200 DefaultColWidth = 30
FixedCols = 0
MouseWheelOption = mwGrid MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goThumbTracking, goSmoothScroll] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goThumbTracking, goSmoothScroll, goFixedRowNumbering]
RowCount = 2
TabOrder = 0
ColWidths = (
111
)
end
end
object Panel3: TPanel
Left = 139
Height = 217
Top = 0
Width = 115
BevelOuter = bvNone
ClientHeight = 217
ClientWidth = 115
TabOrder = 1 TabOrder = 1
object Label3: TLabel OnPrepareCanvas = DataGridPrepareCanvas
AnchorSideLeft.Control = Panel3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel3
Left = 17
Height = 15
Top = 0
Width = 80
Caption = 'Freq. Expected:'
Constraints.MaxHeight = 15
ParentColor = False
end
object ExpectedGrid: TStringGrid
AnchorSideLeft.Control = Panel3
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel3
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 200
Top = 17
Width = 115
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True
BorderSpacing.Top = 2
ColCount = 1
FixedCols = 0
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 0
ColWidths = ( ColWidths = (
111 30
128
129
)
Cells = (
2
1
0
'Observed'
2
0
'Expected'
) )
end end
end object NcatsEdit: TSpinEdit[9]
object Panel4: TPanel AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Side = asrBottom AnchorSideTop.Control = ParamsPanel
Left = 278 AnchorSideRight.Control = ParamsPanel
Height = 217
Top = 0
Width = 114
BevelOuter = bvNone
ClientHeight = 217
ClientWidth = 114
TabOrder = 2
object Label4: TLabel
AnchorSideLeft.Control = Panel4
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel4
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 11 Left = 233
Height = 15 Height = 23
Top = 0 Top = 4
Width = 93 Width = 58
BorderSpacing.Right = 8 Anchors = [akTop, akRight]
Caption = 'Computed Values' BorderSpacing.Left = 8
ParentColor = False BorderSpacing.Top = 4
end BorderSpacing.Bottom = 16
object ChiSqrGrid: TStringGrid MaxValue = 65535
AnchorSideLeft.Control = Panel4 MinValue = 1
AnchorSideTop.Control = Label4 OnEditingDone = NcatsEditEditingDone
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel4
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel4
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 200
Top = 17
Width = 114
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True
BorderSpacing.Top = 2
ColCount = 1
FixedCols = 0
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 0 TabOrder = 0
ColWidths = ( Value = 1
110
)
end end
end end
inherited ParamsSplitter: TSplitter
Height = 266
end end
end end

View File

@ -5,157 +5,145 @@ unit SimpleChiSqrUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, SpinEx, Forms, Controls, Graphics, Dialogs,
StdCtrls, Grids, ExtCtrls, StdCtrls, Grids, ExtCtrls, Spin,
MainUnit, Globals, FunctionsLib, OutputUnit; Globals, FunctionsLib, BasicStatsReportFormUnit;
type type
{ TSimpleChiSqrForm } { TSimpleChiSqrForm }
TSimpleChiSqrForm = class(TForm) TSimpleChiSqrForm = class(TBasicStatsReportForm)
Bevel1: TBevel; Bevel1: TBevel;
ComputeBtn: TButton; NcatsEdit: TSpinEdit;
Memo1: TLabel; ObsLabel: TLabel;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
ProbEdit: TEdit;
Label6: TLabel;
TotChiSqrEdit: TEdit;
Label5: TLabel;
ResetBtn: TButton;
ReturnBtn: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
NcatsEdit: TEdit;
Label1: TLabel; Label1: TLabel;
ObservedGrid: TStringGrid; DataGrid: TStringGrid;
ExpectedGrid: TStringGrid; procedure DataGridPrepareCanvas(Sender: TObject; {%H-}ACol, ARow: Integer;
ChiSqrGrid: TStringGrid; {%H-}AState: TGridDrawState);
procedure ComputeBtnClick(Sender: TObject); procedure NcatsEditEditingDone(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure NcatsEditExit(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private private
{ private declarations }
FAutoSized: Boolean; protected
NoCats: integer; procedure AdjustConstraints; override;
procedure Compute; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end; end;
var var
SimpleChiSqrForm: TSimpleChiSqrForm; SimpleChiSqrForm: TSimpleChiSqrForm;
implementation implementation
uses {$R *.lfm}
Math;
{ TSimpleChiSqrForm } { TSimpleChiSqrForm }
procedure TSimpleChiSqrForm.NcatsEditExit(Sender: TObject); constructor TSimpleChiSqrForm.Create(AOwner: TComponent);
begin begin
NoCats := StrToInt(NcatsEdit.Text); inherited;
ObservedGrid.RowCount := NoCats+1; NCatsEdit.Value := 1;
ExpectedGrid.RowCount := NoCats+1;
ChiSqrGrid.RowCount := NoCats+1;
end; end;
procedure TSimpleChiSqrForm.ComputeBtnClick(Sender: TObject);
var procedure TSimpleChiSqrForm.AdjustConstraints;
TotalChiSqr : double;
ChiSqr, Obs, Exp, ChiProb, NObs, NExp : double;
i : integer;
outline : string;
begin begin
OutputFrm.RichEdit.Clear; inherited;
OutputFrm.RichEdit.Lines.Add('Simple Chi-Square Analysis Results'); ParamsPanel.Constraints.MinWidth := 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left;
OutputFrm.RichEdit.Lines.Add('Category ChiSquare'); ParamsPanel.Constraints.MinHeight := 300;
end;
procedure TSimpleChiSqrForm.Compute;
var
totalChiSqr, chiSqr, ObsValue, ExpValue, chiProb: double;
i, nObs, nExp: integer;
lReport: TStrings;
noCats: Integer;
begin
noCats := DataGrid.RowCount - DataGrid.FixedRows;
lReport := TStringList.Create;
try
lReport.Add('SIMPLE CHI-SQUARE ANALYSIS RESULTS');
lReport.Add('');
lReport.Add('Number of categories: ' + IntToStr(noCats));
lReport.Add('');
lReport.Add('Category Observed Expected ChiSquare ');
lReport.Add('-------- ---------- ---------- ----------');
TotalChiSqr := 0.0; TotalChiSqr := 0.0;
NObs := 0.0; nObs := 0;
NExp := 0.0; nExp := 0;
for i := 1 to NoCats do for i := 1 to NoCats do
begin begin
Obs := StrToFloat(ObservedGrid.Cells[0,i]); ObsValue := StrToFloat(DataGrid.Cells[1, i]);
NObs := NObs + 1; nObs := nObs + 1;
Exp := StrToFloat(ExpectedGrid.Cells[0,i]); ExpValue := StrToFloat(DataGrid.Cells[2, i]);
NExp := NExp + 1; if ExpValue <> 0 then
chisqr := sqr(Obs - Exp) / Exp; begin
outline := format('%8.3f',[chisqr]); nExp := nExp + 1;
ChiSqrGrid.Cells[0,i] := outline; chisqr := sqr(ObsValue - ExpValue) / ExpValue;
TotalChiSqr := TotalChiSqr + chisqr; totalChiSqr := totalChiSqr + chisqr;
outline := format(' %2d %8.3f',[i,chisqr]); lReport.Add('%8d %10.3f %10.3f %10.3f', [i, obsValue, expValue, chiSqr]);
OutputFrm.RichEdit.Lines.Add(outline); end else
lReport.Add('%8d %10.3f %10.3f %-10s', [i, obsValue, expvalue, 'ERROR: Division by 0']);
end;
lReport.Add('');
chiProb := 1.0 - ChiSquaredProb(totalChiSqr, nExp);
lReport.Add('Number observed: %8d', [nObs]);
lReport.Add('Number expected: %8d', [nExp]);
lReport.Add('Total Chi-Square: %8.3f', [totalChiSqr]);
lReport.Add(' with probability of a larger value %8.3f', [chiProb]);
FReportFrame.Displayreport(lReport);
finally
lReport.Free;
end; end;
OutputFrm.RichEdit.Lines.Add('');
TotChiSqrEdit.Text := FloatToStr(TotalChiSqr);
ChiProb := 1.0 - ChiSquaredProb(TotalChiSqr,NoCats);
ProbEdit.Text := FloatToStr(ChiProb);
outline := format('Number Observed = %8.3f',[NObs]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('Number Expected = %8.3f',[NExp]);
OutputFrm.RichEdit.Lines.Add(outline);
outline := format('ChiSquare = %8.3f with Probability of a larger value = %8.3f',
[TotalChiSqr,ChiProb]);
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.ShowModal;
OutputFrm.RichEdit.Clear;
end; end;
procedure TSimpleChiSqrForm.FormActivate(Sender: TObject);
procedure TSimpleChiSqrForm.DataGridPrepareCanvas(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState);
var var
w: Integer; grid: TStringGrid;
ts: TTextStyle;
begin begin
if FAutoSized then grid := (Sender as TStringGrid);
exit; ts := grid.Canvas.TextStyle;
if ARow > 0 then
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]); ts.Alignment := taRightJustify
ResetBtn.Constraints.MinWidth := w; else
ComputeBtn.Constraints.MinWidth := w; ts.Alignment := taCenter;
ReturnBtn.Constraints.MinWidth := w; grid.Canvas.TextStyle := ts;
FAutoSized := true;
end; end;
procedure TSimpleChiSqrForm.FormCreate(Sender: TObject);
procedure TSimpleChiSqrForm.NcatsEditEditingDone(Sender: TObject);
begin begin
Assert(OS3MainFrm <> nil); DataGrid.RowCount := NCatsEdit.Value + DataGrid.FixedRows;
if OutputFrm = nil then
Application.CreateForm(TOutputFrm, OutputFrm);
end; end;
procedure TSimpleChiSqrForm.FormResize(Sender: TObject);
var procedure TSimpleChiSqrForm.Reset;
w: Integer;
dist: Integer;
begin begin
dist := ObservedGrid.BorderSpacing.Left + ChiSqrGrid.BorderSpacing.Right; inherited;
w := Width div 3 - dist;
ObservedGrid.Width := w; DataGrid.RowCount := NCatsEdit.Value + DataGrid.FixedRows;
ExpectedGrid.Width := w; DataGrid.Cols[1].Clear;
ChiSqrGrid.Width := w; DataGrid.Cols[2].Clear;
DataGrid.Cells[1, 0] := 'Observed';
DataGrid.Cells[2, 0] := 'Expected';
end; end;
procedure TSimpleChiSqrForm.ResetBtnClick(Sender: TObject);
begin
NoCats := 1;
ObservedGrid.RowCount := NoCats + 1;
ExpectedGrid.RowCount := NoCats + 1;
ChiSqrGrid.RowCount := NoCats + 1;
NCatsEdit.Text := '1';
ObservedGrid.Cells[0,0] := 'Observed';
ExpectedGrid.Cells[0,0] := 'Expected';
ChiSqrGrid.Cells[0,0] := 'ChiSquared';
end;
initialization
{$I simplechisqrunit.lrs}
end. end.