LazStats: Inherit TwoCorrsUnit from TBasicStatsReportForm. Minor refactoring of TwoCorrsUnit and TwoPropUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7843 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-04 17:53:45 +00:00
parent 7613b7da31
commit 9953cfe29b
6 changed files with 1153 additions and 910 deletions

View File

@@ -307,7 +307,7 @@
<Unit25> <Unit25>
<Filename Value="forms\analysis\comparisons\twocorrsunit.pas"/> <Filename Value="forms\analysis\comparisons\twocorrsunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="TwoCorrsFrm"/> <ComponentName Value="TwoCorrsForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TwoCorrsUnit"/> <UnitName Value="TwoCorrsUnit"/>

View File

@@ -1,75 +1,55 @@
object TwoCorrsFrm: TTwoCorrsFrm inherited TwoCorrsForm: TTwoCorrsForm
Left = 559 Left = 584
Height = 391 Height = 460
Top = 286 Top = 206
Width = 462 Width = 823
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/DifferencebetweenCorrelations.htm' HelpKeyword = 'html/DifferencebetweenCorrelations.htm'
Caption = 'Comparison of Two Correlations' Caption = 'Comparison of Two Correlations'
ClientHeight = 391 ClientHeight = 460
ClientWidth = 462 ClientWidth = 823
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 444
OnShow = FormShow Width = 392
Position = poMainFormCenter ClientHeight = 444
LCLVersion = '2.1.0.0' ClientWidth = 392
object Label14: TLabel inherited CloseBtn: TButton
AnchorSideLeft.Control = Owner Left = 337
AnchorSideTop.Control = CInterval Top = 419
AnchorSideTop.Side = asrCenter TabOrder = 7
Left = 8
Height = 15
Top = 323
Width = 149
BorderSpacing.Left = 8
Caption = 'Percent Confidence Interval:'
ParentColor = False
end end
object RadioGroup1: TRadioGroup inherited ComputeBtn: TButton
AnchorSideLeft.Control = Owner Left = 253
AnchorSideTop.Control = Owner Top = 419
Left = 8 TabOrder = 6
Height = 72
Top = 8
Width = 225
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Data Entered From:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 221
Items.Strings = (
'Values entered on this form.'
'Values in the data grid from a file.'
)
OnClick = RadioGroup1Click
TabOrder = 0
end end
object RadioGroup2: TRadioGroup inherited ResetBtn: TButton
AnchorSideLeft.Control = RadioGroup1 Left = 191
AnchorSideLeft.Side = asrBottom Top = 419
AnchorSideTop.Control = Owner TabOrder = 5
Left = 257 end
inherited HelpBtn: TButton
Tag = 151
Left = 132
Top = 419
TabOrder = 4
end
inherited ButtonBevel: TBevel
Top = 403
Width = 392
end
object DataSourceGroup: TRadioGroup[5]
AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = Bevel5
Left = 3
Height = 72 Height = 72
Top = 8 Top = 0
Width = 185 Width = 185
Anchors = [akTop, akRight]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Left = 24 Caption = 'Data Entered From:'
BorderSpacing.Top = 8 ChildSizing.LeftRightSpacing = 8
BorderSpacing.Right = 8
Caption = 'Test Assumptions:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2 ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@@ -80,117 +60,81 @@ object TwoCorrsFrm: TTwoCorrsFrm
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 52 ClientHeight = 52
ClientWidth = 181 ClientWidth = 181
Items.Strings = (
'Values entered on this form'
'Values in the data grid'
)
OnClick = DataSourceGroupClick
TabOrder = 0
end
object DepIndepGroup: TRadioGroup[6]
AnchorSideLeft.Control = Bevel5
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ParamsPanel
Left = 204
Height = 72
Top = 0
Width = 177
AutoFill = True
AutoSize = True
Caption = 'Test Assumptions:'
ChildSizing.LeftRightSpacing = 8
ChildSizing.TopBottomSpacing = 6
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 52
ClientWidth = 173
Items.Strings = ( Items.Strings = (
'Independent Correlations.' 'Independent Correlations.'
'Dependent Correlations.' 'Dependent Correlations.'
) )
OnClick = RadioGroup2Click OnClick = DepIndepGroupClick
TabOrder = 1 TabOrder = 1
end end
object CInterval: TEdit object Label14: TLabel[7]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = CIntervalEdit
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 384
Width = 149
Caption = 'Percent Confidence Interval:'
ParentColor = False
end
object CIntervalEdit: TEdit[8]
AnchorSideLeft.Control = Label14 AnchorSideLeft.Control = Label14
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Bevel2 AnchorSideBottom.Control = ButtonBevel
Left = 165 Left = 157
Height = 23 Height = 23
Top = 319 Top = 380
Width = 36 Width = 48
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8
TabOrder = 3 TabOrder = 3
Text = 'CInterval' Text = 'CIntervalEdit'
end end
object ResetBtn: TButton object Notebook: TNotebook[9]
AnchorSideRight.Control = ComputeBtn AnchorSideLeft.Control = ParamsPanel
AnchorSideBottom.Control = Owner AnchorSideTop.Control = DataSourceGroup
AnchorSideBottom.Side = asrBottom
Left = 243
Height = 25
Top = 358
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 = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 305
Height = 25
Top = 358
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 ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 389
Height = 25
Top = 358
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 7
end
object HelpBtn: TButton
Tag = 151
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 184
Height = 25
Top = 358
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 4
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = RadioGroup1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CInterval AnchorSideBottom.Control = CIntervalEdit
Left = 8 Left = 0
Height = 223 Height = 292
Top = 88 Top = 80
Width = 454 Width = 392
PageIndex = 0 PageIndex = 2
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
TabOrder = 2 TabOrder = 2
@@ -199,7 +143,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
AnchorSideLeft.Control = Page1 AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Page1 AnchorSideTop.Control = Page1
Left = 143 Left = 112
Height = 132 Height = 132
Top = 0 Top = 0
Width = 168 Width = 168
@@ -211,7 +155,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
TabOrder = 0 TabOrder = 0
object firstcorlabel: TLabel object firstcorlabel: TLabel
AnchorSideLeft.Control = PanelPage1 AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = rxy1 AnchorSideTop.Control = Corr1Edit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
@@ -222,18 +166,18 @@ object TwoCorrsFrm: TTwoCorrsFrm
end end
object size1label: TLabel object size1label: TLabel
AnchorSideLeft.Control = PanelPage1 AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = Size1 AnchorSideTop.Control = SampleSize1Edit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 51 Top = 51
Width = 74 Width = 90
Caption = 'Sample Size 1:' Caption = 'First Sample Size:'
ParentColor = False ParentColor = False
end end
object SecdCorLabel: TLabel object SecdCorLabel: TLabel
AnchorSideLeft.Control = PanelPage1 AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = rxy2 AnchorSideTop.Control = Corr2Edit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
@@ -244,15 +188,16 @@ object TwoCorrsFrm: TTwoCorrsFrm
end end
object Size2Label: TLabel object Size2Label: TLabel
AnchorSideLeft.Control = PanelPage1 AnchorSideLeft.Control = PanelPage1
AnchorSideTop.Control = Size2 AnchorSideTop.Control = Size2Edit
AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
Top = 109 Top = 113
Width = 74 Width = 107
Caption = 'Sample Size 2:' Caption = 'Second Sample Size:'
ParentColor = False ParentColor = False
end end
object rxy1: TEdit object Corr1Edit: TEdit
AnchorSideLeft.Control = SecdCorLabel AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PanelPage1 AnchorSideTop.Control = PanelPage1
@@ -264,12 +209,12 @@ object TwoCorrsFrm: TTwoCorrsFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 16 BorderSpacing.Top = 16
TabOrder = 0 TabOrder = 0
Text = 'rxy1' Text = 'Corr1Edit'
end end
object Size1: TEdit object SampleSize1Edit: TEdit
AnchorSideLeft.Control = SecdCorLabel AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rxy1 AnchorSideTop.Control = Corr1Edit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 112 Left = 112
Height = 23 Height = 23
@@ -279,12 +224,12 @@ object TwoCorrsFrm: TTwoCorrsFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 1 TabOrder = 1
Text = 'Edit1' Text = 'SampleSize1Edit'
end end
object rxy2: TEdit object Corr2Edit: TEdit
AnchorSideLeft.Control = SecdCorLabel AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Size1 AnchorSideTop.Control = SampleSize1Edit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 112 Left = 112
Height = 23 Height = 23
@@ -294,12 +239,12 @@ object TwoCorrsFrm: TTwoCorrsFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 2 TabOrder = 2
Text = 'Edit1' Text = 'Corr2Edit'
end end
object Size2: TEdit object Size2Edit: TEdit
AnchorSideLeft.Control = SecdCorLabel AnchorSideLeft.Control = SecdCorLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rxy2 AnchorSideTop.Control = Corr2Edit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 112 Left = 112
Height = 23 Height = 23
@@ -309,7 +254,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 3 TabOrder = 3
Text = 'Edit1' Text = 'Size2Edit'
end end
end end
end end
@@ -318,7 +263,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
AnchorSideLeft.Control = Page2 AnchorSideLeft.Control = Page2
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Page2 AnchorSideTop.Control = Page2
Left = 144 Left = 113
Height = 156 Height = 156
Top = 0 Top = 0
Width = 167 Width = 167
@@ -329,7 +274,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
TabOrder = 0 TabOrder = 0
object corxylabel: TLabel object corxylabel: TLabel
AnchorSideLeft.Control = PanelPage2 AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = rxy AnchorSideTop.Control = CorrXYEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
@@ -340,7 +285,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
end end
object corxzlabel: TLabel object corxzlabel: TLabel
AnchorSideLeft.Control = PanelPage2 AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = rxz AnchorSideTop.Control = CorrXZEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
@@ -351,7 +296,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
end end
object coryzlabel: TLabel object coryzlabel: TLabel
AnchorSideLeft.Control = PanelPage2 AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = ryz AnchorSideTop.Control = CorrYZEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
@@ -360,9 +305,9 @@ object TwoCorrsFrm: TTwoCorrsFrm
Caption = 'Correlation r(y,z)' Caption = 'Correlation r(y,z)'
ParentColor = False ParentColor = False
end end
object sampsizelabel: TLabel object SampleSizeLabel: TLabel
AnchorSideLeft.Control = PanelPage2 AnchorSideLeft.Control = PanelPage2
AnchorSideTop.Control = SampSize AnchorSideTop.Control = SampleSizeEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 15 Height = 15
@@ -371,7 +316,7 @@ object TwoCorrsFrm: TTwoCorrsFrm
Caption = 'Sample Size:' Caption = 'Sample Size:'
ParentColor = False ParentColor = False
end end
object rxy: TEdit object CorrXYEdit: TEdit
AnchorSideLeft.Control = corxylabel AnchorSideLeft.Control = corxylabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PanelPage2 AnchorSideTop.Control = PanelPage2
@@ -383,13 +328,13 @@ object TwoCorrsFrm: TTwoCorrsFrm
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Top = 16 BorderSpacing.Top = 16
TabOrder = 0 TabOrder = 0
Text = 'rxy' Text = 'CorrXYEdit'
end end
object SampSize: TEdit object SampleSizeEdit: TEdit
AnchorSideLeft.Control = rxy AnchorSideLeft.Control = CorrXYEdit
AnchorSideTop.Control = ryz AnchorSideTop.Control = CorrYZEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = rxy AnchorSideRight.Control = CorrXYEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 105 Left = 105
Height = 23 Height = 23
@@ -400,13 +345,13 @@ object TwoCorrsFrm: TTwoCorrsFrm
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Bottom = 24 BorderSpacing.Bottom = 24
TabOrder = 3 TabOrder = 3
Text = 'Edit1' Text = 'SampleSizeEdit'
end end
object rxz: TEdit object CorrXZEdit: TEdit
AnchorSideLeft.Control = rxy AnchorSideLeft.Control = CorrXYEdit
AnchorSideTop.Control = rxy AnchorSideTop.Control = CorrXYEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = rxy AnchorSideRight.Control = CorrXYEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 105 Left = 105
Height = 23 Height = 23
@@ -416,13 +361,13 @@ object TwoCorrsFrm: TTwoCorrsFrm
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 1 TabOrder = 1
Text = 'Edit1' Text = 'CorrXZEdit'
end end
object ryz: TEdit object CorrYZEdit: TEdit
AnchorSideLeft.Control = rxy AnchorSideLeft.Control = CorrXYEdit
AnchorSideTop.Control = rxz AnchorSideTop.Control = CorrXZEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = rxy AnchorSideRight.Control = CorrXYEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 105 Left = 105
Height = 23 Height = 23
@@ -432,21 +377,21 @@ object TwoCorrsFrm: TTwoCorrsFrm
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 2 TabOrder = 2
Text = 'Edit1' Text = 'CorrXZEdit'
end end
end end
end end
object Page3: TPage object Page3: TPage
object PanelPage3: TPanel object PanelPage3: TPanel
Left = 0 Left = 0
Height = 223 Height = 292
Top = 0 Top = 0
Width = 446 Width = 384
Align = alClient Align = alClient
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 223 ClientHeight = 292
ClientWidth = 446 ClientWidth = 384
TabOrder = 0 TabOrder = 0
object SelVarLabel: TLabel object SelVarLabel: TLabel
AnchorSideLeft.Control = PanelPage3 AnchorSideLeft.Control = PanelPage3
@@ -462,175 +407,301 @@ object TwoCorrsFrm: TTwoCorrsFrm
AnchorSideLeft.Control = PanelPage3 AnchorSideLeft.Control = PanelPage3
AnchorSideTop.Control = SelVarLabel AnchorSideTop.Control = SelVarLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Var1In
AnchorSideBottom.Control = PanelPage3 AnchorSideBottom.Control = PanelPage3
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 206 Height = 275
Top = 17 Top = 17
Width = 246 Width = 173
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 6
ItemHeight = 0 ItemHeight = 0
OnClick = VarListClick OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object Bevel1: TBevel object Bevel1: TBevel
AnchorSideLeft.Control = PanelPage3 AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
Left = 200 Left = 169
Height = 13 Height = 13
Top = 2 Top = 2
Width = 46 Width = 46
Shape = bsSpacer Shape = bsSpacer
end end
object Panel1: TPanel object Var1In: TBitBtn
AnchorSideLeft.Control = Bevel1 AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 179
Height = 26
Top = 17
Width = 26
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var1InClick
Spacing = 0
TabOrder = 1
end
object Var1Out: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1In
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 47
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var1OutClick
Spacing = 0
TabOrder = 2
end
object XVarLabel: TLabel
AnchorSideLeft.Control = XVarEdit
AnchorSideTop.Side = asrCenter
AnchorSideBottom.Control = XVarEdit
Left = 213
Height = 15
Top = 25
Width = 84
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'First Variable (X)'
ParentColor = False
end
object XVarEdit: TEdit
AnchorSideLeft.Control = Var1In
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = PanelPage3 AnchorSideRight.Control = PanelPage3
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 246 AnchorSideBottom.Control = Var1Out
Height = 116 AnchorSideBottom.Side = asrBottom
Top = 32 Left = 213
Width = 162
AutoSize = True
BevelOuter = bvNone
ClientHeight = 116
ClientWidth = 162
TabOrder = 1
object xlabel: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Xvar
AnchorSideTop.Side = asrCenter
Left = 48
Height = 15
Top = 4
Width = 18
Alignment = taRightJustify
BorderSpacing.Left = 48
Caption = 'X ='
ParentColor = False
end
object Xvar: TEdit
AnchorSideLeft.Control = xlabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 74
Height = 23 Height = 23
Top = 0 Top = 42
Width = 88 Width = 171
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
ReadOnly = True BorderSpacing.Bottom = 8
TabOrder = 0
Text = 'Xvar'
end
object ylabel: TLabel
AnchorSideTop.Control = Yvar
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = xlabel
AnchorSideRight.Side = asrBottom
Left = 48
Height = 15
Top = 35
Width = 18
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Y ='
ParentColor = False
end
object Yvar: TEdit
AnchorSideLeft.Control = Xvar
AnchorSideTop.Control = Xvar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Xvar
AnchorSideRight.Side = asrBottom
Left = 74
Height = 23
Top = 31
Width = 88
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
ReadOnly = True
TabOrder = 1
Text = 'Edit1'
end
object zlabel: TLabel
AnchorSideTop.Control = Zvar
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = xlabel
AnchorSideRight.Side = asrBottom
Left = 48
Height = 15
Top = 66
Width = 18
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Z ='
ParentColor = False
end
object Zvar: TEdit
AnchorSideLeft.Control = Xvar
AnchorSideTop.Control = Yvar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Xvar
AnchorSideRight.Side = asrBottom
Left = 74
Height = 23
Top = 62
Width = 88
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
ReadOnly = True
TabOrder = 2
Text = 'Edit1'
end
object GroupLabel: TLabel
AnchorSideTop.Control = GroupVar
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = xlabel
AnchorSideRight.Side = asrBottom
Left = 22
Height = 15
Top = 97
Width = 44
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Group ='
ParentColor = False
end
object GroupVar: TEdit
AnchorSideLeft.Control = Xvar
AnchorSideTop.Control = Zvar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Xvar
AnchorSideRight.Side = asrBottom
Left = 74
Height = 23
Top = 93
Width = 88
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
ReadOnly = True ReadOnly = True
TabOrder = 3 TabOrder = 3
Text = 'Edit1' Text = 'XVarEdit'
end end
object Var2In: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1Out
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 89
Width = 26
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var2InClick
Spacing = 0
TabOrder = 4
end end
object Var2Out: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2In
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 119
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var2OutClick
Spacing = 0
TabOrder = 5
end end
end object YVarLabel: TLabel
end AnchorSideLeft.Control = YVarEdit
object Bevel2: TBevel AnchorSideTop.Side = asrCenter
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn AnchorSideBottom.Control = YVarEdit
Left = 0 Left = 213
Height = 8 Height = 15
Top = 342 Top = 97
Width = 462 Width = 101
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Second Variable (Y)'
ParentColor = False
end
object YVarEdit: TEdit
AnchorSideLeft.Control = XVarLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PanelPage3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var2Out
AnchorSideBottom.Side = asrBottom
Left = 213
Height = 23
Top = 114
Width = 171
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 6
Text = 'YVarEdit'
end
object Var3In: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2Out
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 161
Width = 26
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var3InClick
Spacing = 0
TabOrder = 7
end
object Var3Out: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var3In
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 191
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var3OutClick
Spacing = 0
TabOrder = 8
end
object ZVarLabel: TLabel
AnchorSideLeft.Control = ZVarEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ZVarEdit
Left = 213
Height = 15
Top = 169
Width = 89
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Third Variable (Z)'
ParentColor = False
end
object ZVarEdit: TEdit
AnchorSideLeft.Control = YVarEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PanelPage3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var3Out
AnchorSideBottom.Side = asrBottom
Left = 213
Height = 23
Top = 186
Width = 171
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 9
Text = 'ZVarEdit'
end
object GrpIn: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var3Out
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 233
Width = 26
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = GrpInClick
Spacing = 0
TabOrder = 10
end
object GrpOut: TBitBtn
AnchorSideLeft.Control = PanelPage3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = GrpIn
AnchorSideTop.Side = asrBottom
Left = 179
Height = 26
Top = 263
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = GrpOutClick
Spacing = 0
TabOrder = 11
end
object GroupVarLabel: TLabel
AnchorSideLeft.Control = GroupVarEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GroupVarEdit
Left = 213
Height = 15
Top = 241
Width = 77
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
Caption = 'Group Variable'
ParentColor = False
end
object GroupVarEdit: TEdit
AnchorSideLeft.Control = ZVarEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PanelPage3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = GrpOut
AnchorSideBottom.Side = asrBottom
Left = 213
Height = 23
Top = 258
Width = 171
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 12
Text = 'GroupVarEdit'
end
end
end
end
object Bevel5: TBevel[10]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ParamsPanel
Left = 188
Height = 41
Top = 0
Width = 16
Shape = bsSpacer
end
end
inherited ParamsSplitter: TSplitter
Left = 404
Height = 460
end end
end end

