LazStats: Refactor PolyDIFUnit. Update chm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7394 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-04-21 10:39:17 +00:00
parent 2d80d005dd
commit e2de5809db
4 changed files with 646 additions and 553 deletions

View File

@ -1,106 +1,86 @@
object PolyDIFFrm: TPolyDIFFrm object PolyDIFFrm: TPolyDIFFrm
Left = 548 Left = 984
Height = 413 Height = 413
Top = 305 Top = 356
Width = 631 Width = 657
AutoSize = True AutoSize = True
Caption = 'Polytomous Item DIF' Caption = 'Polytomous Item DIF'
ClientHeight = 413 ClientHeight = 413
ClientWidth = 631 ClientWidth = 657
OnActivate = FormActivate OnActivate = FormActivate
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
Position = poMainFormCenter Position = poMainFormCenter
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
object ResetBtn: TButton object ResetBtn: TButton
AnchorSideRight.Control = CancelBtn AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 334 Left = 448
Height = 25 Height = 25
Top = 380 Top = 380
Width = 54 Width = 54
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 12 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Reset' Caption = 'Reset'
OnClick = ResetBtnClick OnClick = ResetBtnClick
TabOrder = 3 TabOrder = 3
end end
object CancelBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 400
Height = 25
Top = 380
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 = 4
end
object ComputeBtn: TButton object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 474 Left = 510
Height = 25 Height = 25
Top = 380 Top = 380
Width = 76 Width = 76
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 12 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Compute' Caption = 'Compute'
OnClick = ComputeBtnClick OnClick = ComputeBtnClick
TabOrder = 5 TabOrder = 4
end end
object ReturnBtn: TButton object CloseBtn: TButton
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 562 Left = 594
Height = 25 Height = 25
Top = 380 Top = 380
Width = 61 Width = 55
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Return' Caption = 'Close'
ModalResult = 1 ModalResult = 11
OnClick = ReturnBtnClick TabOrder = 5
TabOrder = 6
end end
object HelpBtn: TButton object HelpBtn: TButton
Tag = 138 Tag = 138
AnchorSideRight.Control = ResetBtn AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 271 Left = 389
Height = 25 Height = 25
Top = 380 Top = 380
Width = 51 Width = 51
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 12 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Help' Caption = 'Help'
OnClick = HelpBtnClick OnClick = HelpBtnClick
@ -114,14 +94,14 @@ object PolyDIFFrm: TPolyDIFFrm
Left = 8 Left = 8
Height = 356 Height = 356
Top = 8 Top = 8
Width = 411 Width = 437
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 16 BorderSpacing.Right = 16
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 356 ClientHeight = 356
ClientWidth = 411 ClientWidth = 437
Constraints.MinWidth = 400 Constraints.MinWidth = 400
TabOrder = 0 TabOrder = 0
object Label1: TLabel object Label1: TLabel
@ -137,7 +117,7 @@ object PolyDIFFrm: TPolyDIFFrm
object Label2: TLabel object Label2: TLabel
AnchorSideLeft.Control = ItemsList AnchorSideLeft.Control = ItemsList
AnchorSideTop.Control = Panel1 AnchorSideTop.Control = Panel1
Left = 236 Left = 249
Height = 15 Height = 15
Top = 0 Top = 0
Width = 76 Width = 76
@ -147,7 +127,7 @@ object PolyDIFFrm: TPolyDIFFrm
object Label3: TLabel object Label3: TLabel
AnchorSideLeft.Control = ItemsList AnchorSideLeft.Control = ItemsList
AnchorSideBottom.Control = GroupVarEdit AnchorSideBottom.Control = GroupVarEdit
Left = 236 Left = 249
Height = 15 Height = 15
Top = 296 Top = 296
Width = 94 Width = 94
@ -166,19 +146,20 @@ object PolyDIFFrm: TPolyDIFFrm
Left = 0 Left = 0
Height = 339 Height = 339
Top = 17 Top = 17
Width = 174 Width = 187
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 8 BorderSpacing.Right = 8
ItemHeight = 0 ItemHeight = 0
MultiSelect = True MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object ItemInBtn: TBitBtn object ItemInBtn: TBitBtn
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
Left = 191 Left = 204
Height = 28 Height = 28
Top = 25 Top = 25
Width = 28 Width = 28
@ -194,7 +175,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ItemInBtn AnchorSideTop.Control = ItemInBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 191 Left = 204
Height = 28 Height = 28
Top = 57 Top = 57
Width = 28 Width = 28
@ -210,7 +191,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ItemOutBtn AnchorSideTop.Control = ItemOutBtn
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 182 Left = 195
Height = 25 Height = 25
Top = 89 Top = 89
Width = 46 Width = 46
@ -225,7 +206,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = GrpOutBtn AnchorSideBottom.Control = GrpOutBtn
Left = 191 Left = 204
Height = 28 Height = 28
Top = 288 Top = 288
Width = 28 Width = 28
@ -242,7 +223,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 191 Left = 204
Height = 28 Height = 28
Top = 320 Top = 320
Width = 28 Width = 28
@ -260,12 +241,13 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GrpOutBtn AnchorSideBottom.Control = GrpOutBtn
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 236 Left = 249
Height = 23 Height = 23
Top = 313 Top = 313
Width = 175 Width = 188
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 7 TabOrder = 7
Text = 'GroupVarEdit' Text = 'GroupVarEdit'
end end
@ -277,15 +259,17 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GrpInBtn AnchorSideBottom.Control = GrpInBtn
Left = 236 Left = 249
Height = 247 Height = 247
Top = 17 Top = 17
Width = 175 Width = 188
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Bottom = 24 BorderSpacing.Bottom = 24
ItemHeight = 0 ItemHeight = 0
MultiSelect = True
OnSelectionChange = VarListSelectionChange
TabOrder = 4 TabOrder = 4
end end
end end
@ -293,11 +277,11 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn AnchorSideBottom.Control = CloseBtn
Left = 0 Left = 0
Height = 8 Height = 8
Top = 364 Top = 364
Width = 631 Width = 657
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine Shape = bsBottomLine
end end
@ -306,12 +290,11 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1 AnchorSideBottom.Control = Bevel1
Left = 435 Left = 461
Height = 364 Height = 364
Top = 0 Top = 0
Width = 196 Width = 196
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 364 ClientHeight = 364
ClientWidth = 196 ClientWidth = 196
@ -322,7 +305,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 12 Top = 132
Width = 124 Width = 124
Caption = 'No. of Grouping Levels:' Caption = 'No. of Grouping Levels:'
ParentColor = False ParentColor = False
@ -333,7 +316,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 191 Top = 16
Width = 99 Width = 99
Caption = 'Lowest Item Score:' Caption = 'Lowest Item Score:'
ParentColor = False ParentColor = False
@ -344,7 +327,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 218 Top = 43
Width = 103 Width = 103
Caption = 'Highest Item Score:' Caption = 'Highest Item Score:'
ParentColor = False ParentColor = False
@ -355,7 +338,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 245 Top = 70
Width = 122 Width = 122
Caption = 'Reference Group Code:' Caption = 'Reference Group Code:'
ParentColor = False ParentColor = False
@ -366,34 +349,36 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 272 Top = 97
Width = 98 Width = 98
Caption = 'Focal Group Code:' Caption = 'Focal Group Code:'
ParentColor = False ParentColor = False
end end
object LevelsEdit: TEdit object LevelsEdit: TEdit
AnchorSideTop.Control = TrgtGrpEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2 AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 140 Left = 140
Height = 23 Height = 23
Top = 8 Top = 128
Width = 40 Width = 40
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 12
BorderSpacing.Right = 8 BorderSpacing.Right = 8
OnExit = LevelsEditExit OnEditingDone = LevelsEditEditingDone
TabOrder = 0 TabOrder = 4
end end
object GroupBox1: TGroupBox object GroupBox1: TGroupBox
AnchorSideLeft.Control = GroupBox2 AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = TrgtGrpEdit AnchorSideTop.Control = GroupBox2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2 AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 51 Height = 51
Top = 303 Top = 307
Width = 188 Width = 188
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
@ -417,19 +402,19 @@ object PolyDIFFrm: TPolyDIFFrm
end end
object LowScoreEdit: TEdit object LowScoreEdit: TEdit
AnchorSideLeft.Control = LevelsEdit AnchorSideLeft.Control = LevelsEdit
AnchorSideTop.Control = GroupBox2 AnchorSideTop.Control = Panel3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2 AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 140 Left = 140
Height = 23 Height = 23
Top = 187 Top = 12
Width = 40 Width = 40
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 12 BorderSpacing.Top = 12
BorderSpacing.Right = 8 BorderSpacing.Right = 8
TabOrder = 2 TabOrder = 0
Text = 'LowScoreEdit'
end end
object HiScoreEdit: TEdit object HiScoreEdit: TEdit
AnchorSideLeft.Control = LowScoreEdit AnchorSideLeft.Control = LowScoreEdit
@ -439,13 +424,13 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 140 Left = 140
Height = 23 Height = 23
Top = 214 Top = 39
Width = 40 Width = 40
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
TabOrder = 3 TabOrder = 1
Text = 'Edit1' Text = 'HiScoreEdit'
end end
object RefGrpEdit: TEdit object RefGrpEdit: TEdit
AnchorSideLeft.Control = LowScoreEdit AnchorSideLeft.Control = LowScoreEdit
@ -455,13 +440,13 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 140 Left = 140
Height = 23 Height = 23
Top = 241 Top = 66
Width = 40 Width = 40
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
TabOrder = 4 TabOrder = 2
Text = 'Edit1' Text = 'RefGrpEdit'
end end
object TrgtGrpEdit: TEdit object TrgtGrpEdit: TEdit
AnchorSideLeft.Control = LowScoreEdit AnchorSideLeft.Control = LowScoreEdit
@ -471,13 +456,13 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 140 Left = 140
Height = 23 Height = 23
Top = 268 Top = 93
Width = 40 Width = 40
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
TabOrder = 5 TabOrder = 3
Text = 'Edit1' Text = 'TrgtGrpEdit'
end end
object GroupBox2: TGroupBox object GroupBox2: TGroupBox
AnchorSideLeft.Control = Panel3 AnchorSideLeft.Control = Panel3
@ -487,7 +472,7 @@ object PolyDIFFrm: TPolyDIFFrm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 132 Height = 132
Top = 43 Top = 163
Width = 188 Width = 188
AutoSize = True AutoSize = True
BorderSpacing.Top = 12 BorderSpacing.Top = 12
@ -495,7 +480,7 @@ object PolyDIFFrm: TPolyDIFFrm
Caption = 'Enter Bounds for Levels' Caption = 'Enter Bounds for Levels'
ClientHeight = 112 ClientHeight = 112
ClientWidth = 184 ClientWidth = 184
TabOrder = 1 TabOrder = 5
object Panel2: TPanel object Panel2: TPanel
Left = 8 Left = 8
Height = 104 Height = 104
@ -584,25 +569,9 @@ object PolyDIFFrm: TPolyDIFFrm
PageSize = 0 PageSize = 0
Position = 1 Position = 1
TabOrder = 0 TabOrder = 0
OnScroll = LevelScrollScroll OnChange = LevelScrollChange
end
object LevelNoEdit: TEdit
AnchorSideTop.Control = Label8
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 129
Height = 23
Top = 19
Width = 39
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
TabOrder = 1
Text = 'LevelNoEdit'
end end
object LowBoundEdit: TEdit object LowBoundEdit: TEdit
AnchorSideTop.Control = LevelNoEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2 AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -613,7 +582,7 @@ object PolyDIFFrm: TPolyDIFFrm
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
OnExit = LowBoundEditExit OnEditingDone = LowBoundEditEditingDone
TabOrder = 2 TabOrder = 2
Text = 'LowBoundEdit' Text = 'LowBoundEdit'
end end
@ -629,10 +598,25 @@ object PolyDIFFrm: TPolyDIFFrm
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
OnExit = UpBoundEditExit OnEditingDone = UpBoundEditEditingDone
TabOrder = 3 TabOrder = 3
Text = 'Edit1' Text = 'Edit1'
end end
object LevelNoEdit: TStaticText
AnchorSideTop.Control = Label8
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
Left = 129
Height = 23
Top = 19
Width = 39
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
BorderStyle = sbsSingle
TabOrder = 1
end
end end
end end
end end

