diff --git a/applications/lazstats/source/LazStats.lpi b/applications/lazstats/source/LazStats.lpi index a22bef228..7130451c1 100644 --- a/applications/lazstats/source/LazStats.lpi +++ b/applications/lazstats/source/LazStats.lpi @@ -629,7 +629,7 @@ - + diff --git a/applications/lazstats/source/forms/analysis/comparisons/ttestunit.pas b/applications/lazstats/source/forms/analysis/comparisons/ttestunit.pas index 8b92027de..92db94694 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/ttestunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/ttestunit.pas @@ -405,7 +405,7 @@ begin grp2 := StrToInt(Grp2CodeEdit.Text); end else begin - GetMinMax(OS3MainFrm.DataGrid, colNoSelected[1], colNoSelected, minf, maxf); + GetColMinMax(OS3MainFrm.DataGrid, colNoSelected[1], colNoSelected, minf, maxf); grp1 := round(minf); grp2 := round(maxf); end; diff --git a/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas b/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas index 1d9f167bf..2dfe5c59b 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas @@ -511,7 +511,7 @@ begin colNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, YVarEdit.Text); colNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, GroupVarEdit.Text); - GetMinMax(OS3MainFrm.DataGrid, colNoSelected[2], colNoSelected, minf, maxf); + GetColMinMax(OS3MainFrm.DataGrid, colNoSelected[2], colNoSelected, minf, maxf); grp1 := Round(minf); grp2 := Round(maxf); diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.lfm b/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.lfm index bc5216879..65217cd9d 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.lfm +++ b/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.lfm @@ -1,192 +1,144 @@ -object SuccIntFrm: TSuccIntFrm - Left = 864 - Height = 282 - Top = 391 - Width = 335 +inherited SuccIntFrm: TSuccIntFrm + Left = 637 + Height = 334 + Top = 284 + Width = 599 HelpType = htKeyword HelpKeyword = 'html/SuccessiveIntervalScaling.htm' - AutoSize = True Caption = 'Successive Interval Scaling' - ClientHeight = 282 - ClientWidth = 335 - OnActivate = FormActivate - OnCreate = FormCreate - OnShow = FormShow - Position = poMainFormCenter - LCLVersion = '2.1.0.0' - object Label1: TLabel - AnchorSideLeft.Control = VarList - AnchorSideTop.Control = Owner - Left = 8 - Height = 15 - Top = 8 - Width = 97 - BorderSpacing.Top = 8 - Caption = 'Available Variables' - ParentColor = False + ClientHeight = 334 + ClientWidth = 599 + inherited ParamsPanel: TPanel + Height = 318 + ClientHeight = 318 + inherited CloseBtn: TButton + Top = 293 + TabOrder = 8 + end + inherited ComputeBtn: TButton + Top = 293 + TabOrder = 7 + end + inherited ResetBtn: TButton + Top = 293 + TabOrder = 6 + end + inherited HelpBtn: TButton + Top = 293 + TabOrder = 5 + end + inherited ButtonBevel: TBevel + Top = 277 + end + object Label1: TLabel[5] + AnchorSideLeft.Control = VarList + AnchorSideTop.Control = ParamsPanel + Left = 0 + Height = 15 + Top = 0 + Width = 97 + Caption = 'Available Variables' + ParentColor = False + end + object Label2: TLabel[6] + AnchorSideLeft.Control = ItemList + AnchorSideTop.Control = ParamsPanel + Left = 171 + Height = 15 + Top = 0 + Width = 93 + Caption = 'Selected Variables' + ParentColor = False + end + object VarList: TListBox[7] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = Label1 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = AllBtn + AnchorSideBottom.Control = ButtonBevel + Left = 0 + Height = 260 + Top = 17 + Width = 119 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 2 + BorderSpacing.Right = 6 + ItemHeight = 0 + MultiSelect = True + OnDblClick = VarListDblClick + OnSelectionChange = VarListSelectionChange + TabOrder = 0 + end + object InBtn: TBitBtn[8] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = VarList + Left = 132 + Height = 26 + Top = 17 + Width = 26 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = InBtnClick + Spacing = 0 + TabOrder = 1 + end + object OutBtn: TBitBtn[9] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = InBtn + AnchorSideTop.Side = asrBottom + Left = 132 + Height = 26 + Top = 47 + Width = 26 + BorderSpacing.Top = 4 + Images = MainDataModule.ImageList + ImageIndex = 0 + OnClick = OutBtnClick + Spacing = 0 + TabOrder = 2 + end + object AllBtn: TBitBtn[10] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = OutBtn + AnchorSideTop.Side = asrBottom + Left = 125 + Height = 25 + Top = 105 + Width = 40 + AutoSize = True + BorderSpacing.Top = 32 + Caption = 'All' + OnClick = AllBtnClick + Spacing = 0 + TabOrder = 3 + end + object ItemList: TListBox[11] + AnchorSideLeft.Control = AllBtn + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label2 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = VarList + AnchorSideBottom.Side = asrBottom + Left = 171 + Height = 260 + Top = 17 + Width = 120 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Left = 6 + BorderSpacing.Top = 2 + ItemHeight = 0 + MultiSelect = True + OnDblClick = ItemListDblClick + OnSelectionChange = VarListSelectionChange + TabOrder = 4 + end end - object Label2: TLabel - AnchorSideLeft.Control = ItemList - AnchorSideTop.Control = Owner - Left = 198 - Height = 15 - Top = 8 - Width = 93 - BorderSpacing.Top = 8 - Caption = 'Selected Variables' - ParentColor = False - end - object VarList: TListBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Label1 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = AllBtn - AnchorSideBottom.Control = Bevel1 - Left = 8 - Height = 208 - Top = 25 - Width = 128 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - Constraints.MinHeight = 200 - ItemHeight = 0 - MultiSelect = True - OnSelectionChange = VarListSelectionChange - TabOrder = 0 - end - object InBtn: TBitBtn - AnchorSideLeft.Control = Owner - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = VarList - Left = 153 - Height = 28 - Top = 25 - Width = 28 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = InBtnClick - Spacing = 0 - TabOrder = 1 - end - object OutBtn: TBitBtn - AnchorSideLeft.Control = Owner - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = InBtn - AnchorSideTop.Side = asrBottom - Left = 153 - Height = 28 - Top = 57 - Width = 28 - BorderSpacing.Top = 4 - Images = MainDataModule.ImageList - ImageIndex = 0 - OnClick = OutBtnClick - Spacing = 0 - TabOrder = 2 - end - object AllBtn: TBitBtn - AnchorSideLeft.Control = Owner - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = VarList - AnchorSideTop.Side = asrCenter - Left = 144 - Height = 25 - Top = 117 - Width = 46 - AutoSize = True - Caption = 'ALL' - OnClick = AllBtnClick - Spacing = 0 - TabOrder = 3 - end - object ItemList: TListBox - AnchorSideLeft.Control = AllBtn - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Label2 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Bevel1 - Left = 198 - Height = 208 - Top = 25 - Width = 129 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - ItemHeight = 0 - MultiSelect = True - OnSelectionChange = VarListSelectionChange - TabOrder = 4 - end - object ResetBtn: TButton - AnchorSideRight.Control = ComputeBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 126 - Height = 25 - Top = 249 - Width = 54 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 5 - end - object ComputeBtn: TButton - AnchorSideRight.Control = CloseBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 188 - Height = 25 - Top = 249 - Width = 76 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick - TabOrder = 6 - end - object CloseBtn: TButton - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 272 - Height = 25 - Top = 249 - Width = 55 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Close' - ModalResult = 11 - TabOrder = 7 - end - object Bevel1: TBevel - AnchorSideLeft.Control = Owner - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CloseBtn - Left = 0 - Height = 8 - Top = 233 - Width = 335 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine + inherited ParamsSplitter: TSplitter + Height = 334 end end diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.pas b/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.pas index a48a9e9ab..04c867f88 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.pas +++ b/applications/lazstats/source/forms/analysis/measurement_programs/succintunit.pas @@ -1,6 +1,6 @@ // Test file: sucsintv.laz, use all variables. -// TODO: Different output for VAR5 scale value in "Estimates of scale values..." +// TODO: Different output from OpenStat for VAR5 scale value in "Estimates of scale values..." unit SuccIntUnit; @@ -9,19 +9,15 @@ unit SuccIntUnit; interface uses - Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, ExtCtrls, - MainUnit, OutputUnit, FunctionsLib, Globals, DataProcs; + MainUnit, FunctionsLib, Globals, BasicStatsReportFormUnit; type { TSuccIntFrm } - TSuccIntFrm = class(TForm) - Bevel1: TBevel; - ResetBtn: TButton; - ComputeBtn: TButton; - CloseBtn: TButton; + TSuccIntFrm = class(TBasicStatsReportForm) InBtn: TBitBtn; OutBtn: TBitBtn; AllBtn: TBitBtn; @@ -30,20 +26,21 @@ type ItemList: TListBox; VarList: TListBox; procedure AllBtnClick(Sender: TObject); - procedure ComputeBtnClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormShow(Sender: TObject); procedure InBtnClick(Sender: TObject); + procedure ItemListDblClick(Sender: TObject); procedure OutBtnClick(Sender: TObject); - procedure ResetBtnClick(Sender: TObject); + procedure VarListDblClick(Sender: TObject); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); private - { private declarations } - FAutoSized: Boolean; - procedure UpdateBtnStates; + + protected + procedure AdjustConstraints; override; + procedure Compute; override; + procedure UpdateBtnStates; override; + function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; + public - { public declarations } + procedure Reset; override; end; var @@ -51,52 +48,23 @@ var implementation +{$R *.lfm} + uses - Math, Utils; + GridProcs; { TSuccIntFrm } -procedure TSuccIntFrm.ResetBtnClick(Sender: TObject); -var - i: integer; +procedure TSuccIntFrm.AdjustConstraints; begin - VarList.Clear; - ItemList.Clear; - for i := 1 to NoVariables do - VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); - UpdateBtnStates; + inherited; + + ParamsPanel.Constraints.MinWidth := 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left; + ParamsPanel.Constraints.MinHeight := AllBtn.Top + AllBtn.Height + + VarList.BorderSpacing.Bottom + ButtonBevel.Height + + CloseBtn.Height + CloseBtn.BorderSpacing.Top; end; -procedure TSuccIntFrm.FormActivate(Sender: TObject); -var - w: Integer; -begin - if FAutoSized then - exit; - - w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); - ResetBtn.Constraints.MinWidth := w; - ComputeBtn.Constraints.MinWidth := w; - CloseBtn.Constraints.MinWidth := w; - - Constraints.MinWidth := Max( - 2*MaxValue([Label1.Width, Label2.Width]) + 2*AllBtn.Width + 4*VarList.BorderSpacing.Left, // 2 * AllBtn.Width to avoid window to get too narrow - 3*w + 4*CloseBtn.BorderSpacing.Right - ); - Constraints.MinHeight := Height; - - FAutoSized := true; -end; - -procedure TSuccIntFrm.FormCreate(Sender: TObject); -begin - Assert(OS3MainFrm <> nil); -end; - -procedure TSuccIntFrm.FormShow(Sender: TObject); -begin - ResetBtnClick(self); -end; procedure TSuccIntFrm.AllBtnClick(Sender: TObject); var @@ -108,30 +76,33 @@ begin UpdateBtnStates; end; -procedure TSuccIntFrm.ComputeBtnClick(Sender: TObject); + +procedure TSuccIntFrm.Compute; var i, j, k, col, X, NoSelected, MaxCat, count, subscript: integer; discrow: integer; - CatCount: IntDyneVec; - ColNoSelected: IntDyneVec; - FreqMat: IntDyneMat; - RowTots: IntDyneVec; - PropMat, Zmatrix, WidthMat, TheorZMat, ThCumPMat, CumMat: DblDyneMat; - DiscDisp, Mean, StdDev, CumWidth, ScaleValue: DblDyneVec; + CatCount: IntDyneVec = nil; + ColNoSelected: IntDyneVec = nil; + FreqMat: IntDyneMat = nil; + RowTots: IntDyneVec = nil; + PropMat: DblDyneMat = nil; + Zmatrix: DblDyneMat = nil; + WidthMat: DblDyneMat = nil; + TheorZMat: DblDyneMat = nil; + ThCumPMat: DblDyneMat = nil; + CumMat: DblDyneMat = nil; + DiscDisp: DblDyneVec = nil; + Mean: DblDyneVec = nil; + StdDev: DblDyneVec = nil; + CumWidth: DblDyneVec = nil; + ScaleValue: DblDyneVec = nil; + RowLabels: StrDyneVec = nil; + ColLabels: StrDyneVec = nil; d1, d2, C1, L1, L2, t3, sum, discrep, z, prop, maxdiscrep: double; - RowLabels, ColLabels: StrDyneVec; outline: string; - Save_Cursor: TCursor; found: boolean; lReport: TStrings; begin - if ItemList.Items.Count = 0 then - begin - ErrorMsg('No variables selected.'); - exit; - end; - - MaxCat := 0; L1 := 0.01; L2 := 0.99; maxdiscrep := 0.0; @@ -140,10 +111,14 @@ begin SetLength(DiscDisp,NoVariables); SetLength(ScaleValue,NoVariables); SetLength(RowLabels,NoVariables); - SetLength(ColNoSelected,NoVariables); +// SetLength(ColNoSelected,NoVariables); // Get items selected NoSelected := ItemList.Items.Count; + SetLength(ColNoSelected, NoSelected); + for i := 0 to NoSelected-1 do + ColNoSelected[i] := GetVariableIndex(OS3MainFrm.DataGrid, ItemList.Items[i]); + { for i := 1 to NoSelected do begin for j := 1 to NoVariables do @@ -152,6 +127,7 @@ begin if outline = OS3MainFrm.DataGrid.Cells[j,0] then ColNoSelected[i-1] := j; end; end; + } (* OutputFrm.RichEdit.Lines.Add('check of parameters'); @@ -168,10 +144,18 @@ begin OutputFrm.RichEdit.Clear; *) -//Find largest category value in data + //Find largest category value in data + MaxCat := 0; + for j := 0 to NoSelected-1 do + begin + X := round(GetColMax(OS3MainFrm.DataGrid, ColNoSelected[j], ColNoSelected)); + if X > MaxCat then MaxCat := X; + end; + { + GetColMax(OS3MainFrm.DataGrid, for i := 1 to NoCases do begin - if (not GoodRecord(i,NoSelected,ColNoSelected)) then continue; + if (not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected)) then continue; for j := 1 to NoSelected do begin col := ColNoSelected[j-1]; @@ -179,6 +163,7 @@ begin if (X > MaxCat) then MaxCat := X; end; end; + } // Initialize arrays SetLength(CatCount, MaxCat); @@ -195,43 +180,16 @@ begin SetLength(CumWidth, MaxCat); SetLength(ColLabels, MaxCat); - for i := 0 to NoSelected-1 do + // Build frequency matrix + for i := 0 to NoCases-1 do begin - RowTots[i] := 0; - DiscDisp[i] := 0.0; - ScaleValue[i] := 0.0; - for j := 0 to MaxCat-1 do + if (not GoodRecord(OS3MainFrm.DataGrid, i+1, ColNoSelected)) then continue; + for j := 0 to NoSelected-1 do begin - FreqMat[i,j] := 0; - PropMat[i,j] := 0.0; - CumMat[i,j] := 0.0; - Zmatrix[i,j] := 0.0; - WidthMat[i,j] := 0.0; - TheorZMat[i,j] := 0.0; - ThCumPMat[i,j] := 0.0; - end; - end; - for j := 0 to MaxCat-1 do - begin - CumWidth[j] := 0.0; - StdDev[j] := 0.0; - Mean[j] := 0.0; - CatCount[j] := 0; - end; - - Save_Cursor := Screen.Cursor; // save current cursor - Screen.Cursor := crHourGlass; // Show hourglass cursor - - //Build frequency matrix - for i := 1 to NoCases do - begin - if (not GoodRecord(i,NoSelected,ColNoSelected)) then continue; - for j := 1 to NoSelected do - begin - col := ColNoSelected[j-1]; - X := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[col,i]))); + col := ColNoSelected[j]; + X := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[col, i+1]))); if (X > 0) and (X <= MaxCat) then - FreqMat[j-1, X-1] := FreqMat[j-1, X-1] + 1; + FreqMat[j, X-1] := FreqMat[j, X-1] + 1; end; end; @@ -240,13 +198,13 @@ begin begin RowTots[i] := 0; for j := 0 to MaxCat-1 do - RowTots[i] := RowTots[i] + FreqMat[i,j]; + RowTots[i] := RowTots[i] + FreqMat[i, j]; end; // Convert frequencies to proportions of the row totals for i := 0 to NoSelected-1 do for j := 0 to MaxCat-1 do - PropMat[i,j] := FreqMat[i,j] / RowTots[i]; + PropMat[i, j] := FreqMat[i, j] / RowTots[i]; // Accumulate the proportions accross the categories for i := 1 to NoSelected do @@ -312,25 +270,25 @@ begin // Now, calculate interval widths for j := 2 to MaxCat - 1 do begin - for i := 1 to NoSelected do + for i := 0 to NoSelected-1 do begin - if (Zmatrix[i-1, j-1] <> 99.0) and (Zmatrix[i-1, j-2] <> 99.0) then - WidthMat[i-1, j-2] := Zmatrix[i-1, j-1] - Zmatrix[i-1, j-2] + if (Zmatrix[i, j-1] <> 99.0) and (Zmatrix[i, j-2] <> 99.0) then + WidthMat[i, j-2] := Zmatrix[i, j-1] - Zmatrix[i, j-2] else - WidthMat[i-1, j-2] := 99.0; + WidthMat[i, j-2] := 99.0; end; end; //Calculate Means and Standard Deviations of category Widths for j := 1 to MaxCat-2 do begin - for i := 1 to NoSelected do + for i := 0 to NoSelected-1 do begin - if (WidthMat[i-1,j-1] <> 99.0) then + if (WidthMat[i,j-1] <> 99.0) then begin CatCount[j-1] := CatCount[j-1] + 1; - Mean[j-1] := Mean[j-1] + WidthMat[i-1,j-1]; - StdDev[j-1] := StdDev[j-1] + (WidthMat[i-1,j-1] * WidthMat[i-1,j-1]); + Mean[j-1] := Mean[j-1] + WidthMat[i, j-1]; + StdDev[j-1] := StdDev[j-1] + (WidthMat[i, j-1] * WidthMat[i, j-1]); end; end; if (CatCount[j-1] > 1) then @@ -416,44 +374,44 @@ begin try lReport.Add('SUCCESSIVE INTERVAL SCALING RESULTS'); lReport.Add(''); - for i := 1 to NoSelected do - RowLabels[i-1] := OS3MainFrm.DataGrid.Cells[ColNoSelected[i-1],0]; - for i := 1 to MaxCat do - ColLabels[i-1] := Format(' %2d-%2d ', [i-1, i]); + for i := 0 to NoSelected-1 do + RowLabels[i] := OS3MainFrm.DataGrid.Cells[ColNoSelected[i],0]; + for i := 0 to MaxCat-1 do + ColLabels[i] := Format(' %2d-%2d ', [i, i+1]); outline := ' '; - for i := 1 to MaxCat do outline := outline + ColLabels[i-1]; + for i := 0 to MaxCat-1 do outline := outline + ColLabels[i]; lReport.Add(outline); outline := ' '; - for i := 1 to MaxCat do outline := outline + ' ------ '; + for i := 0 to MaxCat-1 do outline := outline + ' ------ '; lReport.Add(outline); - for i := 1 to NoSelected do + for i := 0 to NoSelected-1 do begin - if i > 1 then + if i > 0 then lReport.Add(''); - lReport.Add('%10s', [RowLabels[i-1]]); + lReport.Add('%10s', [RowLabels[i]]); outline := 'Frequency '; - for j := 1 to MaxCat do - outline := outline + Format('%8d', [FreqMat[i-1,j-1]]); + for j := 0 to MaxCat-1 do + outline := outline + Format('%8d', [FreqMat[i, j]]); lReport.Add(outline); outline := 'Proportion '; - for j := 1 to MaxCat do - outline := outline + Format('%8.3f', [PropMat[i-1,j-1]]); + for j := 0 to MaxCat-1 do + outline := outline + Format('%8.3f', [PropMat[i, j]]); lReport.Add(outline); outline := 'Cum. Prop. '; - for j := 1 to MaxCat do - outline := outline + Format('%8.3f', [CumMat[i-1,j-1]]); + for j := 0 to MaxCat-1 do + outline := outline + Format('%8.3f', [CumMat[i, j]]); lReport.Add(outline); outline := 'Normal z '; - for j := 1 to MaxCat do + for j := 0 to MaxCat-1 do begin - if (Zmatrix[i-1,j-1] <> 99.0) then - outline := outline + Format('%8.3f', [Zmatrix[i-1,j-1]]) + if (Zmatrix[i, j] <> 99.0) then + outline := outline + Format('%8.3f', [Zmatrix[i, j]]) else outline := outline + ' -'; end; @@ -475,15 +433,14 @@ begin outline := outline + ' ------ '; lReport.Add(outline); - outline := ''; - for i := 1 to NoSelected do + for i := 0 to NoSelected-1 do begin - outline := outline + Format('%11s', [RowLabels[i-1]]); - for j := 1 to MaxCat-2 do + outline := outline + Format('%11s', [RowLabels[i]]); + for j := 0 to MaxCat-3 do begin - if (WidthMat[i-1,j-1] <> 99.0) then - outline := outline + Format('%8.3f', [WidthMat[i-1,j-1]]) + if (WidthMat[i, j] <> 99.0) then + outline := outline + Format('%8.3f', [WidthMat[i, j]]) else outline := outline + ' -'; end; @@ -493,23 +450,23 @@ begin lReport.Add(''); outline := 'Mean Width '; - for i := 1 to MaxCat - 2 do - outline := outline + Format('%8.2f', [Mean[i-1]]); + for i := 0 to MaxCat - 3 do + outline := outline + Format('%8.2f', [Mean[i]]); lReport.Add(outline); outline := 'No. Items '; - for i := 1 to MaxCat - 2 do - outline := outline + Format('%8d', [CatCount[i-1]]); + for i := 0 to MaxCat - 3 do + outline := outline + Format('%8d', [CatCount[i]]); lReport.Add(outline); outline := 'Std. Dev.s '; - for i := 1 to MaxCat - 2 do - outline := outline + Format('%8.2f', [StdDev[i-1]]);; + for i := 0 to MaxCat - 3 do + outline := outline + Format('%8.2f', [StdDev[i]]);; lReport.Add(outline); outline := 'Cum. Means '; - for i := 1 to MaxCat - 2 do - outline := outline + Format('%8.2f', [CumWidth[i-1]]); + for i := 0 to MaxCat - 3 do + outline := outline + Format('%8.2f', [CumWidth[i]]); lReport.Add(outline); lReport.Add(''); @@ -533,11 +490,11 @@ begin outline := ' '; for i := 0 to MaxCat-1 do outline := outline + ' ------ '; lReport.Add(outline); - for i := 1 to NoSelected do + for i := 0 to NoSelected-1 do begin - outline := Format('%10s', [RowLabels[i-1]]); - for j := 1 to MaxCat - 1 do - outline := outline + Format('%8.3f', [TheorZMat[i-1,j-1]]); + outline := Format('%10s', [RowLabels[i]]); + for j := 0 to MaxCat - 2 do + outline := outline + Format('%8.3f', [TheorZMat[i, j]]); lReport.Add(outline); end; @@ -545,19 +502,19 @@ begin lReport.Add(DIVIDER_SMALL); lReport.Add(''); - lReport.Add('Cumulative Theoretical Proportions'); + lReport.Add('CUMULATIVE THEORETICAL PROPORTIONS'); lReport.Add(''); outline := ' '; - for i := 1 to MaxCat do outline := outline + ColLabels[i-1]; + for i := 0 to MaxCat-1 do outline := outline + ColLabels[i]; lReport.Add(outline); outline := ' '; - for i := 1 to MaxCat do outline := outline + ' ------ '; + for i := 0 to MaxCat-1 do outline := outline + ' ------ '; lReport.Add(outline); - for i := 1 to NoSelected do + for i := 0 to NoSelected-1 do begin - outline := Format('%10s', [RowLabels[i-1]]); - for j := 1 to MaxCat do - outline := outline + Format('%8.3f', [ThCumPMat[i-1,j-1]]); + outline := Format('%10s', [RowLabels[i]]); + for j := 0 to MaxCat-1 do + outline := outline + Format('%8.3f', [ThCumPMat[i, j]]); lReport.Add(outline); end; lReport.Add(''); @@ -565,32 +522,14 @@ begin lReport.Add('Average Discrepancy Between Theoretical and Observed Cumulative Proportions: %.3f', [discrep]); lReport.Add('Maximum discrepancy %.3f found in item %s', [maxdiscrep, RowLabels[discrow-1]]); - Screen.Cursor := Save_Cursor; - DisplayReport(lReport); + FReportFrame.DisplayReport(lReport); finally lReport.Free; - - ColLabels := nil; - RowLabels := nil; - ScaleValue := nil; - CumWidth := nil; - StdDev := nil; - Mean := nil; - DiscDisp := nil; - CumMat := nil; - ThCumPMat := nil; - TheorZMat := nil; - WidthMat := nil; - Zmatrix := nil; - PropMat := nil; - RowTots := nil; - FreqMat := nil; - CatCount := nil; - ColNoSelected := nil; end; end; + procedure TSuccIntFrm.InBtnClick(Sender: TObject); var i: integer; @@ -609,6 +548,21 @@ begin UpdateBtnStates; end; + +procedure TSuccIntFrm.ItemListDblClick(Sender: TObject); +var + index: Integer; +begin + index := ItemList.ItemIndex; + if index > -1 then + begin + VarList.Items.Add(ItemList.Items[index]); + ItemList.Items.Delete(index); + UpdateBtnStates; + end; +end; + + procedure TSuccIntFrm.OutBtnClick(Sender: TObject); var i: integer; @@ -627,11 +581,27 @@ begin UpdateBtnStates; end; + +procedure TSuccIntFrm.Reset; +var + i: integer; +begin + inherited; + ItemList.Clear; + VarList.Clear; + for i := 1 to NoVariables do + VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); + UpdateBtnStates; +end; + + procedure TSuccIntFrm.UpdateBtnStates; var lSelected: Boolean; i: Integer; begin + inherited; + lSelected := false; for i := 0 to VarList.Items.Count - 1 do if VarList.Selected[i] then @@ -653,13 +623,42 @@ begin AllBtn.Enabled := VarList.Items.Count > 0; end; + +function TSuccIntFrm.Validate(out AMsg: String; + out AControl: TWinControl): Boolean; +begin + Result := false; + + if ItemList.Items.Count = 0 then + begin + AMsg := 'No variables selected.'; + AControl := VarList; + exit; + end; + + Result := true; +end; + + +procedure TSuccIntFrm.VarListDblClick(Sender: TObject); +var + index: Integer; +begin + index := VarList.ItemIndex; + if index > -1 then + begin + ItemList.Items.Add(VarList.Items[index]); + VarList.Items.Delete(index); + UpdateBtnStates; + end; +end; + + procedure TSuccIntFrm.VarListSelectionChange(Sender: TObject; User: boolean); begin UpdateBtnStates; end; -initialization - {$I succintunit.lrs} end. diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm index ba8494b95..13d1ba3e7 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm +++ b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm @@ -1,4 +1,4 @@ -object TestScoreFrm: TTestScoreFrm +object TestScoreForm: TTestScoreForm Left = 501 Height = 575 Top = 204 @@ -13,7 +13,7 @@ object TestScoreFrm: TTestScoreFrm OnCreate = FormCreate OnShow = FormShow Position = poMainFormCenter - LCLVersion = '2.1.0.0' + LCLVersion = '2.0.10.0' object OptionsGroup: TGroupBox AnchorSideLeft.Control = Owner AnchorSideRight.Control = Owner diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas index 1ef596cbb..8c3889c55 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas +++ b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas @@ -14,9 +14,9 @@ uses type - { TTestScoreFrm } + { TTestScoreForm } - TTestScoreFrm = class(TForm) + TTestScoreForm = class(TForm) Bevel1: TBevel; MeansPlotChk: TCheckBox; HoytChk: TCheckBox; @@ -119,7 +119,7 @@ type end; var - TestScoreFrm: TTestScoreFrm; + TestScoreForm: TTestScoreForm; implementation @@ -127,9 +127,9 @@ uses Math, Utils, MatrixUnit, MathUnit; -{ TTestScoreFrm } +{ TTestScoreForm } -procedure TTestScoreFrm.ResetBtnClick(Sender: TObject); +procedure TTestScoreForm.ResetBtnClick(Sender: TObject); var i, j: integer; begin @@ -195,7 +195,7 @@ begin end; end; -procedure TTestScoreFrm.ResponseScrollChange(Sender: TObject); +procedure TTestScoreForm.ResponseScrollChange(Sender: TObject); var item, respno: integer; begin @@ -218,7 +218,7 @@ begin ScoreEdit.Text := FloatToStr(RespWghts[respno][item-1]); end; -procedure TTestScoreFrm.FormActivate(Sender: TObject); +procedure TTestScoreForm.FormActivate(Sender: TObject); var w: Integer; begin @@ -237,7 +237,7 @@ begin FAutoSized := true; end; -procedure TTestScoreFrm.FormCreate(Sender: TObject); +procedure TTestScoreForm.FormCreate(Sender: TObject); begin Assert(OS3MainFrm <> nil); @@ -247,12 +247,12 @@ begin Application.CreateForm(TGraphFrm, GraphFrm); end; -procedure TTestScoreFrm.FormShow(Sender: TObject); +procedure TTestScoreForm.FormShow(Sender: TObject); begin ResetBtnClick(self); end; -procedure TTestScoreFrm.IDInBtnClick(Sender: TObject); +procedure TTestScoreForm.IDInBtnClick(Sender: TObject); var index: integer; begin @@ -264,7 +264,7 @@ begin end; end; -procedure TTestScoreFrm.InBtnClick(Sender: TObject); +procedure TTestScoreForm.InBtnClick(Sender: TObject); var i: integer; begin @@ -284,7 +284,7 @@ begin ItemScroll.Max := ItemList.Items.Count; end; -procedure TTestScoreFrm.ItemScrollChange(Sender: TObject); +procedure TTestScoreForm.ItemScrollChange(Sender: TObject); var item, respno: integer; begin @@ -311,7 +311,7 @@ begin ScoreEdit.Text := FloatToStr(RespWghts[respno][item-1]); end; -procedure TTestScoreFrm.LastInBtnClick(Sender: TObject); +procedure TTestScoreForm.LastInBtnClick(Sender: TObject); var index: integer; begin @@ -324,7 +324,7 @@ begin end; end; -procedure TTestScoreFrm.OutBtnClick(Sender: TObject); +procedure TTestScoreForm.OutBtnClick(Sender: TObject); var i: integer; begin @@ -342,7 +342,7 @@ begin UpdateBtnStates; end; -procedure TTestScoreFrm.ComputeBtnClick(Sender: TObject); +procedure TTestScoreForm.ComputeBtnClick(Sender: TObject); var i, j, col, start, count: integer; cellstring: string; @@ -485,12 +485,12 @@ begin end; end; -procedure TTestScoreFrm.FirstChkClick(Sender: TObject); +procedure TTestScoreForm.FirstChkClick(Sender: TObject); begin ItemScoringGroup.Visible := not FirstChk.Checked; end; -procedure TTestScoreFrm.FirstInBtnClick(Sender: TObject); +procedure TTestScoreForm.FirstInBtnClick(Sender: TObject); var index: integer; begin @@ -503,7 +503,7 @@ begin end; end; -procedure TTestScoreFrm.ItemScores; +procedure TTestScoreForm.ItemScores; var start, i, j, k, count, col: integer; score, denom, fract: double; @@ -554,7 +554,7 @@ begin NCases := count; end; -procedure TTestScoreFrm.ScoreReport(AReport: TStrings); +procedure TTestScoreForm.ScoreReport(AReport: TStrings); var i, start, count, col: integer; outline, namestr: string; @@ -617,7 +617,7 @@ begin AReport.Add(''); end; -procedure TTestScoreFrm.Alpha(AReport: TStrings); +procedure TTestScoreForm.Alpha(AReport: TStrings); var i, j: integer; AlphaRel, SEMeas: double; @@ -662,7 +662,7 @@ begin AReport.Add(''); end; -procedure TTestScoreFrm.Cors(AReport: TStrings); +procedure TTestScoreForm.Cors(AReport: TStrings); var i, j, k: integer; title: string; @@ -735,7 +735,7 @@ begin end; end; -procedure TTestScoreFrm.SimMR(AReport: TStrings); +procedure TTestScoreForm.SimMR(AReport: TStrings); var i, j: integer; determinant, df1, df2, StdErr, x: double; @@ -842,7 +842,7 @@ begin CorrMat := nil; end; -procedure TTestScoreFrm.Hoyt(AReport: TStrings); +procedure TTestScoreForm.Hoyt(AReport: TStrings); var i, j: integer; Hoyt1, Hoyt2, Hoyt3, Hoyt4, SEMeas1, SEMeas2, SEMeas3, SEMeas4: double; @@ -933,7 +933,7 @@ begin AReport.Add(''); end; -procedure TTestScoreFrm.StepKR(AReport: TStrings); +procedure TTestScoreForm.StepKR(AReport: TStrings); var i, j, col: integer; score, KR20, meanscore, scorevar, sumvars, hicor: double; @@ -1060,12 +1060,12 @@ begin selected := nil; end; -procedure TTestScoreFrm.VarListSelectionChange(Sender: TObject; User: boolean); +procedure TTestScoreForm.VarListSelectionChange(Sender: TObject; User: boolean); begin UpdateBtnStates; end; -function TTestScoreFrm.PlotScores: Boolean; +function TTestScoreForm.PlotScores: Boolean; var rowvar: DblDyneVec; totscrs: DblDyneVec; @@ -1121,7 +1121,7 @@ begin GraphFrm.Ypoints := nil; end; -function TTestScoreFrm.PlotMeans: Boolean; +function TTestScoreForm.PlotMeans: Boolean; var rowvar: DblDyneVec; i: integer; @@ -1157,7 +1157,7 @@ begin GraphFrm.Ypoints := nil; end; -procedure TTestScoreFrm.UpdateBtnStates; +procedure TTestScoreForm.UpdateBtnStates; begin InBtn.Enabled := AnySelected(VarList); OutBtn.Enabled := AnySelected(ItemList); diff --git a/applications/lazstats/source/forms/analysis/multivariate/bartletttestunit.lfm b/applications/lazstats/source/forms/analysis/multivariate/bartletttestunit.lfm index 718854821..84d9e7c92 100644 --- a/applications/lazstats/source/forms/analysis/multivariate/bartletttestunit.lfm +++ b/applications/lazstats/source/forms/analysis/multivariate/bartletttestunit.lfm @@ -70,7 +70,7 @@ inherited BartlettTestForm: TBartlettTestForm object Label3: TLabel[7] AnchorSideLeft.Control = SelList AnchorSideTop.Control = ParamsPanel - Left = 188 + Left = 186 Height = 15 Top = 0 Width = 44 @@ -86,14 +86,13 @@ inherited BartlettTestForm: TBartlettTestForm AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = VarList AnchorSideBottom.Side = asrBottom - Left = 188 + Left = 186 Height = 282 Top = 17 - Width = 124 + Width = 134 Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 + BorderSpacing.Left = 6 BorderSpacing.Top = 2 - BorderSpacing.Right = 8 ItemHeight = 0 MultiSelect = True OnDblClick = SelListDblClick @@ -137,10 +136,10 @@ inherited BartlettTestForm: TBartlettTestForm AnchorSideTop.Side = asrBottom Left = 140 Height = 25 - Top = 77 + Top = 105 Width = 40 AutoSize = True - BorderSpacing.Top = 4 + BorderSpacing.Top = 32 Caption = 'All' OnClick = AllBtnClick Spacing = 0 diff --git a/applications/lazstats/source/forms/mainunit.pas b/applications/lazstats/source/forms/mainunit.pas index f650a9bd4..ec41b270d 100644 --- a/applications/lazstats/source/forms/mainunit.pas +++ b/applications/lazstats/source/forms/mainunit.pas @@ -768,9 +768,9 @@ end; // Menu "Analysis" > "Measurement Programs" > "Classical Test Analysis" procedure TOS3MainFrm.mnuAnalysisMeas_ClassicalClick(Sender: TObject); begin - if TestScoreFrm = nil then - Application.CreateForm(TTestScoreFrm, TestScoreFrm); - TestScoreFrm.ShowModal; + if TestScoreForm = nil then + Application.CreateForm(TTestScoreForm, TestScoreForm); + TestScoreForm.Show; end; // Menu "Analysis" > "Measurement Programs" > "Rasch Test Calibration" diff --git a/applications/lazstats/source/units/gridprocs.pas b/applications/lazstats/source/units/gridprocs.pas index ab8c83f3d..e1302425b 100644 --- a/applications/lazstats/source/units/gridprocs.pas +++ b/applications/lazstats/source/units/gridprocs.pas @@ -16,7 +16,9 @@ function CollectFilteredVecValues(AGrid: TStringGrid; AColIndex, AFilterColIndex function CollectMatValues(AGrid: TStringGrid; AColIndices: IntDyneVec): DblDyneMat; -procedure GetMinMax(AGrid: TStringGrid; AColIndex: Integer; +function GetColMax(AGrid: TStringGrid; AColIndex: Integer; const AColCheck: IntDyneVec): Double; + +procedure GetColMinMax(AGrid: TStringGrid; AColIndex: Integer; const AColCheck: IntDyneVec; out AMin, AMax: Double); function GetVariableIndex(AGrid: TStringGrid; const AVarName: String): Integer; @@ -143,10 +145,33 @@ begin end; +function GetColMax(AGrid: TStringGrid; AColIndex: Integer; + const AColCheck: IntDyneVec): Double; +var + row: Integer; + value: Double; +begin + Result := -Infinity; + for row := 1 to AGrid.RowCount-1 do + begin + if Length(AColCheck) = 0 then + begin + if not ValidValue(AGrid, row, AColIndex) then continue; + end else + begin + if not GoodRecord(AGrid, row, AColCheck) then continue; + end; + value := StrToFloat(trim(AGrid.Cells[AColIndex, row])); + if value > Result then + Result := value; + end; +end; + + { Determines the minimum and maximum of the values in the specified column of the grid. Rows with "invalid" data are ignored. If AColCheck contains other column indices these cells must be "valid", too. } -procedure GetMinMax(AGrid: TStringGrid; AColIndex: Integer; +procedure GetColMinMax(AGrid: TStringGrid; AColIndex: Integer; const AColCheck: IntDyneVec; out AMin, AMax: Double); var row: Integer;