View File

@@ -5,198 +5,181 @@ unit TwoCorrsUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, ExtCtrls, StdCtrls, Buttons,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit; MainUnit, Globals, FunctionsLib, DataProcs, BasicStatsReportFormUnit;
type type
{ TTwoCorrsFrm } { TTwoCorrsForm }
TTwoCorrsFrm = class(TForm) TTwoCorrsForm = class(TBasicStatsReportForm)
Bevel1: TBevel; Bevel1: TBevel;
Bevel2: TBevel; Bevel5: TBevel;
HelpBtn: TButton; Notebook: TNotebook;
Notebook1: TNotebook;
Page1: TPage; Page1: TPage;
Page2: TPage; Page2: TPage;
Page3: TPage; Page3: TPage;
Panel1: TPanel;
PanelPage1: TPanel; PanelPage1: TPanel;
ResetBtn: TButton; CIntervalEdit: TEdit;
ComputeBtn: TButton;
ReturnBtn: TButton;
CInterval: TEdit;
Label14: TLabel; Label14: TLabel;
Xvar: TEdit; Var1In: TBitBtn;
Yvar: TEdit; Var2In: TBitBtn;
Zvar: TEdit; Var1Out: TBitBtn;
GroupVar: TEdit; Var3In: TBitBtn;
xlabel: TLabel; Var2Out: TBitBtn;
ylabel: TLabel; GrpIn: TBitBtn;
zlabel: TLabel; Var3Out: TBitBtn;
GroupLabel: TLabel; GrpOut: TBitBtn;
XVarEdit: TEdit;
YVarEdit: TEdit;
ZVarEdit: TEdit;
GroupVarEdit: TEdit;
XVarLabel: TLabel;
YVarLabel: TLabel;
ZVarLabel: TLabel;
GroupVarLabel: TLabel;
SelVarLabel: TLabel; SelVarLabel: TLabel;
VarList: TListBox; VarList: TListBox;
PanelPage3: TPanel; PanelPage3: TPanel;
rxy1: TEdit; Corr1Edit: TEdit;
Size1: TEdit; SampleSize1Edit: TEdit;
rxy2: TEdit; Corr2Edit: TEdit;
Size2: TEdit; Size2Edit: TEdit;
firstcorlabel: TLabel; firstcorlabel: TLabel;
size1label: TLabel; size1label: TLabel;
SecdCorLabel: TLabel; SecdCorLabel: TLabel;
Size2Label: TLabel; Size2Label: TLabel;
rxy: TEdit; CorrXYEdit: TEdit;
rxz: TEdit; CorrXZEdit: TEdit;
ryz: TEdit; CorrYZEdit: TEdit;
SampSize: TEdit; SampleSizeEdit: TEdit;
corxylabel: TLabel; corxylabel: TLabel;
corxzlabel: TLabel; corxzlabel: TLabel;
coryzlabel: TLabel; coryzlabel: TLabel;
sampsizelabel: TLabel; SampleSizeLabel: TLabel;
PanelPage2: TPanel; PanelPage2: TPanel;
RadioGroup1: TRadioGroup; DataSourceGroup: TRadioGroup;
RadioGroup2: TRadioGroup; DepIndepGroup: TRadioGroup;
procedure ComputeBtnClick(Sender: TObject); procedure DataSourceGroupClick(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure DepIndepGroupClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure GrpInClick(Sender: TObject);
procedure FormShow(Sender: TObject); procedure GrpOutClick(Sender: TObject);
procedure HelpBtnClick(Sender: TObject); procedure Var1InClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject); procedure Var1OutClick(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject); procedure Var2InClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject); procedure Var2OutClick(Sender: TObject);
procedure VarListClick(Sender: TObject); procedure Var3InClick(Sender: TObject);
procedure Var3OutClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
private private
{ private declarations }
FAutoSized: Boolean;
independent: boolean; independent: boolean;
griddata: boolean; griddata: boolean;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end; end;
var var
TwoCorrsFrm: TTwoCorrsFrm; TwoCorrsForm: TTwoCorrsForm;
implementation implementation
{$R *.lfm}
uses uses
Math, MathUnit; Math,
MathUnit, GridProcs;
{ TTwoCorrsFrm }
procedure TTwoCorrsFrm.ResetBtnClick(Sender: TObject); { TTwoCorrsForm }
var
i: integer; constructor TTwoCorrsForm.Create(AOwner: TComponent);
begin begin
CInterval.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT); inherited;
CIntervalEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
RadioGroup1.ItemIndex := 0;
RadioGroup2.ItemIndex := 0;
Notebook1.PageIndex := 0;
VarList.Clear;
Xvar.Text := '';
Yvar.Text := '';
Zvar.Text := '';
rxy.Text := '';
rxz.Text := '';
ryz.Text := '';
SampSize.Text := '';
rxy1.Text := '';
rxy2.Text := '';
Size1.Text := '';
Size2.Text := '';
zlabel.Visible := false;
Zvar.Visible := false;
GroupLabel.Visible := true;
GroupVar.Text := '';
GroupVar.Visible := true;
independent := true;
griddata := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
end; end;
procedure TTwoCorrsFrm.VarListClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if Xvar.Text = '' then
begin
Xvar.Text := VarList.Items.Strings[index];
exit;
end;
if Yvar.Text = '' then procedure TTwoCorrsForm.AdjustConstraints;
begin
Yvar.Text := VarList.Items.Strings[index];
exit;
end;
if not independent then
begin
if Zvar.Text = '' then
begin
Zvar.Text := VarList.Items.Strings[index];
exit;
end;
end;
if independent then
begin
if GroupVar.Text = '' then
begin
GroupVar.Text := VarList.Items.Strings[index];
exit;
end;
end;
end;
procedure TTwoCorrsFrm.FormActivate(Sender: TObject);
var var
w: Integer; w: Integer;
begin begin
if FAutoSized then inherited;
exit;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]); w := Max(DataSourceGroup.Width, DepIndepGroup.Width);
HelpBtn.Constraints.MinWidth := w; DataSourceGroup.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w; DepIndepGroup.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w; ParamsPanel.Constraints.MinWidth := Max(
ReturnBtn.Constraints.MinWidth := w; CloseBtn.Width * 4 + CloseBtn.BorderSpacing.Left * 3,
w * 2 + DepIndepGroup.BorderSpacing.Left
Width := Max(
RadioGroup2.Left + RadioGroup2.Width + RadioGroup2.BorderSpacing.Right,
Width - HelpBtn.Left + HelpBtn.BorderSpacing.Left
); );
Constraints.MinWidth := Width; ParamsPanel.Constraints.MinHeight := DataSourceGroup.Height +
Constraints.MinHeight := Height; NoteBook.BorderSpacing.Top + Var3Out.Top + Var3Out.Height +
NoteBook.BorderSpacing.Bottom + CIntervalEdit.Height +
FAutoSized := true; ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height;
end; end;
procedure TTwoCorrsFrm.FormCreate(Sender: TObject);
procedure TTwoCorrsForm.Reset;
var
i: integer;
begin begin
Assert(OS3MainFrm <> nil); inherited;
DataSourceGroup.ItemIndex := 0;
DepIndepGroup.ItemIndex := 0;
independent := true;
griddata := false;
Notebook.PageIndex := 0;
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
XVarEdit.Clear;
YVarEdit.Clear;
ZVarEdit.Clear;
CorrXYEdit.Clear;
CorrXZEdit.Clear;
CorrYZEdit.Clear;
SampleSizeEdit.Clear;
Corr1Edit.Clear;
Corr2Edit.Clear;
SampleSize1Edit.Clear;
Size2Edit.Clear;
// ZVarLabel.Visible := false;
// ZVarEdit.Visible := false;
// GroupVarLabel.Visible := true;
GroupVarEdit.Clear;
// GroupVarEdit.Visible := true;
ZVarEdit.Visible := false;
ZVarLabel.Visible := ZVarEdit.Visible;
Var3In.Visible := ZVarEdit.Visible;
Var3Out.Visible := ZVarEdit.Visible;
GroupVarEdit.Visible := not ZVarEdit.Visible;
GroupVarLabel.Visible := GroupVarEdit.Visible;
GrpIn.Visible := GroupVarEdit.Visible;
GrpOut.Visible := GroupVarEdit.Visible;
end; end;
procedure TTwoCorrsFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TTwoCorrsFrm.HelpBtnClick(Sender: TObject); procedure TTwoCorrsForm.Compute;
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TTwoCorrsFrm.ComputeBtnClick(Sender: TObject);
var var
lReport: TStrings; lReport: TStrings;
Corxy, Corxz, Coryz, Cor1, Cor2, alpha, tvalue, df2: double; Corxy, Corxz, Coryz, Cor1, Cor2, alpha, tvalue, df2: double;
@@ -206,21 +189,11 @@ var
stddev1, stddev2, stddev3, value1, value2, value3: double; stddev1, stddev2, stddev3, value1, value2, value3: double;
meanx1, meanx2, meany1, meany2, varx1, varx2, vary1, vary2: double; meanx1, meanx2, meany1, meany2, varx1, varx2, vary1, vary2: double;
sdx1, sdx2, sdy1, sdy2: double; sdx1, sdx2, sdy1, sdy2: double;
SSize1, SSize2, SSize, v1, v2, v3, grp, ncases, NoSelected: integer; SSize1, SSize2, SSize, {v1, v2, v3, grp, }ncases: Integer; //, NoSelected: integer;
min, max, grpval, ncases1, ncases2, i: integer; min, max, grpval, ncases1, ncases2, i: integer;
cellstring: string; cellstring: string;
msg: String;
C: TWinControl;
ColNoSelected: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil;
begin begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
ModalResult := mrNone;
exit;
end;
SetLength(ColNoSelected, NoVariables); SetLength(ColNoSelected, NoVariables);
Corxy := 0.0; Corxy := 0.0;
Corxz := 0.0; Corxz := 0.0;
@@ -236,7 +209,7 @@ begin
meanx1 := 0.0; meanx1 := 0.0;
meanx2 := 0.0; meanx2 := 0.0;
meany1 := 0.0; meany1 := 0.0;
ConfLevel := StrToFloat(CInterval.Text) / 100.0; ConfLevel := StrToFloat(CIntervalEdit.Text) / 100.0;
// *** USE DATA ON THE FORM *** // *** USE DATA ON THE FORM ***
if not griddata then if not griddata then
@@ -244,10 +217,10 @@ begin
// read data from form and obtain results // read data from form and obtain results
if independent then if independent then
begin begin
Cor1 := StrToFloat(rxy1.Text); Cor1 := StrToFloat(Corr1Edit.Text);
Cor2 := StrToFloat(rxy2.Text); Cor2 := StrToFloat(Corr2Edit.Text);
SSize1 := StrToInt(Size1.Text); SSize1 := StrToInt(SampleSize1Edit.Text);
SSize2 := StrToInt(Size2.Text); SSize2 := StrToInt(Size2Edit.Text);
CorDif := Cor1 - Cor2; CorDif := Cor1 - Cor2;
zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1)); zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1));
zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2)); zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2));
@@ -266,10 +239,10 @@ begin
// obtain data from form and obtain results // obtain data from form and obtain results
if not independent then if not independent then
begin begin
Corxy := StrToFloat(rxy.Text); Corxy := StrToFloat(CorrXYEdit.Text);
Corxz := StrToFloat(rxz.Text); Corxz := StrToFloat(CorrXZEdit.Text);
Coryz := StrToFloat(ryz.Text); Coryz := StrToFloat(CorrYZEdit.Text);
SSize := StrToInt(SampSize.Text); SSize := StrToInt(SampleSizeEdit.Text);
CorDif := Corxy - Corxz; CorDif := Corxy - Corxz;
alpha := (1.0 - ConfLevel) / 2.0; alpha := (1.0 - ConfLevel) / 2.0;
tvalue := CorDif * sqrt((SSize - 3.0) * (1.0 + Coryz)) / sqrt(2.0 * (1.0 - Corxy*Corxy - Corxz*Corxz - Coryz*Coryz + 2.0*Corxy*Corxz*Coryz)); tvalue := CorDif * sqrt((SSize - 3.0) * (1.0 + Coryz)) / sqrt(2.0 * (1.0 - Corxy*Corxy - Corxz*Corxz - Coryz*Coryz + 2.0*Corxy*Corxz*Coryz));
@@ -279,26 +252,33 @@ begin
end; end;
end; end;
// *** USE DATA FROM THE GRID ***
if griddata then if griddata then
begin begin
v1 := 1; //v1 := 1;
v2 := 1; //v2 := 1;
grp := 1; //grp := 1;
// read grid data for independent r's // read grid data for independent r's
if independent then if independent then
begin begin
SetLength(ColNoSelected, 3);
ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, XVarEdit.Text);
ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, YVarEdit.Text);
ColNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, GroupVarEdit.Text);
(*
for i := 1 to NoVariables do for i := 1 to NoVariables do
begin begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0]; cellstring := OS3MainFrm.DataGrid.Cells[i,0];
if cellstring = Xvar.Text then v1 := i; if cellstring = XVarEdit.Text then v1 := i;
if cellstring = Yvar.Text then v2 := i; if cellstring = YVarEdit.Text then v2 := i;
if cellstring = GroupVar.Text then grp := i; if cellstring = GroupVarEdit.Text then grp := i;
end; end;
ColNoSelected[0] := v1; ColNoSelected[0] := v1;
ColNoSelected[1] := v2; ColNoSelected[1] := v2;
ColNoSelected[2] := grp; ColNoSelected[2] := grp;
NoSelected := 3; NoSelected := 3;
*)
meanx1 := 0.0; meanx1 := 0.0;
meany1 := 0.0; meany1 := 0.0;
varx1 := 0.0; varx1 := 0.0;
@@ -311,26 +291,26 @@ begin
Cor2 := 0.0; Cor2 := 0.0;
ncases1 := 0; ncases1 := 0;
ncases2 := 0; ncases2 := 0;
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,1]))); min := MaxInt;
max := min; max := -min;
for i := 2 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i]))); grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i])));
if grpval > max then max := grpval; if grpval > max then max := grpval;
if grpval < min then min := grpval; if grpval < min then min := grpval;
end; end;
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i]))); grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i])));
if grpval = min then if grpval = min then
begin begin
ncases1 := ncases1 + 1; ncases1 := ncases1 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
meanx1 := meanx1 + value1; meanx1 := meanx1 + value1;
varx1 := varx1 + (value1 * value1); varx1 := varx1 + (value1 * value1);
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
meany1 := meany1 + value2; meany1 := meany1 + value2;
vary1 := vary1 + value2 * value2; vary1 := vary1 + value2 * value2;
Cor1 := Cor1 + value1 * value2; Cor1 := Cor1 + value1 * value2;
@@ -338,10 +318,10 @@ begin
if grpval = max then if grpval = max then
begin begin
ncases2 := ncases2 + 1; ncases2 := ncases2 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
meanx2 := meanx2 + value1; meanx2 := meanx2 + value1;
varx2 := varx2 + (value1 * value1); varx2 := varx2 + (value1 * value1);
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
meany2 := meany2 + value2; meany2 := meany2 + value2;
vary2 := vary2 + value2 * value2; vary2 := vary2 + value2 * value2;
Cor2 := Cor2 + value1 * value2; Cor2 := Cor2 + value1 * value2;
@@ -399,24 +379,17 @@ begin
Corxz := 0.0; Corxz := 0.0;
Coryz := 0.0; Coryz := 0.0;
ncases := 0; ncases := 0;
for i := 1 to NoVariables do SetLength(ColNoSelected, 3);
begin ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, XVarEdit.Text);
cellstring := OS3MainFrm.DataGrid.Cells[i,0]; ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, YVarEdit.Text);
if cellstring = Xvar.Text then v1 := i; ColNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, ZVarEdit.Text);
if cellstring = Yvar.Text then v2 := i;
if cellstring = ZVar.Text then v3 := i;
end;
ColNoSelected[0] := v1;
ColNoSelected[1] := v2;
ColNoSelected[2] := v3;
NoSelected := 3;
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
ncases := ncases + 1; ncases := ncases + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v3,i])); value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]));
mean1 := mean1 + value1; mean1 := mean1 + value1;
mean2 := mean2 + value2; mean2 := mean2 + value2;
mean3 := mean3 + value3; mean3 := mean3 + value3;
@@ -428,22 +401,22 @@ begin
Coryz := Coryz + value2 * value3; Coryz := Coryz + value2 * value3;
end; end;
variance1 := variance1 - mean1 * mean1 / ncases; variance1 := variance1 - mean1 * mean1 / ncases;
variance1 := variance1 / (ncases - 1.0); variance1 := variance1 / (ncases - 1);
stddev1 := sqrt(variance1); stddev1 := sqrt(variance1);
variance2 := variance2 - mean2 * mean2 / ncases; variance2 := variance2 - mean2 * mean2 / ncases;
variance2 := variance2 / (ncases - 1.0); variance2 := variance2 / (ncases - 1);
stddev2 := sqrt(variance2); stddev2 := sqrt(variance2);
variance3 := variance3 - mean3 * mean3 / ncases; variance3 := variance3 - mean3 * mean3 / ncases;
variance3 := variance3 / (ncases - 1.0); variance3 := variance3 / (ncases - 1);
stddev3 := sqrt(variance3); stddev3 := sqrt(variance3);
Corxy := Corxy - mean1 * mean2 / ncases; Corxy := Corxy - mean1 * mean2 / ncases;
Corxy := Corxy / (ncases - 1.0); Corxy := Corxy / (ncases - 1);
Corxy := Corxy / (stddev1 * stddev2); Corxy := Corxy / (stddev1 * stddev2);
Corxz := Corxz - mean1 * mean3 / ncases; Corxz := Corxz - mean1 * mean3 / ncases;
Corxz := Corxz / (ncases - 1.0); Corxz := Corxz / (ncases - 1);
Corxz := Corxz / (stddev1 * stddev3); Corxz := Corxz / (stddev1 * stddev3);
Coryz := Coryz - mean2 * mean3 / ncases; Coryz := Coryz - mean2 * mean3 / ncases;
Coryz := Coryz / (ncases - 1.0); Coryz := Coryz / (ncases - 1);
Coryz := Coryz / (stddev2 * stddev3); Coryz := Coryz / (stddev2 * stddev3);
mean1 := mean1 / ncases; mean1 := mean1 / ncases;
mean2 := mean2 / ncases; mean2 := mean2 / ncases;
@@ -471,7 +444,7 @@ begin
lReport.Add('Correlation two: %6.3f', [Cor2]); lReport.Add('Correlation two: %6.3f', [Cor2]);
lReport.Add('Sample size two: %6d', [SSize2]); lReport.Add('Sample size two: %6d', [SSize2]);
lReport.Add('Difference between correlations: %6.3f', [CorDif]); lReport.Add('Difference between correlations: %6.3f', [CorDif]);
lReport.Add('Confidence level selected: %6s', [CInterval.Text]); lReport.Add('Confidence level selected: %6s', [CIntervalEdit.Text]);
lReport.Add('z for Correlation One: %6.3f', [zOne]); lReport.Add('z for Correlation One: %6.3f', [zOne]);
lReport.Add('z for Correlation Two: %6.3f', [zTwo]); lReport.Add('z for Correlation Two: %6.3f', [zTwo]);
lReport.Add('z difference: %6.3f', [zDif]); lReport.Add('z difference: %6.3f', [zDif]);
@@ -480,7 +453,7 @@ begin
lReport.Add('Probability > |z|: %6.3f', [zprobability]); lReport.Add('Probability > |z|: %6.3f', [zprobability]);
lReport.Add('z Required for significance: %6.3f', [zTest]); lReport.Add('z Required for significance: %6.3f', [zTest]);
lReport.Add('Note: above is a two-tailed test.'); lReport.Add('Note: above is a two-tailed test.');
lReport.Add('Confidence Limits = (%.3f ... %.3f)', [LCL, UCL]); lReport.Add('Confidence Limits: %6.3f ... %.3f', [LCL, UCL]);
lReport.Add(''); lReport.Add('');
if griddata then if griddata then
begin begin
@@ -488,7 +461,7 @@ begin
lReport.Add('Mean X for group 2: %9.3f', [meanx2]); lReport.Add('Mean X for group 2: %9.3f', [meanx2]);
lReport.Add('Std.Dev. X for group 1: %9.3f', [sdx1]); lReport.Add('Std.Dev. X for group 1: %9.3f', [sdx1]);
lReport.Add('Std.Dev. X for group 2: %9.3f', [sdx2]); lReport.Add('Std.Dev. X for group 2: %9.3f', [sdx2]);
lReport.Add('Mean y for group 1; %9.3f', [meany1]); lReport.Add('Mean y for group 1: %9.3f', [meany1]);
lReport.Add('Mean Y for group 2: %9.3f', [meany2]); lReport.Add('Mean Y for group 2: %9.3f', [meany2]);
lReport.Add('Std.Dev. Y for group 1: %9.3f', [sdy1]); lReport.Add('Std.Dev. Y for group 1: %9.3f', [sdy1]);
lReport.Add('Std.Dev. Y for group 2: %9.3f', [sdy2]); lReport.Add('Std.Dev. Y for group 2: %9.3f', [sdy2]);
@@ -501,7 +474,7 @@ begin
lReport.Add('Correlation x with z: %6.3f', [Corxz]); lReport.Add('Correlation x with z: %6.3f', [Corxz]);
lReport.Add('Correlation y with z: %6.3f', [Coryz]); lReport.Add('Correlation y with z: %6.3f', [Coryz]);
lReport.Add('Sample size: %6d', [SSize]); lReport.Add('Sample size: %6d', [SSize]);
lReport.Add('Confidence Level Selected: %6s', [CInterval.Text]); lReport.Add('Confidence Level Selected: %6s', [CIntervalEdit.Text]);
lReport.Add('Difference r(x,y) - r(x,z): %6.3f', [CorDif]); lReport.Add('Difference r(x,y) - r(x,z): %6.3f', [CorDif]);
lReport.Add('t test statistic: %6.3f', [tvalue]); lReport.Add('t test statistic: %6.3f', [tvalue]);
lReport.Add('Probability > |t|: %6.3f', [tprobability]); lReport.Add('Probability > |t|: %6.3f', [tprobability]);
@@ -510,82 +483,113 @@ begin
if griddata then if griddata then
begin begin
lReport.Add('Variable Mean Variance Std.Dev. '); lReport.Add('Variable Mean Variance Std.Dev. ');
lReport.Add(' X %9.3f %9.3f %9.3f', [mean1, variance1, stddev1]); lReport.Add('-------- ---------- ---------- ----------');
lReport.Add(' Y %9.3f %9.3f %9.3f', [mean2, variance2, stddev2]); lReport.Add(' X %10.3f %10.3f %10.3f', [mean1, variance1, stddev1]);
lReport.Add(' Z %9.3f %9.3f %9.3f', [mean3, variance3, stddev3]); lReport.Add(' Y %10.3f %10.3f %10.3f', [mean2, variance2, stddev2]);
lReport.Add(' Z %10.3f %10.3f %10.3f', [mean3, variance3, stddev3]);
end; end;
end; end;
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
ColNoSelected := nil;
end; end;
end; end;
procedure TTwoCorrsFrm.RadioGroup1Click(Sender: TObject);
procedure TTwoCorrsForm.DataSourceGroupClick(Sender: TObject);
var var
index: integer; index: integer;
begin begin
index := RadioGroup1.ItemIndex; index := DataSourceGroup.ItemIndex;
if index = 0 then if index = 0 then
begin begin
griddata := false; griddata := false;
if independent then if independent then
Notebook1.PageIndex := 0 Notebook.PageIndex := 0
else else
Notebook1.PageIndex := 1; Notebook.PageIndex := 1;
end else end else
begin begin
griddata := true; griddata := true;
Notebook1.PageIndex := 2; Notebook.PageIndex := 2;
end; end;
end; end;
procedure TTwoCorrsFrm.RadioGroup2Click(Sender: TObject);
procedure TTwoCorrsForm.DepIndepGroupClick(Sender: TObject);
var var
index1, index2: integer; index1, index2: integer;
begin begin
index1 := RadioGroup1.ItemIndex; index1 := DataSourceGroup.ItemIndex;
index2 := RadioGroup2.ItemIndex; index2 := DepIndepGroup.ItemIndex;
// form input with independent corrs // form input with independent corrs
if ((index2 = 0) and (index1 = 0)) then if ((index2 = 0) and (index1 = 0)) then
begin begin
independent := true; independent := true;
Notebook1.PageIndex := 0; Notebook.PageIndex := 0;
end; end;
// grid data for independent corrs // grid data for independent corrs
if ((index2 = 0) and (index1 = 1)) then if ((index2 = 0) and (index1 = 1)) then
begin begin
Notebook1.PageIndex := 2; Notebook.PageIndex := 2;
zlabel.Visible := false; // ZVarLabel.Visible := false;
zvar.Visible := false; ZVarEdit.Visible := false;
grouplabel.Visible := true; // GroupVarLabel.Visible := true;
groupvar.Visible := true; // GroupVarEdit.Visible := true;
end; end;
// form data for dependent corrs // form data for dependent corrs
if ((index2 = 1) and (index1 = 0)) then if ((index2 = 1) and (index1 = 0)) then
begin begin
Notebook1.PageIndex := 1; Notebook.PageIndex := 1;
end; end;
// grid data for dependent corrs // grid data for dependent corrs
if ((index2 = 1) and (index1 = 1)) then if ((index2 = 1) and (index1 = 1)) then
begin begin
Notebook1.PageIndex := 2; Notebook.PageIndex := 2;
independent := false; independent := false;
zlabel.Visible := true; // ZVarLabel.Visible := true;
Zvar.Visible := true; ZVarEdit.Visible := true;
GroupLabel.Visible := false; // GroupVarLabel.Visible := false;
GroupVar.Visible := false; // GroupVarEdit.Visible := false;
end;
end; end;
function TTwoCorrsFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; // if Notebook.PageIndex = 2 then
// begin
ZVarLabel.Visible := ZVarEdit.Visible;
Var3In.Visible := ZVarEdit.Visible;
Var3Out.Visible := ZVarEdit.Visible;
GroupVarEdit.Visible := not ZVarEdit.Visible;
GroupVarLabel.Visible := GroupVarEdit.Visible;
GrpIn.Visible := GroupVarEdit.Visible;
GrpOut.Visible := GroupVarEdit.Visible;
// end;
end;
procedure TTwoCorrsForm.UpdateBtnStates;
begin
inherited;
Var1In.Enabled := (VarList.ItemIndex > -1) and (XVarEdit.Text = '');
Var2In.Enabled := (VarList.ItemIndex > -1) and (YVarEdit.Text = '');
Var3In.Enabled := (VarList.ItemIndex > -1) and (ZVarEdit.Text = '');
GrpIn.Enabled := (VarList.ItemIndex > -1) and (GroupVarEdit.Text = '');
Var1Out.Enabled := XVarEdit.Text <> '';
Var2Out.Enabled := YVarEdit.Text <> '';
Var3Out.Enabled := ZVarEdit.Text <> '';
GrpOut.Enabled := GroupVarEdit.Text <> '';
end;
function TTwoCorrsForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var var
n: Integer; n: Integer;
x: Double; x: Double;
@@ -593,75 +597,75 @@ begin
Result := false; Result := false;
AControl := nil; AControl := nil;
AMsg := ''; AMsg := '';
if Notebook1.PageIndex = 0 then if Notebook.PageIndex = 0 then
begin begin
if (rxy1.Text = '') or not TryStrToFloat(rxy1.Text, x) then if (Corr1Edit.Text = '') or not TryStrToFloat(Corr1Edit.Text, x) then
begin begin
AControl := rxy1; AControl := Corr1Edit;
AMsg := 'Invalid input for first correlation'; AMsg := 'Invalid input for first correlation';
exit; exit;
end; end;
if (Size1.Text = '') or not TryStrToInt(Size1.Text, n) or (n <= 0) then if (SampleSize1Edit.Text = '') or not TryStrToInt(SampleSize1Edit.Text, n) or (n <= 0) then
begin begin
AControl := Size1; AControl := SampleSize1Edit;
AMsg := 'Invald input for size of sample 1'; AMsg := 'Invald input for size of sample 1';
exit; exit;
end; end;
if (rxy2.Text = '') or not TryStrToFloat(rxy2.Text, x) then if (Corr2Edit.Text = '') or not TryStrToFloat(Corr2Edit.Text, x) then
begin begin
AControl := rxy2; AControl := Corr2Edit;
AMsg := 'Invalid input for second correlation'; AMsg := 'Invalid input for second correlation';
exit; exit;
end; end;
if (Size2.Text = '') or not TryStrToInt(Size2.Text, n) or (n <= 0) then if (Size2Edit.Text = '') or not TryStrToInt(Size2Edit.Text, n) or (n <= 0) then
begin begin
AControl := Size2; AControl := Size2Edit;
AMsg := 'Invalud input for size of sample 2'; AMsg := 'Invalud input for size of sample 2';
exit; exit;
end; end;
end else end else
if Notebook1.PageIndex = 1 then if Notebook.PageIndex = 1 then
begin begin
if (rxy.Text = '') or not TryStrToFloat(rxy.Text, x) then if (CorrXYEdit.Text = '') or not TryStrToFloat(CorrXYEdit.Text, x) then
AControl := rxy AControl := CorrXYEdit
else else
if (rxz.Text = '') or not TryStrToFloat(rxz.Text, x) then if (CorrXZEdit.Text = '') or not TryStrToFloat(CorrXZEdit.Text, x) then
AControl := rxz AControl := CorrXZEdit
else else
if (ryz.Text = '') or not TryStrToFloat(ryz.Text, x) then if (CorrYZEdit.Text = '') or not TryStrToFloat(CorrYZEdit.Text, x) then
AControl := ryz AControl := CorrYZEdit
else else
if (SampSize.Text = '') or not TryStrToInt(SampSize.Text, n) or (n < 0) then if (SampleSizeEdit.Text = '') or not TryStrToInt(SampleSizeEdit.Text, n) or (n < 0) then
AControl := SampSize; AControl := SampleSizeEdit;
if AControl <> nil then if AControl <> nil then
begin begin
AMsg := 'Invalid input.'; AMsg := 'Invalid input.';
exit; exit;
end; end;
end else end else
if Notebook1.PageIndex = 2 then if Notebook.PageIndex = 2 then
begin begin
if XVar.Text = '' then if XVarEdit.Text = '' then
begin begin
AControl := XVar; AControl := XVarEdit;
AMsg := 'X variable not specified.'; AMsg := 'X variable not specified.';
exit; exit;
end; end;
if YVar.Text = '' then if YVarEdit.Text = '' then
begin begin
AControl := YVar; AControl := YVarEdit;
AMsg := 'Y variable not specified.'; AMsg := 'Y variable not specified.';
exit; exit;
end; end;
case RadioGroup2.ItemIndex of case DepIndepGroup.ItemIndex of
0: if (GroupVar.Text = '') then 0: if (GroupVarEdit.Text = '') then
begin begin
AControl := GroupVar; AControl := GroupVarEdit;
AMsg := 'Group variable not specified'; AMsg := 'Group variable not specified';
exit; exit;
end; end;
1: if (ZVar.Text = '') then begin 1: if (ZVarEdit.Text = '') then begin
AControl := ZVar; AControl := ZVarEdit;
AMsg := 'Z variable not specified.'; AMsg := 'Z variable not specified.';
exit; exit;
end; end;
@@ -670,8 +674,156 @@ begin
Result := true; Result := true;
end; end;
initialization
{$I twocorrsunit.lrs} procedure TTwoCorrsForm.Var1InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
if XVarEdit.Text = '' then
begin
XVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
end;
procedure TTwoCorrsForm.Var1OutClick(Sender: TObject);
begin
if XVarEdit.Text <> '' then
begin
VarList.Items.Add(XVarEdit.Text);
XVarEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTwoCorrsForm.Var2InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if index > -1 then
begin
if YVarEdit.Text = '' then
begin
YVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
end;
procedure TTwoCorrsForm.Var2OutClick(Sender: TObject);
begin
if YVarEdit.Text <> '' then
begin
VarList.Items.Add(YVarEdit.Text);
YVarEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTwoCorrsForm.Var3InClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if (not independent) and (index > -1) then
begin
if ZVarEdit.Text = '' then
begin
ZVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
end;
procedure TTwoCorrsForm.Var3OutClick(Sender: TObject);
begin
if (not independent) and (ZVarEdit.Text <> '') then
begin
VarList.Items.Add(ZVarEdit.Text);
ZVarEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTwoCorrsForm.GrpInClick(Sender: TObject);
var
index: Integer;
begin
index := VarList.ItemIndex;
if independent and (index > -1) then
begin
if GroupVarEdit.Text = '' then
begin
GroupVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
end;
procedure TTwoCorrsForm.GrpOutClick(Sender: TObject);
begin
if independent and (GroupVarEdit.Text <> '') then
begin
VarList.Items.Add(GroupVarEdit.Text);
GroupVarEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TTwoCorrsForm.VarListDblClick(Sender: TObject);
var
index: integer;
s: String;
begin
index := VarList.ItemIndex;
if index >-1 then
begin
s := VarList.Items[index];
if XVarEdit.Text = '' then
begin
XVarEdit.Text := s;
VarList.Items.Delete(index);
end else
if YVarEdit.Text = '' then
begin
YVarEdit.Text := s;
VarList.Items.Delete(index);
end else
if (not independent) and (ZVarEdit.Text = '') then
begin
ZVarEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
end else
if independent and (GroupVarEdit.Text = '') then
begin
GroupVarEdit.Text := VarList.Items.Strings[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
end;
procedure TTwoCorrsForm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
end. end.

View File

@@ -36,7 +36,7 @@ inherited TwoPropForm: TTwoPropForm
end end
object Notebook: TNotebook[5] object Notebook: TNotebook[5]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = RadioGroup1 AnchorSideTop.Control = DataSourceGroup
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ParamsPanel AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@@ -60,8 +60,8 @@ inherited TwoPropForm: TTwoPropForm
Left = 0 Left = 0
Height = 15 Height = 15
Top = 0 Top = 0
Width = 83 Width = 97
Caption = 'Select Variables:' Caption = 'Available Variables'
ParentColor = False ParentColor = False
end end
object Var1Label: TLabel object Var1Label: TLabel
@@ -523,7 +523,7 @@ inherited TwoPropForm: TTwoPropForm
TabOrder = 5 TabOrder = 5
Text = '95.0' Text = '95.0'
end end
object RadioGroup1: TRadioGroup[8] object DataSourceGroup: TRadioGroup[8]
AnchorSideTop.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = Bevel5 AnchorSideRight.Control = Bevel5
Left = -3 Left = -3
@@ -549,7 +549,7 @@ inherited TwoPropForm: TTwoPropForm
'Values Entered on this Form' 'Values Entered on this Form'
'Values in the Data Grid' 'Values in the Data Grid'
) )
OnClick = RadioGroup1Click OnClick = DataSourceGroupClick
TabOrder = 6 TabOrder = 6
end end
object DepIndepGroup: TRadioGroup[9] object DepIndepGroup: TRadioGroup[9]