View File

@ -1,3 +1,14 @@
// Data file not clear, probably PolyDIFData.laz
// - lowest item score 1
// - highest item score 5
// - reference group score 1
// - focus group score 2
// - No of grouping levels 3
// - Level 1: lower bound 0, upper bound 1
// - Level 2: lower bound 2, upper bound 3
// - Level 3: lower bound 4, upper bound 5
// The results obtained this way match the pdf file.
unit PolyDifUnit; unit PolyDifUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
@ -17,13 +28,13 @@ type
Bevel1: TBevel; Bevel1: TBevel;
GroupBox2: TGroupBox; GroupBox2: TGroupBox;
HelpBtn: TButton; HelpBtn: TButton;
LevelNoEdit: TStaticText;
Panel1: TPanel; Panel1: TPanel;
Panel2: TPanel; Panel2: TPanel;
Panel3: TPanel; Panel3: TPanel;
ResetBtn: TButton; ResetBtn: TButton;
CancelBtn: TButton;
ComputeBtn: TButton; ComputeBtn: TButton;
ReturnBtn: TButton; CloseBtn: TButton;
LowScoreEdit: TEdit; LowScoreEdit: TEdit;
HiScoreEdit: TEdit; HiScoreEdit: TEdit;
RefGrpEdit: TEdit; RefGrpEdit: TEdit;
@ -38,7 +49,6 @@ type
UpBoundEdit: TEdit; UpBoundEdit: TEdit;
Label10: TLabel; Label10: TLabel;
Label9: TLabel; Label9: TLabel;
LevelNoEdit: TEdit;
Label6: TLabel; Label6: TLabel;
Label7: TLabel; Label7: TLabel;
Label8: TLabel; Label8: TLabel;
@ -57,7 +67,6 @@ type
LevelScroll: TScrollBar; LevelScroll: TScrollBar;
VarList: TListBox; VarList: TListBox;
procedure AllBtnClick(Sender: TObject); procedure AllBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject); procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
@ -67,22 +76,23 @@ type
procedure HelpBtnClick(Sender: TObject); procedure HelpBtnClick(Sender: TObject);
procedure ItemInBtnClick(Sender: TObject); procedure ItemInBtnClick(Sender: TObject);
procedure ItemOutBtnClick(Sender: TObject); procedure ItemOutBtnClick(Sender: TObject);
procedure LevelScrollScroll(Sender: TObject; ScrollCode: TScrollCode; procedure LevelScrollChange(Sender: TObject);
var ScrollPos: Integer); procedure LevelsEditEditingDone(Sender: TObject);
procedure LevelsEditExit(Sender: TObject); procedure LowBoundEditEditingDone(Sender: TObject);
procedure LowBoundEditExit(Sender: TObject);
procedure ResetBtnClick(Sender: TObject); procedure ResetBtnClick(Sender: TObject);
procedure ReturnBtnClick(Sender: TObject); procedure UpBoundEditEditingDone(Sender: TObject);
procedure UpBoundEditExit(Sender: TObject); procedure VarListSelectionChange(Sender: TObject; User: boolean);
private private
{ private declarations } { private declarations }
NoItems : integer;
FAutoSized: Boolean; FAutoSized: Boolean;
NoItems: integer;
nocats: integer; nocats: integer;
ColNoSelected: IntDyneVec; ColNoSelected: IntDyneVec;
ColLabels, RowLabels: StrDyneVec; ColLabels, RowLabels: StrDyneVec;
Ubounds: IntDyneVec; // upper and lower bounds of score groups Ubounds: IntDyneVec; // upper and lower bounds of score groups
Lbounds: IntdyneVec; Lbounds: IntdyneVec;
procedure UpdateBtnStates;
function ValidNumEdit(AEdit: TEdit; AName: String; out AValue: Integer): Boolean;
public public
{ public declarations } { public declarations }
@ -94,65 +104,61 @@ var
implementation implementation
uses uses
Math; Math, StrUtils, Utils;
{ TPolyDIFFrm } { TPolyDIFFrm }
procedure TPolyDIFFrm.ResetBtnClick(Sender: TObject); procedure TPolyDIFFrm.ResetBtnClick(Sender: TObject);
VAR i : integer; var
i: integer;
begin begin
VarList.Clear;
ItemsList.Clear;
GroupVarEdit.Text := '';
ItemInBtn.Enabled := true;
ItemOutBtn.Enabled := false;
AllBtn.Enabled := true;
GrpInBtn.Enabled := true;
GrpOutBtn.Enabled := false;
// MHChk.Checked := true;
RefGrpEdit.Text := '';
TrgtGrpEdit.Text := '';
LowScoreEdit.Text := '';
HiScoreEdit.Text := '';
LevelsEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
if NoVariables > 0 then LevelScroll.Max := NoVariables;
LevelNoEdit.Text := '1';
LowBoundEdit.Text := '0';
UpBoundEdit.Text := '2';
LevelScroll.Min := 1;
LevelScroll.Position := 1;
//allocate space on heap //allocate space on heap
SetLength(ColLabels, NoVariables + 1); SetLength(ColLabels, NoVariables + 1);
SetLength(RowLabels, NoVariables + 1); SetLength(RowLabels, NoVariables + 1);
SetLength(ColNoSelected, NoVariables); SetLength(ColNoSelected, NoVariables);
SetLength(Lbounds, NoVariables * 10); SetLength(Lbounds, NoVariables * 10);
SetLength(Ubounds, NoVariables * 10); SetLength(Ubounds, NoVariables * 10);
for i:=0 to High(LBounds) do LBounds[i] := -1;
for i:=0 to High(UBounds) do UBounds[i] := -1;
VarList.Clear;
ItemsList.Clear;
GroupVarEdit.Text := '';
RefGrpEdit.Text := '';
TrgtGrpEdit.Text := '';
LowScoreEdit.Text := '';
HiScoreEdit.Text := '';
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
LevelScroll.Min := 0; //1;
LevelScroll.Max := 0; //LevelScroll.Min;
LevelScroll.Position := 0; //1;
{
if NoVariables > 0 then
LevelScroll.Max := NoVariables;
}
LevelsEdit.Text := ''; //IntToStr(NoVariables);
LevelNoEdit.Caption := ''; //'1';
LowBoundEdit.Text := ''; //'0';
UpBoundEdit.Text := ''; //'2';
ComputeBtn.Enabled := false;
UpdateBtnStates;
end; end;
procedure TPolyDIFFrm.ReturnBtnClick(Sender: TObject); procedure TPolyDIFFrm.UpBoundEditEditingDone(Sender: TObject);
var
level: Integer;
begin begin
Ubounds := nil; level := StrToInt(LevelNoEdit.Caption) - 1;
Lbounds := nil; Ubounds[level] := StrToInt(UpBoundEdit.Text);
ColNoSelected := nil; if level + 1 = StrToInt(LevelsEdit.Text) then
RowLabels := nil;
ColLabels := nil;
Close;
end;
procedure TPolyDIFFrm.UpBoundEditExit(Sender: TObject);
VAR i : integer;
begin begin
i := StrToInt(LevelNoEdit.Text); ComputeBtn.Enabled := true;
Ubounds[i-1] := StrToInt(UpBoundEdit.Text);
if i = StrToInt(LevelsEdit.Text) then
begin
ComputeBtn.SetFocus;
exit; exit;
end; end;
LowBoundEdit.Text := IntToStr(Ubounds[i-1] + 1); LowBoundEdit.Text := IntToStr(UBounds[level]); //IntToStr(Ubounds[level] + 1);
LowBoundEdit.SetFocus; // LowBoundEdit.SetFocus;
end; end;
procedure TPolyDIFFrm.FormActivate(Sender: TObject); procedure TPolyDIFFrm.FormActivate(Sender: TObject);
@ -162,12 +168,11 @@ begin
if FAutoSized then if FAutoSized then
exit; exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, CancelBtn.Width, ComputeBtn.Width, ReturnBtn.Width]); w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w; HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w; ResetBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w; ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w; CloseBtn.Constraints.MinWidth := w;
Constraints.MinHeight := Height; Constraints.MinHeight := Height;
Constraints.MinWidth := Width; Constraints.MinWidth := Width;
@ -178,9 +183,6 @@ end;
procedure TPolyDIFFrm.FormCreate(Sender: TObject); procedure TPolyDIFFrm.FormCreate(Sender: TObject);
begin begin
Assert(OS3MainFrm <> nil); Assert(OS3MainFrm <> nil);
if OutputFrm = nil then
Application.CreateForm(TOutputFrm, OutputFrm);
if GraphFrm = nil then if GraphFrm = nil then
Application.CreateForm(TGraphFrm, GraphFrm); Application.CreateForm(TGraphFrm, GraphFrm);
end; end;
@ -191,26 +193,26 @@ begin
end; end;
procedure TPolyDIFFrm.GrpInBtnClick(Sender: TObject); procedure TPolyDIFFrm.GrpInBtnClick(Sender: TObject);
VAR index : integer; var
index: integer;
begin begin
if VarList.ItemIndex < 0 then
begin
GrpInBtn.Enabled := false;
exit;
end;
index := VarList.ItemIndex; index := VarList.ItemIndex;
GroupVarEdit.Text := VarList.Items.Strings[index]; if (index > -1) and (GroupVarEdit.Text = '') then
begin
GroupVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index); VarList.Items.Delete(index);
GrpInBtn.Enabled := false; UpdateBtnStates;
GrpOutBtn.Enabled := true; end;
end; end;
procedure TPolyDIFFrm.GrpOutBtnClick(Sender: TObject); procedure TPolyDIFFrm.GrpOutBtnClick(Sender: TObject);
begin
if GroupVarEdit.Text <> '' then
begin begin
VarList.Items.Add(GroupVarEdit.Text); VarList.Items.Add(GroupVarEdit.Text);
GroupVarEdit.Text := ''; GroupVarEdit.Text := '';
GrpOutBtn.Enabled := false; UpdateBtnStates;
GrpInBtn.Enabled := true; end;
end; end;
procedure TPolyDIFFrm.HelpBtnClick(Sender: TObject); procedure TPolyDIFFrm.HelpBtnClick(Sender: TObject);
@ -221,49 +223,68 @@ begin
end; end;
procedure TPolyDIFFrm.ItemInBtnClick(Sender: TObject); procedure TPolyDIFFrm.ItemInBtnClick(Sender: TObject);
VAR i, index : integer; var
i: integer;
begin begin
if VarList.ItemIndex < 0 then
begin
ItemInBtn.Enabled := false;
exit;
end;
index := VarList.Items.Count;
i := 0; i := 0;
while i < index do while i < VarList.Items.Count do
begin begin
if (VarList.Selected[i]) then if VarList.Selected[i] then
begin begin
ItemsList.Items.Add(VarList.Items.Strings[i]); ItemsList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i); VarList.Items.Delete(i);
index := index - 1;
i := 0; i := 0;
end end
else i := i + 1; else
i := i + 1;
end; end;
ItemOutBtn.Enabled := true; UpdateBtnStates;
LevelsEdit.Text := IntToStr(ItemsList.Count);
LevelsEditEditingDone(nil);
end; end;
procedure TPolyDIFFrm.ItemOutBtnClick(Sender: TObject); procedure TPolyDIFFrm.ItemOutBtnClick(Sender: TObject);
VAR index : integer; var
i: integer;
begin begin
index := ItemsList.ItemIndex; i := 0;
if index < 0 then while i < ItemsList.Items.Count do
begin begin
ItemOutBtn.Enabled := false; if ItemsList.Selected[i] then
exit; begin
VarList.Items.Add(ItemsList.Items[i]);
ItemsList.Items.Delete(i);
i := 0;
end
else
i := i + 1;
end; end;
VarList.Items.Add(ItemsList.Items.Strings[index]); UpdateBtnStates;
ItemsList.Items.Delete(index); LevelsEdit.Text := IntToStr(ItemsList.Count);
ItemInBtn.Enabled := true; LevelsEditEditingDone(nil);
end; end;
procedure TPolyDIFFrm.LevelScrollScroll(Sender: TObject; procedure TPolyDIFFrm.LevelScrollChange(Sender: TObject);
ScrollCode: TScrollCode; var ScrollPos: Integer);
var var
scrlpos : integer;
level: integer; level: integer;
begin begin
level := LevelScroll.Position;
LevelNoEdit.Caption := IntToStr(level + 1);
if LBounds[level] = -1 then
LowBoundEdit.Text := ''
else
LowBoundEdit.Text :=IntToStr(LBounds[level]);
if UBounds[level] = -1 then
UpBoundEdit.Text := ''
else
UpBoundEdit.Text := IntToStr(UBounds[level]);
end;
// wp: Setting focus to other controls makes the form very difficult to use.
{
level := StrToInt(LevelNoEdit.Text); level := StrToInt(LevelNoEdit.Text);
scrlpos := LevelScroll.Position; scrlpos := LevelScroll.Position;
if ((scrlpos > level) and (level <= StrToInt(LevelsEdit.Text))) then if ((scrlpos > level) and (level <= StrToInt(LevelsEdit.Text))) then
@ -284,40 +305,44 @@ begin
LowBoundEdit.SetFocus; LowBoundEdit.SetFocus;
end; end;
end; end;
}
procedure TPolyDIFFrm.LevelsEditExit(Sender: TObject); procedure TPolyDIFFrm.LevelsEditEditingDone(Sender: TObject);
var
L: Integer;
begin begin
LevelScroll.Max := StrToInt(LevelsEdit.Text); if ValidNumEdit(LevelsEdit, 'No. of Grouping Levels', L) then
LowBoundEdit.SetFocus; begin
LevelScroll.Max := Max(L - 1, 0);
LevelScroll.Min := 0;
LevelNoEdit.Caption := IntToStr(LevelScroll.Position + 1);
//LevelScroll.Enabled := true;
//LowBoundEdit.SetFocus;
end;
end; end;
procedure TPolyDIFFrm.LowBoundEditExit(Sender: TObject); procedure TPolyDIFFrm.LowBoundEditEditingDone(Sender: TObject);
VAR i : integer; var
level: integer;
begin begin
i := StrToInt(LevelNoEdit.Text); level := LevelScroll.Position;
Lbounds[i-1] := StrToInt(LowBoundEdit.Text); // level := StrToInt(LevelNoEdit.Caption) - 1;
UpBoundEdit.SetFocus; Lbounds[level] := StrToInt(LowBoundEdit.Text);
end; //UpBoundEdit.Set
procedure TPolyDIFFrm.CancelBtnClick(Sender: TObject);
begin
Ubounds := nil;
Lbounds := nil;
ColNoSelected := nil;
RowLabels := nil;
ColLabels := nil;
Close;
end; end;
procedure TPolyDIFFrm.AllBtnClick(Sender: TObject); procedure TPolyDIFFrm.AllBtnClick(Sender: TObject);
VAR i : integer; var
i: integer;
begin begin
if VarList.Items.Count < 1 then exit; if VarList.Items.Count < 1 then
exit;
for i := 0 to VarList.Items.Count - 1 do for i := 0 to VarList.Items.Count - 1 do
ItemsList.Items.Add(VarList.Items.Strings[i]); ItemsList.Items.Add(VarList.Items[i]);
VarList.Clear; VarList.Clear;
ItemInBtn.Enabled := false; UpdateBtnStates;
ItemOutBtn.Enabled := true; LevelsEdit.Text := IntToStr(ItemsList.Count);
LevelsEditEditingDone(nil);
end; end;
procedure TPolyDIFFrm.ComputeBtnClick(Sender: TObject); procedure TPolyDIFFrm.ComputeBtnClick(Sender: TObject);
@ -338,19 +363,37 @@ var
Zc, Vart, BigJ, SumE, SumV, Term1, MY, prob : double; Zc, Vart, BigJ, SumE, SumV, Term1, MY, prob : double;
X, BigDnum, BigDden, BigD, BigDS, Zd, M2, E, VarE, Ti, dftot : double; X, BigDnum, BigDden, BigD, BigDS, Zd, M2, E, VarE, Ti, dftot : double;
loscore, hiscore : integer; loscore, hiscore : integer;
lReport: TStrings;
begin begin
OutputFrm.RichEdit.Clear;
OutputFrm.RichEdit.Lines.Add('Polytomous Item DIF Analysis adapted by Bill Miller from');
OutputFrm.RichEdit.Lines.Add('Procedures for extending item bias detection techniques');
OutputFrm.RichEdit.Lines.Add('by Catherine Welch and H.D. Hoover, 1993');
OutputFrm.RichEdit.Lines.Add('Applied Measurement in Education 6(1), pages 1-19.');
OutputFrm.RichEdit.Lines.Add('');
NoItems := ItemsList.Items.Count; NoItems := ItemsList.Items.Count;
loscore := StrToInt(LowScoreEdit.Text); if NoItems = 0 then
hiscore := StrToInt(HiScoreEdit.Text); begin
MessageDlg('No items selected.', mtError, [mbOK], 0);
exit;
end;
if not ValidNumEdit(LevelsEdit, 'Number of Grouping Levels', noLevels) then
exit;
if not ValidNumEdit(LowScoreEdit, 'Lowest Item Score', loscore) then
exit;
if not ValidNumEdit(HiScoreEdit, 'Highest Item Score', hiscore) then
exit;
if not ValidNumEdit(RefGrpEdit, 'Reference Group Code', i) then
exit;
if not ValidNumEdit(TrgtGrpEdit, 'Focus Group Code', i) then
exit;
lReport := TStringList.Create;
try
lReport.Add('POLYTOMOUS ITEM DIF ANALYSIS');
lReport.Add('adapted by Bill Miller from');
lReport.Add('Procedures for extending item bias detection techniques');
lReport.Add('by Catherine Welch and H.D. Hoover, 1993');
lReport.Add('Applied Measurement in Education 6(1), pages 1-19.');
lReport.Add('');
nocats := hiscore - loscore + 1; // 0 to highest score nocats := hiscore - loscore + 1; // 0 to highest score
nolevels := StrToInt(LevelsEdit.Text);
SetLength(FData,NoItems,hiscore+10,nolevels+10); SetLength(FData,NoItems,hiscore+10,nolevels+10);
SetLength(RData,NoItems,hiscore+10,nolevels+10); SetLength(RData,NoItems,hiscore+10,nolevels+10);
SetLength(TotData,NoItems,hiscore+10,nolevels+10); SetLength(TotData,NoItems,hiscore+10,nolevels+10);
@ -365,7 +408,8 @@ begin
SetLength(d,nolevels); SetLength(d,nolevels);
SetLength(Sd,nolevels); SetLength(Sd,nolevels);
for k := 1 to 2 do nsize[k] := 0; for k := 1 to 2 do
nsize[k] := 0;
// get items to analyze and their labels // get items to analyze and their labels
for i := 1 to NoItems do // items to analyze for i := 1 to NoItems do // items to analyze
@ -393,14 +437,13 @@ begin
end; end;
if grpvar = 0 then if grpvar = 0 then
begin begin
ShowMessage('Error - No group variable found.'); MessageDlg('No group variable found.', mtError, [mbOK], 0);
exit; exit;
end; end;
// read data (score group and items) // read data (score group and items)
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
subjtot := 0;
// Get group (reference or target) // Get group (reference or target)
value := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grpvar,i]))); value := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grpvar,i])));
subjgrp := 0; subjgrp := 0;
@ -408,55 +451,64 @@ begin
if value = StrToInt(TrgtGrpEdit.Text) then subjgrp := 2; // target group if value = StrToInt(TrgtGrpEdit.Text) then subjgrp := 2; // target group
if subjgrp = 0 then if subjgrp = 0 then
begin begin
ShowMessage('Error - Bad group code for a subject.'); MessageDlg('Bad group code for a subject.', mtError, [mbOK], 0);
exit; exit;
end; end;
nsize[subjgrp] := nsize[subjgrp] + 1; nsize[subjgrp] := nsize[subjgrp] + 1;
for j := 1 to NoItems do // get item score and subject total // get item score and subject total
subjtot := 0;
for j := 1 to NoItems do
begin begin
itm := ColNoSelected[j-1]; itm := ColNoSelected[j-1];
value := Round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[itm,i]))); value := Round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[itm,i])));
subjtot := subjtot + value; subjtot := subjtot + value;
end; end;
// get score level category
level := 0; level := 0;
for k := 0 to NoLevels-1 do // get score level category for k := 0 to NoLevels-1 do
begin
if ((subjtot >= Lbounds[k]) and (subjtot <= Ubounds[k])) then if ((subjtot >= Lbounds[k]) and (subjtot <= Ubounds[k])) then
level := k; level := k;
end;
for j := 1 to NoItems do // add to data // add to data
for j := 1 to NoItems do
begin begin
itm := ColNoSelected[j-1]; itm := ColNoSelected[j-1];
value := Round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[itm,i]))); value := Round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[itm,i])));
value := value - loscore; value := value - loscore;
if subjgrp = 1 then if subjgrp = 1 then
RData[j-1,value,level] := RData[j-1,value,level] + 1 RData[j-1,value,level] := RData[j-1,value,level] + 1
else FData[j-1,value,level] := FData[j-1,value,level] + 1; else
FData[j-1,value,level] := FData[j-1,value,level] + 1;
TotData[j-1,value,level] := TotData[j-1,value,level] + 1; TotData[j-1,value,level] := TotData[j-1,value,level] + 1;
end; end;
end; // next case i end; // next case i
// Show upper and lower bounds for score group bins // Show upper and lower bounds for score group bins
OutputFrm.RichEdit.Lines.Add('Conditioning Levels'); lReport.Add('Conditioning Levels');
OutputFrm.RichEdit.Lines.Add('Lower Upper'); lReport.Add('');
lReport.Add('Lower Upper');
lReport.Add('----- -----');
for i := 0 to nolevels-1 do for i := 0 to nolevels-1 do
begin lReport.Add('%5d %5d', [Lbounds[i], Ubounds[i]]);
cellstring := format('%5d %5d',[Lbounds[i],Ubounds[i]]); lReport.Add('');
OutputFrm.RichEdit.Lines.Add(cellstring); lReport.Add(DIVIDER);
end; lReport.Add('');
OutputFrm.RichEdit.Lines.Add('');
// obtain statistics and print frequency in categories for each item // obtain statistics and print frequency in categories for each item
for i := 1 to NoItems do for i := 1 to NoItems do
begin begin
OutputFrm.RichEdit.Lines.Add('Observed Category Frequencies'); lReport.Add('ITEM ' + IntToStr(i));
OutputFrm.RichEdit.Lines.Add('Item Group Level Category Number'); lReport.Add('');
lReport.Add('Observed Category Frequencies');
lReport.Add('Item Group Level Category Number');
Title := ' '; Title := ' ';
for j := 0 to nocats-1 do Title := Title + format('%10d',[j+loscore]); for j := 0 to nocats-1 do
OutputFrm.RichEdit.Lines.Add(Title); Title := Title + Format('%10d', [j+loscore]);
lReport.Add(Title);
lReport.Add('---- ----- ----- ' + DupeString('-', 10*NoCats)); //---------------');
Zc := 0.0; Zc := 0.0;
dftot := 0.0; dftot := 0.0;
BigDnum := 0.0; BigDnum := 0.0;
@ -481,31 +533,34 @@ begin
E := 0.0; E := 0.0;
Ti := 0.0; Ti := 0.0;
MY := 0.0; MY := 0.0;
Title := format('%3d Ref. %3d',[i,k+1]); Title := Format('%3d Ref. %3d ', [i, k+1]);
for j := 0 to nocats-1 do for j := 0 to nocats-1 do
begin begin
Title := Title + format('%10d',[RData[i-1,j,k]]); Title := Title + Format('%10d', [RData[i-1,j,k]]);
X := RData[i-1,j,k] * (j+loscore); X := RData[i-1,j,k] * (j+loscore);
Mb[k] := Mb[k] + X; Mb[k] := Mb[k] + X;
Sb[k] := Sb[k] + (X * X); Sb[k] := Sb[k] + (X * X);
Nb[k] := Nb[k] + RData[i-1,j,k]; Nb[k] := Nb[k] + RData[i-1,j,k];
end; end;
OutputFrm.RichEdit.Lines.Add(Title); lReport.Add(Title);
Title := format('%3d Focal %3d',[i,k+1]);
Title := Format('%3d Focal %3d ', [i, k+1]);
for j := 0 to nocats-1 do for j := 0 to nocats-1 do
begin begin
Title := Title + format('%10d',[FData[i-1,j,k]]); Title := Title + Format('%10d', [FData[i-1,j,k]]);
X := FData[i-1,j,k] * (j + loscore); X := FData[i-1,j,k] * (j + loscore);
Mf[k] := Mf[k] + X; Mf[k] := Mf[k] + X;
Sf[k] := Sf[k] + (X * X); Sf[k] := Sf[k] + (X * X);
Nf[k] := Nf[k] + FData[i-1,j,k]; Nf[k] := Nf[k] + FData[i-1,j,k];
end; end;
OutputFrm.RichEdit.Lines.Add(Title); lReport.Add(Title);
Title := format('%3d Total %3d',[i,k+1]);
Title := Format('%3d Total %3d ', [i, k+1]);
for j := 0 to nocats-1 do for j := 0 to nocats-1 do
Title := Title + format('%10d',[TotData[i-1,j,k]]); Title := Title + Format('%10d', [TotData[i-1,j,k]]);
OutputFrm.RichEdit.Lines.Add(Title); lReport.Add(Title);
OutputFrm.RichEdit.Lines.Add(''); lReport.Add('');
for j := 0 to nocats-1 do for j := 0 to nocats-1 do
begin begin
Term1 := Term1 + FData[i-1,j,k] * (j+loscore); Term1 := Term1 + FData[i-1,j,k] * (j+loscore);
@ -515,6 +570,13 @@ begin
MY := MY + TotData[i-1,j,k] * (j + loscore); MY := MY + TotData[i-1,j,k] * (j + loscore);
VarE := VarE + TotData[i-1,j,k] * (j + loscore)*(j + loscore); VarE := VarE + TotData[i-1,j,k] * (j + loscore)*(j + loscore);
end; end;
if Ti = 0 then // wp: added to avoid crash when Ti is 0. Not clear why this happens in my test...
begin
lReport.Add('Ti = zero --> skip to avoid division by zero');
Continue;
end;
E := E / Ti; E := E / Ti;
E := Nf[k] * E; E := Nf[k] * E;
SumE := SumE + E; // second term of num. of m2 SumE := SumE + E; // second term of num. of m2
@ -545,32 +607,36 @@ begin
BigDden := BigDden + 1.0 / Sd[k]; BigDden := BigDden + 1.0 / Sd[k];
end; // next level k end; // next level k
M2 := (Term1 - SumE) * (Term1 - SumE) / SumV; M2 := (Term1 - SumE) * (Term1 - SumE) / SumV;
Title := 't-test values for Reference and Focus Means for each level';
OutputFrm.RichEdit.Lines.Add(Title); lReport.Add('');
lReport.Add('t-test values for Reference and Focus Means for each level');
lReport.Add('');
for k := 0 to nolevels-1 do for k := 0 to nolevels-1 do
begin begin
Title := format('Mean Reference = %10.3f SD = %10.3f N = %5.0f',[Mb[k],sqrt(Sb[k]),Nb[k]]); lReport.Add('Level %d', [k+1]);
OutputFrm.RichEdit.Lines.Add(Title); lReport.Add(' Mean Reference: %10.3f SD: %10.3f N: %5.0f', [Mb[k], sqrt(Sb[k]), Nb[k]]);
Title := format('Mean Focal = %10.3f SD = %10.3f N = %5.0f',[Mf[k],sqrt(Sf[k]),Nf[k]]); lReport.Add(' Mean Focal: %10.3f SD: %10.3f N: %5.0f', [Mf[k], sqrt(Sf[k]), Nf[k]]);
OutputFrm.RichEdit.Lines.Add(Title); lReport.Add(' t: %10.3f with %.f degrees of freedom', [t[k], df[k]]);
Title := format('Level %3d t = %8.3f with deg. freedom = %5.0f',[k+1,t[k],df[k]]); lReport.Add('');
OutputFrm.RichEdit.Lines.Add(Title);
end; end;
Zc := Zc / dftot; // HW1 statistic Zc := Zc / dftot; // HW1 statistic
prob := 1.0 - probz(Zc); prob := 1.0 - probz(Zc);
Title := format('Composite z statistic = %6.3f. Prob. > |z| = %6.3f',[Zc, prob]); lReport.Add( 'Composite z statistic: %10.3f Probability > |z|: %6.3f', [Zc, prob]);
OutputFrm.RichEdit.Lines.Add(Title);
BigD := BigDnum / BigDden; BigD := BigDnum / BigDden;
BigDS := 1.0 / sqrt(BigDden); BigDS := 1.0 / sqrt(BigDden);
Zd := BigD / BigDS; // HW3 statistic Zd := BigD / BigDS; // HW3 statistic
prob := 1.0 - probz(Zd); prob := 1.0 - probz(Zd);
Title := format('Weighted Composite z statistic = %6.3f. Prob. > |z| = %6.3f',[Zd, prob]); lReport.Add( 'Weighted Composite z statistic: %10.3f Probability > |z|: %6.3f', [Zd, prob]);
OutputFrm.RichEdit.Lines.Add(Title);
prob := 1.0 - chisquaredprob(M2, 1); prob := 1.0 - chisquaredprob(M2, 1);
Title := format('Generalized Mantel-Haenszel = %10.3f with D.F. = 1 and Prob. > Chi-Sqr. = %6.3f',[M2, prob]); lReport.Add( 'Generalized Mantel-Haenszel: %10.3f with D.F. = 1 and Prob. > Chi-Sqr. %.3f', [M2, prob]);
OutputFrm.RichEdit.Lines.Add(Title);
OutputFrm.ShowModal; lReport.Add('');
OutputFrm.RichEdit.Clear; lReport.Add(DIVIDER);
lReport.Add('');
if GraphChk.Checked then if GraphChk.Checked then
begin begin
GraphFrm.nosets := 2; GraphFrm.nosets := 2;
@ -593,13 +659,17 @@ begin
GraphFrm.ShowRightWall := true; GraphFrm.ShowRightWall := true;
GraphFrm.ShowBottomWall := true; GraphFrm.ShowBottomWall := true;
GraphFrm.ShowBackWall := true; GraphFrm.ShowBackWall := true;
GraphFrm.BackColor := clYellow; GraphFrm.BackColor := GRAPH_BACK_COLOR;
GraphFrm.WallColor := clBlack; GraphFrm.WallColor := GRAPH_WALL_COLOR;
GraphFrm.FloorColor := GRAPH_FLOOR_COLOR;
GraphFrm.ShowModal; GraphFrm.ShowModal;
end; end;
end; // next item end; // next item
// clean up the heap DisplayReport(lReport);
finally
lReport.Free;
GraphFrm.Xpoints := nil; GraphFrm.Xpoints := nil;
GraphFrm.Ypoints := nil; GraphFrm.Ypoints := nil;
FData := nil; FData := nil;
@ -616,6 +686,45 @@ begin
d := nil; d := nil;
Sd:= nil; Sd:= nil;
end; end;
end;
procedure TPolyDIFFrm.UpdateBtnStates;
var
lSelected: Boolean;
begin
lSelected := AnySelected(VarList);
ItemInBtn.Enabled := lSelected;
GrpInBtn.Enabled := lSelected and (GroupVarEdit.Text = '');
ItemOutBtn.Enabled := AnySelected(ItemsList);
GrpOutBtn.Enabled := GroupVarEdit.Text <> '';
AllBtn.Enabled := VarList.Items.Count > 0;
end;
function TPolyDIFFrm.ValidNumEdit(AEdit: TEdit; AName: String;
out AValue: Integer): Boolean;
begin
Result := false;
if AEdit.Text = '' then
begin
AEdit.SetFocus;
MessageDlg(AName + ' not specified.', mtError, [mbOK], 0);
exit;
end;
if not TryStrToInt(AEdit.Text, AValue) then
begin
AEdit.SetFocus;
MessageDlg(AName + ' is not a valid number.', mtError, [mbOk], 0);
exit;
end;
Result := true;
end;
procedure TPolyDIFFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization initialization