From 9953cfe29b556927bb583211bfafd73d894b8c66 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 4 Nov 2020 17:53:45 +0000 Subject: [PATCH] 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 --- applications/lazstats/source/LazStats.lpi | 2 +- .../analysis/comparisons/twocorrsunit.lfm | 1251 +++++++++-------- .../analysis/comparisons/twocorrsunit.pas | 682 +++++---- .../analysis/comparisons/twopropunit.lfm | 10 +- .../analysis/comparisons/twopropunit.pas | 112 +- .../lazstats/source/forms/mainunit.pas | 6 +- 6 files changed, 1153 insertions(+), 910 deletions(-) diff --git a/applications/lazstats/source/LazStats.lpi b/applications/lazstats/source/LazStats.lpi index 6fd8b17b3..62bd5cbe5 100644 --- a/applications/lazstats/source/LazStats.lpi +++ b/applications/lazstats/source/LazStats.lpi @@ -307,7 +307,7 @@ - + diff --git a/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.lfm b/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.lfm index 2285c1864..6ee448718 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.lfm +++ b/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.lfm @@ -1,636 +1,707 @@ -object TwoCorrsFrm: TTwoCorrsFrm - Left = 559 - Height = 391 - Top = 286 - Width = 462 +inherited TwoCorrsForm: TTwoCorrsForm + Left = 584 + Height = 460 + Top = 206 + Width = 823 HelpType = htKeyword HelpKeyword = 'html/DifferencebetweenCorrelations.htm' Caption = 'Comparison of Two Correlations' - ClientHeight = 391 - ClientWidth = 462 - OnActivate = FormActivate - OnCreate = FormCreate - OnShow = FormShow - Position = poMainFormCenter - LCLVersion = '2.1.0.0' - object Label14: TLabel - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = CInterval - AnchorSideTop.Side = asrCenter - Left = 8 - Height = 15 - Top = 323 - Width = 149 - BorderSpacing.Left = 8 - Caption = 'Percent Confidence Interval:' - ParentColor = False - end - object RadioGroup1: TRadioGroup - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Owner - Left = 8 - 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 - object RadioGroup2: TRadioGroup - AnchorSideLeft.Control = RadioGroup1 - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Owner - Left = 257 - Height = 72 - Top = 8 - Width = 185 - AutoFill = True - AutoSize = True - BorderSpacing.Left = 24 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - Caption = 'Test Assumptions:' - 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 = 181 - Items.Strings = ( - 'Independent Correlations.' - 'Dependent Correlations.' - ) - OnClick = RadioGroup2Click - TabOrder = 1 - end - object CInterval: TEdit - AnchorSideLeft.Control = Label14 - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Side = asrBottom - AnchorSideBottom.Control = Bevel2 - Left = 165 - Height = 23 - Top = 319 - Width = 36 - Alignment = taRightJustify - Anchors = [akLeft, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - TabOrder = 3 - Text = 'CInterval' - end - object ResetBtn: TButton - AnchorSideRight.Control = ComputeBtn - AnchorSideBottom.Control = Owner - 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 - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CInterval - Left = 8 - Height = 223 - Top = 88 - Width = 454 - PageIndex = 0 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Bottom = 8 - TabOrder = 2 - object Page1: TPage - object PanelPage1: TPanel - AnchorSideLeft.Control = Page1 - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = Page1 - Left = 143 - Height = 132 - Top = 0 - Width = 168 - AutoSize = True - BorderSpacing.Bottom = 24 - BevelOuter = bvNone - ClientHeight = 132 - ClientWidth = 168 - TabOrder = 0 - object firstcorlabel: TLabel - AnchorSideLeft.Control = PanelPage1 - AnchorSideTop.Control = rxy1 - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 20 - Width = 87 - Caption = 'First Correlation:' - ParentColor = False - end - object size1label: TLabel - AnchorSideLeft.Control = PanelPage1 - AnchorSideTop.Control = Size1 - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 51 - Width = 74 - Caption = 'Sample Size 1:' - ParentColor = False - end - object SecdCorLabel: TLabel - AnchorSideLeft.Control = PanelPage1 - AnchorSideTop.Control = rxy2 - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 82 - Width = 104 - Caption = 'Second Correlation:' - ParentColor = False - end - object Size2Label: TLabel - AnchorSideLeft.Control = PanelPage1 - AnchorSideTop.Control = Size2 - Left = 0 - Height = 15 - Top = 109 - Width = 74 - Caption = 'Sample Size 2:' - ParentColor = False - end - object rxy1: TEdit - AnchorSideLeft.Control = SecdCorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = PanelPage1 - Left = 112 - Height = 23 - Top = 16 - Width = 56 - Alignment = taRightJustify - BorderSpacing.Left = 8 - BorderSpacing.Top = 16 - TabOrder = 0 - Text = 'rxy1' - end - object Size1: TEdit - AnchorSideLeft.Control = SecdCorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = rxy1 - AnchorSideTop.Side = asrBottom - Left = 112 - Height = 23 - Top = 47 - Width = 56 - Alignment = taRightJustify - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - TabOrder = 1 - Text = 'Edit1' - end - object rxy2: TEdit - AnchorSideLeft.Control = SecdCorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Size1 - AnchorSideTop.Side = asrBottom - Left = 112 - Height = 23 - Top = 78 - Width = 56 - Alignment = taRightJustify - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - TabOrder = 2 - Text = 'Edit1' - end - object Size2: TEdit - AnchorSideLeft.Control = SecdCorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = rxy2 - AnchorSideTop.Side = asrBottom - Left = 112 - Height = 23 - Top = 109 - Width = 56 - Alignment = taRightJustify - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - TabOrder = 3 - Text = 'Edit1' - end - end + ClientHeight = 460 + ClientWidth = 823 + inherited ParamsPanel: TPanel + Height = 444 + Width = 392 + ClientHeight = 444 + ClientWidth = 392 + inherited CloseBtn: TButton + Left = 337 + Top = 419 + TabOrder = 7 end - object Page2: TPage - object PanelPage2: TPanel - AnchorSideLeft.Control = Page2 - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = Page2 - Left = 144 - Height = 156 - Top = 0 - Width = 167 - AutoSize = True - BevelOuter = bvNone - ClientHeight = 156 - ClientWidth = 167 - TabOrder = 0 - object corxylabel: TLabel - AnchorSideLeft.Control = PanelPage2 - AnchorSideTop.Control = rxy - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 20 - Width = 89 - Caption = 'Correlation r(x,y)' - ParentColor = False - end - object corxzlabel: TLabel - AnchorSideLeft.Control = PanelPage2 - AnchorSideTop.Control = rxz - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 51 - Width = 88 - Caption = 'Correlation r(x,z)' - ParentColor = False - end - object coryzlabel: TLabel - AnchorSideLeft.Control = PanelPage2 - AnchorSideTop.Control = ryz - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 82 - Width = 88 - Caption = 'Correlation r(y,z)' - ParentColor = False - end - object sampsizelabel: TLabel - AnchorSideLeft.Control = PanelPage2 - AnchorSideTop.Control = SampSize - AnchorSideTop.Side = asrCenter - Left = 0 - Height = 15 - Top = 113 - Width = 65 - Caption = 'Sample Size:' - ParentColor = False - end - object rxy: TEdit - AnchorSideLeft.Control = corxylabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = PanelPage2 - Left = 105 - Height = 23 - Top = 16 - Width = 62 - Alignment = taRightJustify - BorderSpacing.Left = 16 - BorderSpacing.Top = 16 - TabOrder = 0 - Text = 'rxy' - end - object SampSize: TEdit - AnchorSideLeft.Control = rxy - AnchorSideTop.Control = ryz - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = rxy - AnchorSideRight.Side = asrBottom - Left = 105 - Height = 23 - Top = 109 - Width = 62 - Alignment = taRightJustify - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 8 - BorderSpacing.Bottom = 24 - TabOrder = 3 - Text = 'Edit1' - end - object rxz: TEdit - AnchorSideLeft.Control = rxy - AnchorSideTop.Control = rxy - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = rxy - AnchorSideRight.Side = asrBottom - Left = 105 - Height = 23 - Top = 47 - Width = 62 - Alignment = taRightJustify - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 8 - TabOrder = 1 - Text = 'Edit1' - end - object ryz: TEdit - AnchorSideLeft.Control = rxy - AnchorSideTop.Control = rxz - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = rxy - AnchorSideRight.Side = asrBottom - Left = 105 - Height = 23 - Top = 78 - Width = 62 - Alignment = taRightJustify - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 8 - TabOrder = 2 - Text = 'Edit1' - end - end + inherited ComputeBtn: TButton + Left = 253 + Top = 419 + TabOrder = 6 end - object Page3: TPage - object PanelPage3: TPanel - Left = 0 - Height = 223 - Top = 0 - Width = 446 - Align = alClient - BorderSpacing.Right = 8 - BevelOuter = bvNone - ClientHeight = 223 - ClientWidth = 446 - TabOrder = 0 - object SelVarLabel: TLabel - AnchorSideLeft.Control = PanelPage3 - AnchorSideTop.Control = PanelPage3 - Left = 0 - Height = 15 - Top = 0 - Width = 83 - Caption = 'Select Variables:' - ParentColor = False - end - object VarList: TListBox - AnchorSideLeft.Control = PanelPage3 - AnchorSideTop.Control = SelVarLabel - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Panel1 - AnchorSideBottom.Control = PanelPage3 - AnchorSideBottom.Side = asrBottom - Left = 0 - Height = 206 - Top = 17 - Width = 246 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Top = 2 - ItemHeight = 0 - OnClick = VarListClick - TabOrder = 0 - end - object Bevel1: TBevel - AnchorSideLeft.Control = PanelPage3 + inherited ResetBtn: TButton + Left = 191 + Top = 419 + TabOrder = 5 + 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 + Top = 0 + Width = 185 + Anchors = [akTop, akRight] + AutoFill = True + AutoSize = True + Caption = 'Data Entered From:' + 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 = 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 = ( + 'Independent Correlations.' + 'Dependent Correlations.' + ) + OnClick = DepIndepGroupClick + TabOrder = 1 + end + 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.Side = asrBottom + AnchorSideTop.Side = asrBottom + AnchorSideBottom.Control = ButtonBevel + Left = 157 + Height = 23 + Top = 380 + Width = 48 + Alignment = taRightJustify + Anchors = [akLeft, akBottom] + BorderSpacing.Left = 8 + TabOrder = 3 + Text = 'CIntervalEdit' + end + object Notebook: TNotebook[9] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = DataSourceGroup + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = CIntervalEdit + Left = 0 + Height = 292 + Top = 80 + Width = 392 + PageIndex = 2 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 8 + BorderSpacing.Bottom = 8 + TabOrder = 2 + object Page1: TPage + object PanelPage1: TPanel + AnchorSideLeft.Control = Page1 AnchorSideLeft.Side = asrCenter - Left = 200 - Height = 13 - Top = 2 - Width = 46 - Shape = bsSpacer + AnchorSideTop.Control = Page1 + Left = 112 + Height = 132 + Top = 0 + Width = 168 + AutoSize = True + BorderSpacing.Bottom = 24 + BevelOuter = bvNone + ClientHeight = 132 + ClientWidth = 168 + TabOrder = 0 + object firstcorlabel: TLabel + AnchorSideLeft.Control = PanelPage1 + AnchorSideTop.Control = Corr1Edit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 20 + Width = 87 + Caption = 'First Correlation:' + ParentColor = False + end + object size1label: TLabel + AnchorSideLeft.Control = PanelPage1 + AnchorSideTop.Control = SampleSize1Edit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 51 + Width = 90 + Caption = 'First Sample Size:' + ParentColor = False + end + object SecdCorLabel: TLabel + AnchorSideLeft.Control = PanelPage1 + AnchorSideTop.Control = Corr2Edit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 82 + Width = 104 + Caption = 'Second Correlation:' + ParentColor = False + end + object Size2Label: TLabel + AnchorSideLeft.Control = PanelPage1 + AnchorSideTop.Control = Size2Edit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 113 + Width = 107 + Caption = 'Second Sample Size:' + ParentColor = False + end + object Corr1Edit: TEdit + AnchorSideLeft.Control = SecdCorLabel + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PanelPage1 + Left = 112 + Height = 23 + Top = 16 + Width = 56 + Alignment = taRightJustify + BorderSpacing.Left = 8 + BorderSpacing.Top = 16 + TabOrder = 0 + Text = 'Corr1Edit' + end + object SampleSize1Edit: TEdit + AnchorSideLeft.Control = SecdCorLabel + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Corr1Edit + AnchorSideTop.Side = asrBottom + Left = 112 + Height = 23 + Top = 47 + Width = 56 + Alignment = taRightJustify + BorderSpacing.Left = 8 + BorderSpacing.Top = 8 + TabOrder = 1 + Text = 'SampleSize1Edit' + end + object Corr2Edit: TEdit + AnchorSideLeft.Control = SecdCorLabel + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = SampleSize1Edit + AnchorSideTop.Side = asrBottom + Left = 112 + Height = 23 + Top = 78 + Width = 56 + Alignment = taRightJustify + BorderSpacing.Left = 8 + BorderSpacing.Top = 8 + TabOrder = 2 + Text = 'Corr2Edit' + end + object Size2Edit: TEdit + AnchorSideLeft.Control = SecdCorLabel + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Corr2Edit + AnchorSideTop.Side = asrBottom + Left = 112 + Height = 23 + Top = 109 + Width = 56 + Alignment = taRightJustify + BorderSpacing.Left = 8 + BorderSpacing.Top = 8 + TabOrder = 3 + Text = 'Size2Edit' + end end - object Panel1: TPanel - AnchorSideLeft.Control = Bevel1 - AnchorSideLeft.Side = asrBottom - AnchorSideRight.Control = PanelPage3 - AnchorSideRight.Side = asrBottom - Left = 246 - Height = 116 - Top = 32 - Width = 162 + end + object Page2: TPage + object PanelPage2: TPanel + AnchorSideLeft.Control = Page2 + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = Page2 + Left = 113 + Height = 156 + Top = 0 + Width = 167 AutoSize = True BevelOuter = bvNone - ClientHeight = 116 - ClientWidth = 162 - TabOrder = 1 - object xlabel: TLabel - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = Xvar + ClientHeight = 156 + ClientWidth = 167 + TabOrder = 0 + object corxylabel: TLabel + AnchorSideLeft.Control = PanelPage2 + AnchorSideTop.Control = CorrXYEdit AnchorSideTop.Side = asrCenter - Left = 48 + Left = 0 Height = 15 - Top = 4 - Width = 18 - Alignment = taRightJustify - BorderSpacing.Left = 48 - Caption = 'X =' + Top = 20 + Width = 89 + Caption = 'Correlation r(x,y)' ParentColor = False end - object Xvar: TEdit - AnchorSideLeft.Control = xlabel + object corxzlabel: TLabel + AnchorSideLeft.Control = PanelPage2 + AnchorSideTop.Control = CorrXZEdit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 51 + Width = 88 + Caption = 'Correlation r(x,z)' + ParentColor = False + end + object coryzlabel: TLabel + AnchorSideLeft.Control = PanelPage2 + AnchorSideTop.Control = CorrYZEdit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 82 + Width = 88 + Caption = 'Correlation r(y,z)' + ParentColor = False + end + object SampleSizeLabel: TLabel + AnchorSideLeft.Control = PanelPage2 + AnchorSideTop.Control = SampleSizeEdit + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 113 + Width = 65 + Caption = 'Sample Size:' + ParentColor = False + end + object CorrXYEdit: TEdit + AnchorSideLeft.Control = corxylabel AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Panel1 - Left = 74 + AnchorSideTop.Control = PanelPage2 + Left = 105 Height = 23 - Top = 0 - Width = 88 - BorderSpacing.Left = 8 - ReadOnly = True + Top = 16 + Width = 62 + Alignment = taRightJustify + BorderSpacing.Left = 16 + BorderSpacing.Top = 16 TabOrder = 0 - Text = 'Xvar' + Text = 'CorrXYEdit' 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 + object SampleSizeEdit: TEdit + AnchorSideLeft.Control = CorrXYEdit + AnchorSideTop.Control = CorrYZEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Xvar + AnchorSideRight.Control = CorrXYEdit AnchorSideRight.Side = asrBottom - Left = 74 + Left = 105 Height = 23 - Top = 31 - Width = 88 + Top = 109 + Width = 62 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 + BorderSpacing.Bottom = 24 + TabOrder = 3 + Text = 'SampleSizeEdit' + end + object CorrXZEdit: TEdit + AnchorSideLeft.Control = CorrXYEdit + AnchorSideTop.Control = CorrXYEdit + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = CorrXYEdit + AnchorSideRight.Side = asrBottom + Left = 105 + Height = 23 + Top = 47 + Width = 62 + Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 8 - ReadOnly = True TabOrder = 1 - Text = 'Edit1' + Text = 'CorrXZEdit' 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 + object CorrYZEdit: TEdit + AnchorSideLeft.Control = CorrXYEdit + AnchorSideTop.Control = CorrXZEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Xvar + AnchorSideRight.Control = CorrXYEdit AnchorSideRight.Side = asrBottom - Left = 74 + Left = 105 Height = 23 - Top = 62 - Width = 88 + Top = 78 + Width = 62 + Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 8 - ReadOnly = True TabOrder = 2 - Text = 'Edit1' + Text = 'CorrXZEdit' end - object GroupLabel: TLabel - AnchorSideTop.Control = GroupVar - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = xlabel - AnchorSideRight.Side = asrBottom - Left = 22 + end + end + object Page3: TPage + object PanelPage3: TPanel + Left = 0 + Height = 292 + Top = 0 + Width = 384 + Align = alClient + BorderSpacing.Right = 8 + BevelOuter = bvNone + ClientHeight = 292 + ClientWidth = 384 + TabOrder = 0 + object SelVarLabel: TLabel + AnchorSideLeft.Control = PanelPage3 + AnchorSideTop.Control = PanelPage3 + Left = 0 Height = 15 - Top = 97 - Width = 44 - Alignment = taRightJustify - Anchors = [akTop, akRight] - BorderSpacing.Left = 8 - Caption = 'Group =' + Top = 0 + Width = 83 + Caption = 'Select Variables:' ParentColor = False end - object GroupVar: TEdit - AnchorSideLeft.Control = Xvar - AnchorSideTop.Control = Zvar + object VarList: TListBox + AnchorSideLeft.Control = PanelPage3 + AnchorSideTop.Control = SelVarLabel AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Xvar + AnchorSideRight.Control = Var1In + AnchorSideBottom.Control = PanelPage3 + AnchorSideBottom.Side = asrBottom + Left = 0 + Height = 275 + Top = 17 + Width = 173 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 2 + BorderSpacing.Right = 6 + ItemHeight = 0 + OnDblClick = VarListDblClick + OnSelectionChange = VarListSelectionChange + TabOrder = 0 + end + object Bevel1: TBevel + AnchorSideLeft.Control = PanelPage3 + AnchorSideLeft.Side = asrCenter + Left = 169 + Height = 13 + Top = 2 + Width = 46 + Shape = bsSpacer + end + object Var1In: TBitBtn + 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 + AnchorSideRight.Control = PanelPage3 AnchorSideRight.Side = asrBottom - Left = 74 + AnchorSideBottom.Control = Var1Out + AnchorSideBottom.Side = asrBottom + Left = 213 Height = 23 - Top = 93 - Width = 88 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 8 + Top = 42 + Width = 171 + Anchors = [akLeft, akRight, akBottom] + BorderSpacing.Left = 8 + BorderSpacing.Bottom = 8 ReadOnly = True TabOrder = 3 - Text = 'Edit1' + Text = 'XVarEdit' + 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 + 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 + object YVarLabel: TLabel + AnchorSideLeft.Control = YVarEdit + AnchorSideTop.Side = asrCenter + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = YVarEdit + Left = 213 + Height = 15 + Top = 97 + 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] + 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 - object Bevel2: TBevel - AnchorSideLeft.Control = Owner - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = ReturnBtn - Left = 0 - Height = 8 - Top = 342 - Width = 462 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine + inherited ParamsSplitter: TSplitter + Left = 404 + Height = 460 end end diff --git a/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas b/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas index 044b4cd1c..ade862370 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/twocorrsunit.pas @@ -5,198 +5,181 @@ unit TwoCorrsUnit; interface uses - Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, - ExtCtrls, StdCtrls, - MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit; + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, + ExtCtrls, StdCtrls, Buttons, + MainUnit, Globals, FunctionsLib, DataProcs, BasicStatsReportFormUnit; type - { TTwoCorrsFrm } + { TTwoCorrsForm } - TTwoCorrsFrm = class(TForm) + TTwoCorrsForm = class(TBasicStatsReportForm) Bevel1: TBevel; - Bevel2: TBevel; - HelpBtn: TButton; - Notebook1: TNotebook; + Bevel5: TBevel; + Notebook: TNotebook; Page1: TPage; Page2: TPage; Page3: TPage; - Panel1: TPanel; PanelPage1: TPanel; - ResetBtn: TButton; - ComputeBtn: TButton; - ReturnBtn: TButton; - CInterval: TEdit; + CIntervalEdit: TEdit; Label14: TLabel; - Xvar: TEdit; - Yvar: TEdit; - Zvar: TEdit; - GroupVar: TEdit; - xlabel: TLabel; - ylabel: TLabel; - zlabel: TLabel; - GroupLabel: TLabel; + Var1In: TBitBtn; + Var2In: TBitBtn; + Var1Out: TBitBtn; + Var3In: TBitBtn; + Var2Out: TBitBtn; + GrpIn: TBitBtn; + Var3Out: TBitBtn; + GrpOut: TBitBtn; + XVarEdit: TEdit; + YVarEdit: TEdit; + ZVarEdit: TEdit; + GroupVarEdit: TEdit; + XVarLabel: TLabel; + YVarLabel: TLabel; + ZVarLabel: TLabel; + GroupVarLabel: TLabel; SelVarLabel: TLabel; VarList: TListBox; PanelPage3: TPanel; - rxy1: TEdit; - Size1: TEdit; - rxy2: TEdit; - Size2: TEdit; + Corr1Edit: TEdit; + SampleSize1Edit: TEdit; + Corr2Edit: TEdit; + Size2Edit: TEdit; firstcorlabel: TLabel; size1label: TLabel; SecdCorLabel: TLabel; Size2Label: TLabel; - rxy: TEdit; - rxz: TEdit; - ryz: TEdit; - SampSize: TEdit; + CorrXYEdit: TEdit; + CorrXZEdit: TEdit; + CorrYZEdit: TEdit; + SampleSizeEdit: TEdit; corxylabel: TLabel; corxzlabel: TLabel; coryzlabel: TLabel; - sampsizelabel: TLabel; + SampleSizeLabel: TLabel; PanelPage2: TPanel; - RadioGroup1: TRadioGroup; - RadioGroup2: TRadioGroup; - procedure ComputeBtnClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormShow(Sender: TObject); - procedure HelpBtnClick(Sender: TObject); - procedure RadioGroup1Click(Sender: TObject); - procedure RadioGroup2Click(Sender: TObject); - procedure ResetBtnClick(Sender: TObject); - procedure VarListClick(Sender: TObject); + DataSourceGroup: TRadioGroup; + DepIndepGroup: TRadioGroup; + procedure DataSourceGroupClick(Sender: TObject); + procedure DepIndepGroupClick(Sender: TObject); + procedure GrpInClick(Sender: TObject); + procedure GrpOutClick(Sender: TObject); + procedure Var1InClick(Sender: TObject); + procedure Var1OutClick(Sender: TObject); + procedure Var2InClick(Sender: TObject); + procedure Var2OutClick(Sender: TObject); + procedure Var3InClick(Sender: TObject); + procedure Var3OutClick(Sender: TObject); + procedure VarListDblClick(Sender: TObject); + procedure VarListSelectionChange(Sender: TObject; User: boolean); + private - { private declarations } - FAutoSized: Boolean; independent: 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 declarations } + constructor Create(AOwner: TComponent); override; + procedure Reset; override; + end; var - TwoCorrsFrm: TTwoCorrsFrm; + TwoCorrsForm: TTwoCorrsForm; + implementation +{$R *.lfm} + uses - Math, MathUnit; + Math, + MathUnit, GridProcs; -{ TTwoCorrsFrm } -procedure TTwoCorrsFrm.ResetBtnClick(Sender: TObject); -var - i: integer; +{ TTwoCorrsForm } + +constructor TTwoCorrsForm.Create(AOwner: TComponent); begin - CInterval.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]); + inherited; + CIntervalEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT); 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 - 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); + +procedure TTwoCorrsForm.AdjustConstraints; var w: Integer; begin - if FAutoSized then - exit; + inherited; - w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]); - HelpBtn.Constraints.MinWidth := w; - ResetBtn.Constraints.MinWidth := w; - ComputeBtn.Constraints.MinWidth := w; - ReturnBtn.Constraints.MinWidth := w; - - Width := Max( - RadioGroup2.Left + RadioGroup2.Width + RadioGroup2.BorderSpacing.Right, - Width - HelpBtn.Left + HelpBtn.BorderSpacing.Left + w := Max(DataSourceGroup.Width, DepIndepGroup.Width); + DataSourceGroup.Constraints.MinWidth := w; + DepIndepGroup.Constraints.MinWidth := w; + ParamsPanel.Constraints.MinWidth := Max( + CloseBtn.Width * 4 + CloseBtn.BorderSpacing.Left * 3, + w * 2 + DepIndepGroup.BorderSpacing.Left ); - Constraints.MinWidth := Width; - Constraints.MinHeight := Height; - - FAutoSized := true; + ParamsPanel.Constraints.MinHeight := DataSourceGroup.Height + + NoteBook.BorderSpacing.Top + Var3Out.Top + Var3Out.Height + + NoteBook.BorderSpacing.Bottom + CIntervalEdit.Height + + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; end; -procedure TTwoCorrsFrm.FormCreate(Sender: TObject); + +procedure TTwoCorrsForm.Reset; +var + i: integer; 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; -procedure TTwoCorrsFrm.FormShow(Sender: TObject); -begin - ResetBtnClick(self); -end; -procedure TTwoCorrsFrm.HelpBtnClick(Sender: TObject); -begin - if ContextHelpForm = nil then - Application.CreateForm(TContextHelpForm, ContextHelpForm); - ContextHelpForm.HelpMessage((Sender as TButton).tag); -end; - -procedure TTwoCorrsFrm.ComputeBtnClick(Sender: TObject); +procedure TTwoCorrsForm.Compute; var lReport: TStrings; Corxy, Corxz, Coryz, Cor1, Cor2, alpha, tvalue, df2: double; @@ -206,21 +189,11 @@ var stddev1, stddev2, stddev3, value1, value2, value3: double; meanx1, meanx2, meany1, meany2, varx1, varx2, vary1, vary2: 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; cellstring: string; - msg: String; - C: TWinControl; ColNoSelected: IntDyneVec = nil; begin - if not Validate(msg, C) then - begin - C.SetFocus; - MessageDlg(msg, mtError, [mbOK], 0); - ModalResult := mrNone; - exit; - end; - SetLength(ColNoSelected, NoVariables); Corxy := 0.0; Corxz := 0.0; @@ -236,7 +209,7 @@ begin meanx1 := 0.0; meanx2 := 0.0; meany1 := 0.0; - ConfLevel := StrToFloat(CInterval.Text) / 100.0; + ConfLevel := StrToFloat(CIntervalEdit.Text) / 100.0; // *** USE DATA ON THE FORM *** if not griddata then @@ -244,10 +217,10 @@ begin // read data from form and obtain results if independent then begin - Cor1 := StrToFloat(rxy1.Text); - Cor2 := StrToFloat(rxy2.Text); - SSize1 := StrToInt(Size1.Text); - SSize2 := StrToInt(Size2.Text); + Cor1 := StrToFloat(Corr1Edit.Text); + Cor2 := StrToFloat(Corr2Edit.Text); + SSize1 := StrToInt(SampleSize1Edit.Text); + SSize2 := StrToInt(Size2Edit.Text); CorDif := Cor1 - Cor2; zOne := 0.5 * ln((1.0 + Cor1) / (1.0 - Cor1)); zTwo := 0.5 * ln((1.0 + Cor2) / (1.0 - Cor2)); @@ -266,10 +239,10 @@ begin // obtain data from form and obtain results if not independent then begin - Corxy := StrToFloat(rxy.Text); - Corxz := StrToFloat(rxz.Text); - Coryz := StrToFloat(ryz.Text); - SSize := StrToInt(SampSize.Text); + Corxy := StrToFloat(CorrXYEdit.Text); + Corxz := StrToFloat(CorrXZEdit.Text); + Coryz := StrToFloat(CorrYZEdit.Text); + SSize := StrToInt(SampleSizeEdit.Text); CorDif := Corxy - Corxz; 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)); @@ -279,26 +252,33 @@ begin end; end; + // *** USE DATA FROM THE GRID *** if griddata then begin - v1 := 1; - v2 := 1; - grp := 1; + //v1 := 1; + //v2 := 1; + //grp := 1; // read grid data for independent r's if independent then 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 begin cellstring := OS3MainFrm.DataGrid.Cells[i,0]; - if cellstring = Xvar.Text then v1 := i; - if cellstring = Yvar.Text then v2 := i; - if cellstring = GroupVar.Text then grp := i; + if cellstring = XVarEdit.Text then v1 := i; + if cellstring = YVarEdit.Text then v2 := i; + if cellstring = GroupVarEdit.Text then grp := i; end; ColNoSelected[0] := v1; ColNoSelected[1] := v2; ColNoSelected[2] := grp; NoSelected := 3; + *) meanx1 := 0.0; meany1 := 0.0; varx1 := 0.0; @@ -311,26 +291,26 @@ begin Cor2 := 0.0; ncases1 := 0; ncases2 := 0; - min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,1]))); - max := min; - for i := 2 to NoCases do + min := MaxInt; + max := -min; + for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]))); if grpval > max then max := grpval; if grpval < min then min := grpval; end; for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[grp,i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + grpval := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]))); if grpval = min then begin ncases1 := ncases1 + 1; - value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); + value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); meanx1 := meanx1 + 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; vary1 := vary1 + value2 * value2; Cor1 := Cor1 + value1 * value2; @@ -338,10 +318,10 @@ begin if grpval = max then begin ncases2 := ncases2 + 1; - value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); + value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); meanx2 := meanx2 + 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; vary2 := vary2 + value2 * value2; Cor2 := Cor2 + value1 * value2; @@ -399,24 +379,17 @@ begin Corxz := 0.0; Coryz := 0.0; ncases := 0; - for i := 1 to NoVariables do - begin - cellstring := OS3MainFrm.DataGrid.Cells[i,0]; - if cellstring = Xvar.Text then v1 := i; - 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; + SetLength(ColNoSelected, 3); + ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, XVarEdit.Text); + ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, YVarEdit.Text); + ColNoSelected[2] := GetVariableIndex(OS3MainFrm.DataGrid, ZVarEdit.Text); for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; ncases := ncases + 1; - value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); - value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); - value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v3,i])); + value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); + value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])); + value3 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i])); mean1 := mean1 + value1; mean2 := mean2 + value2; mean3 := mean3 + value3; @@ -428,22 +401,22 @@ begin Coryz := Coryz + value2 * value3; end; variance1 := variance1 - mean1 * mean1 / ncases; - variance1 := variance1 / (ncases - 1.0); + variance1 := variance1 / (ncases - 1); stddev1 := sqrt(variance1); variance2 := variance2 - mean2 * mean2 / ncases; - variance2 := variance2 / (ncases - 1.0); + variance2 := variance2 / (ncases - 1); stddev2 := sqrt(variance2); variance3 := variance3 - mean3 * mean3 / ncases; - variance3 := variance3 / (ncases - 1.0); + variance3 := variance3 / (ncases - 1); stddev3 := sqrt(variance3); Corxy := Corxy - mean1 * mean2 / ncases; - Corxy := Corxy / (ncases - 1.0); + Corxy := Corxy / (ncases - 1); Corxy := Corxy / (stddev1 * stddev2); Corxz := Corxz - mean1 * mean3 / ncases; - Corxz := Corxz / (ncases - 1.0); + Corxz := Corxz / (ncases - 1); Corxz := Corxz / (stddev1 * stddev3); Coryz := Coryz - mean2 * mean3 / ncases; - Coryz := Coryz / (ncases - 1.0); + Coryz := Coryz / (ncases - 1); Coryz := Coryz / (stddev2 * stddev3); mean1 := mean1 / ncases; mean2 := mean2 / ncases; @@ -467,11 +440,11 @@ begin if independent then begin lReport.Add('Correlation one: %6.3f', [Cor1]); - lReport.Add('Sample size one: %6d', [SSize1]); + lReport.Add('Sample size one: %6d', [SSize1]); 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('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 Two: %6.3f', [zTwo]); lReport.Add('z difference: %6.3f', [zDif]); @@ -480,7 +453,7 @@ begin lReport.Add('Probability > |z|: %6.3f', [zprobability]); lReport.Add('z Required for significance: %6.3f', [zTest]); 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(''); if griddata then begin @@ -488,7 +461,7 @@ begin 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 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('Std.Dev. Y for group 1: %9.3f', [sdy1]); lReport.Add('Std.Dev. Y for group 2: %9.3f', [sdy2]); @@ -500,8 +473,8 @@ begin lReport.Add('Correlation x with y: %6.3f', [Corxy]); lReport.Add('Correlation x with z: %6.3f', [Corxz]); lReport.Add('Correlation y with z: %6.3f', [Coryz]); - lReport.Add('Sample size: %6d', [SSize]); - lReport.Add('Confidence Level Selected: %6s', [CInterval.Text]); + lReport.Add('Sample size: %6d', [SSize]); + lReport.Add('Confidence Level Selected: %6s', [CIntervalEdit.Text]); lReport.Add('Difference r(x,y) - r(x,z): %6.3f', [CorDif]); lReport.Add('t test statistic: %6.3f', [tvalue]); lReport.Add('Probability > |t|: %6.3f', [tprobability]); @@ -509,83 +482,114 @@ begin lReport.Add(''); if griddata then begin - lReport.Add('Variable Mean Variance Std.Dev.'); - lReport.Add(' X %9.3f %9.3f %9.3f', [mean1, variance1, stddev1]); - lReport.Add(' Y %9.3f %9.3f %9.3f', [mean2, variance2, stddev2]); - lReport.Add(' Z %9.3f %9.3f %9.3f', [mean3, variance3, stddev3]); + lReport.Add('Variable Mean Variance Std.Dev. '); + lReport.Add('-------- ---------- ---------- ----------'); + lReport.Add(' X %10.3f %10.3f %10.3f', [mean1, variance1, stddev1]); + 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; - DisplayReport(lReport); + FReportFrame.DisplayReport(lReport); finally lReport.Free; - ColNoSelected := nil; end; end; -procedure TTwoCorrsFrm.RadioGroup1Click(Sender: TObject); + +procedure TTwoCorrsForm.DataSourceGroupClick(Sender: TObject); var index: integer; begin - index := RadioGroup1.ItemIndex; + index := DataSourceGroup.ItemIndex; if index = 0 then begin griddata := false; if independent then - Notebook1.PageIndex := 0 + Notebook.PageIndex := 0 else - Notebook1.PageIndex := 1; + Notebook.PageIndex := 1; end else begin griddata := true; - Notebook1.PageIndex := 2; + Notebook.PageIndex := 2; end; end; -procedure TTwoCorrsFrm.RadioGroup2Click(Sender: TObject); + +procedure TTwoCorrsForm.DepIndepGroupClick(Sender: TObject); var index1, index2: integer; begin - index1 := RadioGroup1.ItemIndex; - index2 := RadioGroup2.ItemIndex; + index1 := DataSourceGroup.ItemIndex; + index2 := DepIndepGroup.ItemIndex; // form input with independent corrs if ((index2 = 0) and (index1 = 0)) then begin independent := true; - Notebook1.PageIndex := 0; + Notebook.PageIndex := 0; end; // grid data for independent corrs if ((index2 = 0) and (index1 = 1)) then begin - Notebook1.PageIndex := 2; - zlabel.Visible := false; - zvar.Visible := false; - grouplabel.Visible := true; - groupvar.Visible := true; + Notebook.PageIndex := 2; +// ZVarLabel.Visible := false; + ZVarEdit.Visible := false; +// GroupVarLabel.Visible := true; +// GroupVarEdit.Visible := true; end; // form data for dependent corrs if ((index2 = 1) and (index1 = 0)) then begin - Notebook1.PageIndex := 1; + Notebook.PageIndex := 1; end; // grid data for dependent corrs if ((index2 = 1) and (index1 = 1)) then begin - Notebook1.PageIndex := 2; + Notebook.PageIndex := 2; independent := false; - zlabel.Visible := true; - Zvar.Visible := true; - GroupLabel.Visible := false; - GroupVar.Visible := false; +// ZVarLabel.Visible := true; + ZVarEdit.Visible := true; +// GroupVarLabel.Visible := false; +// GroupVarEdit.Visible := false; end; + +// 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; -function TTwoCorrsFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; + +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 n: Integer; x: Double; @@ -593,75 +597,75 @@ begin Result := false; AControl := nil; AMsg := ''; - if Notebook1.PageIndex = 0 then + if Notebook.PageIndex = 0 then begin - if (rxy1.Text = '') or not TryStrToFloat(rxy1.Text, x) then + if (Corr1Edit.Text = '') or not TryStrToFloat(Corr1Edit.Text, x) then begin - AControl := rxy1; + AControl := Corr1Edit; AMsg := 'Invalid input for first correlation'; exit; 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 - AControl := Size1; + AControl := SampleSize1Edit; AMsg := 'Invald input for size of sample 1'; exit; end; - if (rxy2.Text = '') or not TryStrToFloat(rxy2.Text, x) then + if (Corr2Edit.Text = '') or not TryStrToFloat(Corr2Edit.Text, x) then begin - AControl := rxy2; + AControl := Corr2Edit; AMsg := 'Invalid input for second correlation'; exit; 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 - AControl := Size2; + AControl := Size2Edit; AMsg := 'Invalud input for size of sample 2'; exit; end; end else - if Notebook1.PageIndex = 1 then + if Notebook.PageIndex = 1 then begin - if (rxy.Text = '') or not TryStrToFloat(rxy.Text, x) then - AControl := rxy + if (CorrXYEdit.Text = '') or not TryStrToFloat(CorrXYEdit.Text, x) then + AControl := CorrXYEdit else - if (rxz.Text = '') or not TryStrToFloat(rxz.Text, x) then - AControl := rxz + if (CorrXZEdit.Text = '') or not TryStrToFloat(CorrXZEdit.Text, x) then + AControl := CorrXZEdit else - if (ryz.Text = '') or not TryStrToFloat(ryz.Text, x) then - AControl := ryz + if (CorrYZEdit.Text = '') or not TryStrToFloat(CorrYZEdit.Text, x) then + AControl := CorrYZEdit else - if (SampSize.Text = '') or not TryStrToInt(SampSize.Text, n) or (n < 0) then - AControl := SampSize; + if (SampleSizeEdit.Text = '') or not TryStrToInt(SampleSizeEdit.Text, n) or (n < 0) then + AControl := SampleSizeEdit; if AControl <> nil then begin AMsg := 'Invalid input.'; exit; end; end else - if Notebook1.PageIndex = 2 then + if Notebook.PageIndex = 2 then begin - if XVar.Text = '' then + if XVarEdit.Text = '' then begin - AControl := XVar; + AControl := XVarEdit; AMsg := 'X variable not specified.'; exit; end; - if YVar.Text = '' then + if YVarEdit.Text = '' then begin - AControl := YVar; + AControl := YVarEdit; AMsg := 'Y variable not specified.'; exit; end; - case RadioGroup2.ItemIndex of - 0: if (GroupVar.Text = '') then + case DepIndepGroup.ItemIndex of + 0: if (GroupVarEdit.Text = '') then begin - AControl := GroupVar; + AControl := GroupVarEdit; AMsg := 'Group variable not specified'; exit; end; - 1: if (ZVar.Text = '') then begin - AControl := ZVar; + 1: if (ZVarEdit.Text = '') then begin + AControl := ZVarEdit; AMsg := 'Z variable not specified.'; exit; end; @@ -670,8 +674,156 @@ begin Result := true; 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. diff --git a/applications/lazstats/source/forms/analysis/comparisons/twopropunit.lfm b/applications/lazstats/source/forms/analysis/comparisons/twopropunit.lfm index c2863ebc4..ebed2e804 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/twopropunit.lfm +++ b/applications/lazstats/source/forms/analysis/comparisons/twopropunit.lfm @@ -36,7 +36,7 @@ inherited TwoPropForm: TTwoPropForm end object Notebook: TNotebook[5] AnchorSideLeft.Control = ParamsPanel - AnchorSideTop.Control = RadioGroup1 + AnchorSideTop.Control = DataSourceGroup AnchorSideTop.Side = asrBottom AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom @@ -60,8 +60,8 @@ inherited TwoPropForm: TTwoPropForm Left = 0 Height = 15 Top = 0 - Width = 83 - Caption = 'Select Variables:' + Width = 97 + Caption = 'Available Variables' ParentColor = False end object Var1Label: TLabel @@ -523,7 +523,7 @@ inherited TwoPropForm: TTwoPropForm TabOrder = 5 Text = '95.0' end - object RadioGroup1: TRadioGroup[8] + object DataSourceGroup: TRadioGroup[8] AnchorSideTop.Control = ParamsPanel AnchorSideRight.Control = Bevel5 Left = -3 @@ -549,7 +549,7 @@ inherited TwoPropForm: TTwoPropForm 'Values Entered on this Form' 'Values in the Data Grid' ) - OnClick = RadioGroup1Click + OnClick = DataSourceGroupClick TabOrder = 6 end object DepIndepGroup: TRadioGroup[9] diff --git a/applications/lazstats/source/forms/analysis/comparisons/twopropunit.pas b/applications/lazstats/source/forms/analysis/comparisons/twopropunit.pas index 5b2e70746..70b110f2d 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/twopropunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/twopropunit.pas @@ -58,11 +58,11 @@ type Samp20Label: TLabel; GrpOut: TBitBtn; VarList: TListBox; - RadioGroup1: TRadioGroup; + DataSourceGroup: TRadioGroup; DepIndepGroup: TRadioGroup; procedure GrpInClick(Sender: TObject); procedure GrpOutClick(Sender: TObject); - procedure RadioGroup1Click(Sender: TObject); + procedure DataSourceGroupClick(Sender: TObject); procedure DepIndepGroupClick(Sender: TObject); procedure Var1InClick(Sender: TObject); procedure Var1OutClick(Sender: TObject); @@ -94,7 +94,8 @@ implementation {$R *.lfm} uses - Math; + Math, + GridProcs; { TTwoPropForm } @@ -107,13 +108,20 @@ end; procedure TTwoPropForm.AdjustConstraints; +var + w: Integer; begin inherited; + + w := Max(DataSourceGroup.Width, DepIndepGroup.Width); + DataSourceGroup.Constraints.MinWidth := w; + DepIndepGroup.Constraints.MinWidth := w; ParamsPanel.Constraints.MinWidth := Max( 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 + CloseBtn.BorderSpacing.Top + CloseBtn.Height; end; @@ -124,7 +132,8 @@ var ConfInt, Prop1, Prop2, zstatistic, zprobability: double; PropDif, stderr, UCL, LCL, value1, value2, ztest: 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; ColNoSelected: IntDyneVec = nil; lReport: TStrings; @@ -132,12 +141,12 @@ begin // Initialize output form stderr := 0.0; PropDif := 0.0; - v2 := 0; +// v2 := 0; ztest := 0.0; Prop1 := 0.0; Prop2 := 0.0; - NoSelected := 0; - v1 := 0; +// NoSelected := 0; +// v1 := 0; zstatistic := 0.0; zprobability := 0.0; UCL := 0.0; @@ -147,6 +156,7 @@ begin ConfInt := (100.0 - StrToFloat(CIntervalEdit.Text)) / 2.0 ; ConfInt := (100.0 - ConfInt) / 100.0; // one tail + ncases1 := 0; ncases2 := 0; f1 := 0; @@ -158,6 +168,10 @@ begin if griddata then // data read from grid begin + SetLength(ColNoSelected, 2); + ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, Var1Edit.Text); + ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Var2Edit.Text); + { for i := 1 to NoVariables do begin if Var1Edit.Text = OS3MainFrm.DataGrid.Cells[i,0] then @@ -172,30 +186,34 @@ begin ColNoSelected[1] := i; end; end; // next variable + } + f1 := 0; + f2 := 0; + nCases1 := 0; if not independent then // correlated data begin for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - ncases1 := ncases1 + 1; - value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); - value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i])); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + nCases1 := nCases1 + 1; + value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); + value2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i])); f1 := f1 + round(value1); f2 := f2 + round(value2); end; // next case - f3 := ncases1 - f1; - f4 := ncases1 - f2; + f3 := nCases1 - f1; + f4 := nCases1 - f2; AB := f1 + f2; AC := f1 + f3; CD := f3 + f4; BD := f2 + f4; - Prop1 := BD / ncases1; - Prop2 := AB / ncases1; - stderr := sqrt((f1 / ncases1 + f4 / ncases1) / ncases1); + Prop1 := BD / nCases1; + Prop2 := AB / nCases1; + stderr := sqrt((f1 / nCases1 + f4 / nCases1) / nCases1); PropDif := Prop1 - Prop2; zstatistic := PropDif / stderr; - ztest := inversez(ConfInt); + ztest := InverseZ(ConfInt); zprobability := 1.0 - ProbZ(abs(zstatistic)); UCL := PropDif + stderr * ztest; LCL := PropDif - stderr * ztest; @@ -203,21 +221,21 @@ begin if independent then begin - min := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,1]))); + min := MaxInt; max := min; - for i := 2 to NoCases do + for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); if group < min then min := group; if group > max then max := group; end; for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v1,i])); - group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[v2,i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + value1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); + group := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); if group = min then begin f1 := f1 + round(value1); @@ -307,8 +325,10 @@ begin lReport.Add(' --------|-------|------'); lReport.Add(' sum | %5d %5d %5d |', [AC, BD, ncases1]); lReport.Add(''); - lReport.Add('Confidence Level selected: %s', [CIntervalEdit.Text]); - lReport.Add('Proportion 1 = %.3f and Proportion 2 = %.3f with %d cases', [Prop1, Prop2, ncases1]); + lReport.Add('Confidence Level selected: %9s', [CIntervalEdit.Text]); + 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('Standard Error of Difference: %9.3f', [stderr]); lReport.Add('z test statistic: %9.3f', [zStatistic]); @@ -323,14 +343,14 @@ begin lReport.Add(''); lReport.Add('Entered Values'); lReport.Add(''); - 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 1: Frequency %5d for %5d cases.', [f1, ncases1]); + lReport.Add('Sample 2: Frequency %5d for %5d cases.', [f2, ncases2]); lReport.Add(''); lReport.Add('Proportion 1: %9.3f', [Prop1]); lReport.Add('Proportion 2: %9.3f', [Prop2]); lReport.Add('Difference: %9.3f', [PropDif]); 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(' with probability %9.4f', [zProbability]); lReport.Add('z value for confidence interval: %9.3f', [ztest]); @@ -370,9 +390,9 @@ begin end; -procedure TTwoPropForm.RadioGroup1Click(Sender: TObject); +procedure TTwoPropForm.DataSourceGroupClick(Sender: TObject); begin - griddata := (RadioGroup1.ItemIndex = 1); + griddata := (DataSourceGroup.ItemIndex = 1); DepIndepGroupClick(nil); end; @@ -415,7 +435,7 @@ var begin inherited; - RadioGroup1.ItemIndex := 0; + DataSourceGroup.ItemIndex := 0; DepIndepGroup.ItemIndex := 0; VarList.Clear; @@ -600,20 +620,20 @@ begin begin s := VarList.Items[index]; if Var1Edit.Text = '' then - Var1Edit.Text := s - else begin - if independent then - begin - if GrpEdit.Text = '' then - GrpEdit.Text := s; - end else - begin - if Var2Edit.Text = '' then - Var2Edit.Text := s; - end; + Var1Edit.Text := s; + VarList.Items.Delete(index); + 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 + Var2Edit.Text := s; + VarList.Items.Delete(index); end; - UpdateBtnStates; end; end; diff --git a/applications/lazstats/source/forms/mainunit.pas b/applications/lazstats/source/forms/mainunit.pas index f87a21754..4ccff0f51 100644 --- a/applications/lazstats/source/forms/mainunit.pas +++ b/applications/lazstats/source/forms/mainunit.pas @@ -1087,9 +1087,9 @@ end; // Menu "Analysis" > "Comparisons" > "Difference Between Correlations" procedure TOS3MainFrm.mnuAnalysisComp_CorrDiffClick(Sender: TObject); begin - if TwoCorrsFrm = nil then - Application.CreateForm(TTwoCorrsFrm, TwoCorrsFrm); - TwoCorrsFrm.ShowModal; + if TwoCorrsForm = nil then + Application.CreateForm(TTwoCorrsForm, TwoCorrsForm); + TwoCorrsForm.Show; end; // Menu "Analysis" > "Multivariate" > "mnuAnalysisMulti_Correspondence Analysis"