View File

@@ -58,11 +58,11 @@ type
Samp20Label: TLabel; Samp20Label: TLabel;
GrpOut: TBitBtn; GrpOut: TBitBtn;
VarList: TListBox; VarList: TListBox;
RadioGroup1: TRadioGroup; DataSourceGroup: TRadioGroup;
DepIndepGroup: TRadioGroup; DepIndepGroup: TRadioGroup;
procedure GrpInClick(Sender: TObject); procedure GrpInClick(Sender: TObject);
procedure GrpOutClick(Sender: TObject); procedure GrpOutClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject); procedure DataSourceGroupClick(Sender: TObject);
procedure DepIndepGroupClick(Sender: TObject); procedure DepIndepGroupClick(Sender: TObject);
procedure Var1InClick(Sender: TObject); procedure Var1InClick(Sender: TObject);
procedure Var1OutClick(Sender: TObject); procedure Var1OutClick(Sender: TObject);
@@ -94,7 +94,8 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Math; Math,
GridProcs;
{ TTwoPropForm } { TTwoPropForm }
@@ -107,13 +108,20 @@ end;
procedure TTwoPropForm.AdjustConstraints; procedure TTwoPropForm.AdjustConstraints;
var
w: Integer;
begin begin
inherited; inherited;
w := Max(DataSourceGroup.Width, DepIndepGroup.Width);
DataSourceGroup.Constraints.MinWidth := w;
DepIndepGroup.Constraints.MinWidth := w;
ParamsPanel.Constraints.MinWidth := Max( ParamsPanel.Constraints.MinWidth := Max(
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
RadioGroup1.Width + Bevel5.Width + DepIndepGroup.Width 2*w + Bevel5.Width
); );
ParamsPanel.Constraints.MinHeight := GrpOut.Top + GrpOut.Height + ParamsPanel.Constraints.MinHeight := DataSourceGroup.Height +
Notebook.BorderSpacing.Top + Var2Out.Top + Var2Out.Height +
Notebook.BorderSpacing.Bottom + CIntervalEdit.Height + ButtonBevel.Height + Notebook.BorderSpacing.Bottom + CIntervalEdit.Height + ButtonBevel.Height +
CloseBtn.BorderSpacing.Top + CloseBtn.Height; CloseBtn.BorderSpacing.Top + CloseBtn.Height;
end; end;
@@ -124,7 +132,8 @@ var
ConfInt, Prop1, Prop2, zstatistic, zprobability: double; ConfInt, Prop1, Prop2, zstatistic, zprobability: double;
PropDif, stderr, UCL, LCL, value1, value2, ztest: double; PropDif, stderr, UCL, LCL, value1, value2, ztest: double;
P, Q: double; P, Q: double;
i, v1, v2, NoSelected, f1, f2, f3, f4, ncases1, ncases2: integer; i: Integer; //, v1, v2, NoSelected,
f1, f2, f3, f4, ncases1, ncases2: integer;
min, max, group, AB, AC, CD, BD: integer; min, max, group, AB, AC, CD, BD: integer;
ColNoSelected: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil;
lReport: TStrings; lReport: TStrings;
@@ -132,12 +141,12 @@ begin
// Initialize output form // Initialize output form
stderr := 0.0; stderr := 0.0;
PropDif := 0.0; PropDif := 0.0;
v2 := 0; // v2 := 0;
ztest := 0.0; ztest := 0.0;
Prop1 := 0.0; Prop1 := 0.0;
Prop2 := 0.0; Prop2 := 0.0;
NoSelected := 0; // NoSelected := 0;
v1 := 0; // v1 := 0;
zstatistic := 0.0; zstatistic := 0.0;
zprobability := 0.0; zprobability := 0.0;
UCL := 0.0; UCL := 0.0;
@@ -147,6 +156,7 @@ begin
ConfInt := (100.0 - StrToFloat(CIntervalEdit.Text)) / 2.0 ; ConfInt := (100.0 - StrToFloat(CIntervalEdit.Text)) / 2.0 ;
ConfInt := (100.0 - ConfInt) / 100.0; // one tail ConfInt := (100.0 - ConfInt) / 100.0; // one tail
ncases1 := 0; ncases1 := 0;
ncases2 := 0; ncases2 := 0;
f1 := 0; f1 := 0;
@@ -158,6 +168,10 @@ begin
if griddata then // data read from grid if griddata then // data read from grid
begin begin
SetLength(ColNoSelected, 2);
ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, Var1Edit.Text);
ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Var2Edit.Text);
{
for i := 1 to NoVariables do for i := 1 to NoVariables do
begin begin
if Var1Edit.Text = OS3MainFrm.DataGrid.Cells[i,0] then if Var1Edit.Text = OS3MainFrm.DataGrid.Cells[i,0] then
@@ -172,30 +186,34 @@ begin
ColNoSelected[1] := i; ColNoSelected[1] := i;
end; end;
end; // next variable end; // next variable
}
f1 := 0;
f2 := 0;
nCases1 := 0;
if not independent then // correlated data if not independent then // correlated data
begin begin
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
ncases1 := ncases1 + 1; nCases1 := nCases1 + 1;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]));
f1 := f1 + round(value1); f1 := f1 + round(value1);
f2 := f2 + round(value2); f2 := f2 + round(value2);
end; // next case end; // next case
f3 := ncases1 - f1; f3 := nCases1 - f1;
f4 := ncases1 - f2; f4 := nCases1 - f2;
AB := f1 + f2; AB := f1 + f2;
AC := f1 + f3; AC := f1 + f3;
CD := f3 + f4; CD := f3 + f4;
BD := f2 + f4; BD := f2 + f4;
Prop1 := BD / ncases1; Prop1 := BD / nCases1;
Prop2 := AB / ncases1; Prop2 := AB / nCases1;
stderr := sqrt((f1 / ncases1 + f4 / ncases1) / ncases1); stderr := sqrt((f1 / nCases1 + f4 / nCases1) / nCases1);
PropDif := Prop1 - Prop2; PropDif := Prop1 - Prop2;
zstatistic := PropDif / stderr; zstatistic := PropDif / stderr;
ztest := inversez(ConfInt); ztest := InverseZ(ConfInt);
zprobability := 1.0 - ProbZ(abs(zstatistic)); zprobability := 1.0 - ProbZ(abs(zstatistic));
UCL := PropDif + stderr * ztest; UCL := PropDif + stderr * ztest;
LCL := PropDif - stderr * ztest; LCL := PropDif - stderr * ztest;
@@ -203,21 +221,21 @@ begin
if independent then if independent then
begin begin
min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,1]))); min := MaxInt;
max := min; max := min;
for i := 2 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]))); group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])));
if group < min then min := group; if group < min then min := group;
if group > max then max := group; if group > max then max := group;
end; end;
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i,NoSelected,ColNoSelected) then continue; if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue;
value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i]));
group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]))); group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])));
if group = min then if group = min then
begin begin
f1 := f1 + round(value1); f1 := f1 + round(value1);
@@ -307,8 +325,10 @@ begin
lReport.Add(' --------|-------|------'); lReport.Add(' --------|-------|------');
lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]); lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]);
lReport.Add(''); lReport.Add('');
lReport.Add('Confidence Level selected: %s', [CIntervalEdit.Text]); lReport.Add('Confidence Level selected: %9s', [CIntervalEdit.Text]);
lReport.Add('Proportion 1 = %.3f and Proportion 2 = %.3f with %d cases', [Prop1, Prop2, ncases1]); lReport.Add('Proportion 1: %9.3f', [Prop1]);
lReport.Add('Proportion 2: %9.3f', [Prop2]);
lReport.Add('Number of cases: %9d', [nCases1]);
lReport.Add('Difference in proportions: %9.3f', [PropDif]); lReport.Add('Difference in proportions: %9.3f', [PropDif]);
lReport.Add('Standard Error of Difference: %9.3f', [stderr]); lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
lReport.Add('z test statistic: %9.3f', [zStatistic]); lReport.Add('z test statistic: %9.3f', [zStatistic]);
@@ -323,14 +343,14 @@ begin
lReport.Add(''); lReport.Add('');
lReport.Add('Entered Values'); lReport.Add('Entered Values');
lReport.Add(''); lReport.Add('');
lReport.Add('Sample 1: Frequency = %5d for %5d cases.', [f1, ncases1]); lReport.Add('Sample 1: Frequency %5d for %5d cases.', [f1, ncases1]);
lReport.Add('Sample 2: Frequency = %5d for %5d cases.', [f2, ncases2]); lReport.Add('Sample 2: Frequency %5d for %5d cases.', [f2, ncases2]);
lReport.Add(''); lReport.Add('');
lReport.Add('Proportion 1: %9.3f', [Prop1]); lReport.Add('Proportion 1: %9.3f', [Prop1]);
lReport.Add('Proportion 2: %9.3f', [Prop2]); lReport.Add('Proportion 2: %9.3f', [Prop2]);
lReport.Add('Difference: %9.3f', [PropDif]); lReport.Add('Difference: %9.3f', [PropDif]);
lReport.Add('Standard Error of Difference: %9.3f', [stderr]); lReport.Add('Standard Error of Difference: %9.3f', [stderr]);
lReport.Add('Confidence Level selected: %-9s', [CIntervalEdit.Text]); lReport.Add('Confidence Level selected: %9s', [CIntervalEdit.Text]);
lReport.Add('z test statistic: %9.3f', [zStatistic]); lReport.Add('z test statistic: %9.3f', [zStatistic]);
lReport.Add(' with probability %9.4f', [zProbability]); lReport.Add(' with probability %9.4f', [zProbability]);
lReport.Add('z value for confidence interval: %9.3f', [ztest]); lReport.Add('z value for confidence interval: %9.3f', [ztest]);
@@ -370,9 +390,9 @@ begin
end; end;
procedure TTwoPropForm.RadioGroup1Click(Sender: TObject); procedure TTwoPropForm.DataSourceGroupClick(Sender: TObject);
begin begin
griddata := (RadioGroup1.ItemIndex = 1); griddata := (DataSourceGroup.ItemIndex = 1);
DepIndepGroupClick(nil); DepIndepGroupClick(nil);
end; end;
@@ -415,7 +435,7 @@ var
begin begin
inherited; inherited;
RadioGroup1.ItemIndex := 0; DataSourceGroup.ItemIndex := 0;
DepIndepGroup.ItemIndex := 0; DepIndepGroup.ItemIndex := 0;
VarList.Clear; VarList.Clear;
@@ -600,20 +620,20 @@ begin
begin begin
s := VarList.Items[index]; s := VarList.Items[index];
if Var1Edit.Text = '' then if Var1Edit.Text = '' then
Var1Edit.Text := s
else
begin begin
if independent then Var1Edit.Text := s;
begin VarList.Items.Delete(index);
if GrpEdit.Text = '' then
GrpEdit.Text := s;
end else end else
if independent and (GrpEdit.Text = '') then
begin
GrpEdit.Text := s;
VarList.Items.Delete(index);
end else
if (not independent) and (Var2Edit.Text = '') then
begin begin
if Var2Edit.Text = '' then
Var2Edit.Text := s; Var2Edit.Text := s;
VarList.Items.Delete(index);
end; end;
end;
UpdateBtnStates; UpdateBtnStates;
end; end;
end; end;

View File

@@ -1087,9 +1087,9 @@ end;
// Menu "Analysis" > "Comparisons" > "Difference Between Correlations" // Menu "Analysis" > "Comparisons" > "Difference Between Correlations"
procedure TOS3MainFrm.mnuAnalysisComp_CorrDiffClick(Sender: TObject); procedure TOS3MainFrm.mnuAnalysisComp_CorrDiffClick(Sender: TObject);
begin begin
if TwoCorrsFrm = nil then if TwoCorrsForm = nil then
Application.CreateForm(TTwoCorrsFrm, TwoCorrsFrm); Application.CreateForm(TTwoCorrsForm, TwoCorrsForm);
TwoCorrsFrm.ShowModal; TwoCorrsForm.Show;
end; end;
// Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis" // Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"