diff --git a/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.lfm b/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.lfm index 5484d2e3d..60ed4326c 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.lfm +++ b/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.lfm @@ -1,752 +1,644 @@ -object BlksAnovaFrm: TBlksAnovaFrm +inherited BlksAnovaFrm: TBlksAnovaFrm Left = 853 - Height = 454 - Top = 256 - Width = 742 + Height = 553 + Top = 216 + Width = 914 HelpType = htKeyword HelpKeyword = 'html/OneTwoorThreeWayAnalysesofVarian.htm' - AutoSize = True Caption = 'One, Two or Three Way Analysis of Variance' - ClientHeight = 454 - ClientWidth = 742 - Constraints.MinHeight = 450 - OnActivate = FormActivate - OnCreate = FormCreate - OnShow = FormShow - Position = poMainFormCenter - LCLVersion = '2.1.0.0' - object Label1: TLabel - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Owner - Left = 8 - Height = 15 - Top = 8 - Width = 49 - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - Caption = 'Variables:' - ParentColor = False - end - object Label2: TLabel - AnchorSideLeft.Control = Fact1Grp - AnchorSideLeft.Side = asrCenter - AnchorSideBottom.Control = Fact1Grp - Left = 441 - Height = 15 - Top = 76 - Width = 68 - Anchors = [akLeft, akBottom] - BorderSpacing.Bottom = 8 - Caption = 'Variable Type' - ParentColor = False - end - object Label3: TLabel - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = OverallAlpha - AnchorSideTop.Side = asrCenter - Left = 8 - Height = 15 - Top = 386 - Width = 147 - BorderSpacing.Left = 8 - Caption = 'Alpha Level for Overall Tests' - ParentColor = False - end - object Label4: TLabel - AnchorSideLeft.Control = OverallAlpha - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = PostAlpha - AnchorSideTop.Side = asrCenter - Left = 232 - Height = 15 - Top = 386 - Width = 163 - BorderSpacing.Left = 24 - Caption = 'Alpha Level for Post-Hoc Tests:' - ParentColor = False - end - object VarList: TListBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Label1 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Panel4 - AnchorSideBottom.Control = OverallAlpha - Left = 8 - Height = 349 - Top = 25 - Width = 201 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - ItemHeight = 0 - OnSelectionChange = VarListSelectionChange - TabOrder = 0 - end - object Fact1Grp: TRadioGroup - AnchorSideRight.Control = GroupBox1 - AnchorSideBottom.Control = Panel2 - AnchorSideBottom.Side = asrBottom - Left = 411 - Height = 70 - Top = 99 - Width = 128 - Anchors = [akRight, akBottom] - AutoFill = True - AutoSize = True - BorderSpacing.Right = 8 - Caption = 'Factor 1' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 - ClientHeight = 50 - ClientWidth = 124 - Items.Strings = ( - 'Fixed Levels' - 'Random Levels' - ) - TabOrder = 3 - end - object Fact2Grp: TRadioGroup - AnchorSideLeft.Control = Fact1Grp - AnchorSideRight.Control = Fact1Grp - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Panel3 - AnchorSideBottom.Side = asrBottom - Left = 411 - Height = 70 - Top = 183 - Width = 128 - Anchors = [akLeft, akRight, akBottom] - AutoFill = True - AutoSize = True - Caption = 'Factor 2' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 - ClientHeight = 50 - ClientWidth = 124 - Items.Strings = ( - 'Fixed Levels' - 'Random Levels' - ) - TabOrder = 5 - end - object Fact3Grp: TRadioGroup - AnchorSideLeft.Control = Fact1Grp - AnchorSideRight.Control = Fact1Grp - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Panel4 - AnchorSideBottom.Side = asrBottom - Left = 411 - Height = 70 - Top = 267 - Width = 128 - Anchors = [akLeft, akRight, akBottom] - AutoFill = True - AutoSize = True - Caption = 'Factor 3' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 - ClientHeight = 50 - ClientWidth = 124 - Items.Strings = ( - 'Fixed Levels' - 'Random Levels' - ) - TabOrder = 7 - end - object GroupBox1: TGroupBox - AnchorSideLeft.Control = GroupBox2 - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - Left = 547 - Height = 177 - Top = 21 - Width = 187 - Anchors = [akTop, akLeft, akRight] - AutoSize = True - BorderSpacing.Right = 8 - Caption = 'Post-Hoc Comparisons:' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.VerticalSpacing = 2 - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ClientHeight = 157 - ClientWidth = 183 - TabOrder = 8 - object Scheffe: TCheckBox - Left = 12 - Height = 19 - Top = 6 - Width = 138 - Caption = 'Scheffe' - TabOrder = 0 + ClientHeight = 553 + ClientWidth = 914 + inherited ParamsPanel: TPanel + Height = 537 + Width = 400 + ClientHeight = 537 + ClientWidth = 400 + inherited CloseBtn: TButton + Left = 345 + Top = 512 end - object TukeyHSD: TCheckBox - Left = 12 - Height = 19 - Top = 27 - Width = 138 - Caption = 'Tukey HSD (= n''s)' - TabOrder = 1 + inherited ComputeBtn: TButton + Left = 261 + Top = 512 end - object TukeyB: TCheckBox - Left = 12 - Height = 19 - Top = 48 - Width = 138 - Caption = 'Tukey B (= n''s)' - TabOrder = 2 + inherited ResetBtn: TButton + Left = 199 + Top = 512 end - object TukeyKramer: TCheckBox - Left = 12 - Height = 19 - Top = 69 - Width = 138 - Caption = 'Tukey-Kramer' - TabOrder = 3 + inherited HelpBtn: TButton + Tag = 107 + Left = 140 + Top = 512 end - object NewmanKeuls: TCheckBox - Left = 12 - Height = 19 - Top = 90 - Width = 138 - Caption = 'Newman-Keuls (= n''s)' - TabOrder = 4 + inherited ButtonBevel: TBevel + Top = 496 + Width = 400 end - object Bonferoni: TCheckBox - Left = 12 - Height = 19 - Top = 111 - Width = 138 - Caption = 'Bonferroni' - TabOrder = 5 - end - object OrthoContrasts: TCheckBox - Left = 12 - Height = 19 - Top = 132 - Width = 138 - Caption = 'Orthogonal Contrasts' - TabOrder = 6 - end - end - object GroupBox2: TGroupBox - AnchorSideTop.Control = GroupBox1 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - Left = 547 - Height = 152 - Top = 214 - Width = 187 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Top = 16 - BorderSpacing.Right = 8 - Caption = 'Options' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.VerticalSpacing = 2 - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ClientHeight = 132 - ClientWidth = 183 - TabOrder = 9 - object PlotMeans: TCheckBox - Left = 12 - Height = 19 - Top = 6 - Width = 159 - Caption = 'Plot Means Using 3D bars' - TabOrder = 0 - end - object Plot2DLines: TCheckBox - Left = 12 - Height = 19 - Top = 27 - Width = 159 - Caption = 'Plot Means Using 2D Lines' - TabOrder = 1 - end - object Plot3DLines: TCheckBox - Left = 12 - Height = 19 - Top = 48 - Width = 159 - Caption = 'Plot Means Using 3D Lines' - TabOrder = 2 - end - object Label5: TLabel - Left = 12 + object Label1: TLabel[5] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = ParamsPanel + Left = 0 Height = 15 - Top = 69 - Width = 159 - Caption = 'Corrections for unequal Var.' + Top = 0 + Width = 49 + Caption = 'Variables:' ParentColor = False end - object BrownForsythe: TCheckBox - Left = 12 - Height = 19 - Top = 86 - Width = 159 - Caption = 'Brown-Forsythe for 1-way' - TabOrder = 3 - end - object Welch: TCheckBox - Left = 12 - Height = 19 - Top = 107 - Width = 159 - Caption = 'Welch for 1-way' + object VarList: TListBox[6] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = Label1 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = DepIn + AnchorSideBottom.Control = PosthocGroup + Left = 0 + Height = 302 + Top = 17 + Width = 181 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 2 + BorderSpacing.Right = 6 + BorderSpacing.Bottom = 12 + ItemHeight = 0 + OnDblClick = VarListDblClick + OnSelectionChange = VarListSelectionChange TabOrder = 4 end - end - object OverallAlpha: TEdit - AnchorSideLeft.Control = Label3 - AnchorSideLeft.Side = asrBottom - AnchorSideBottom.Control = Bevel1 - Left = 163 - Height = 23 - Top = 382 - Width = 45 - Alignment = taRightJustify - Anchors = [akLeft, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - TabOrder = 10 - Text = 'OverallAlpha' - end - object PostAlpha: TEdit - AnchorSideLeft.Control = Label4 - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = OverallAlpha - AnchorSideTop.Side = asrCenter - Left = 403 - Height = 23 - Top = 382 - Width = 51 - Alignment = taRightJustify - BorderSpacing.Left = 8 - TabOrder = 11 - Text = 'PostAlpha' - end - object ResetBtn: TButton - AnchorSideRight.Control = ComputeBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 521 - Height = 25 - Top = 421 - Width = 54 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 12 - BorderSpacing.Top = 8 - BorderSpacing.Right = 12 - BorderSpacing.Bottom = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 13 - end - object ComputeBtn: TButton - AnchorSideRight.Control = CloseBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 587 - Height = 25 - Top = 421 - Width = 76 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 12 - BorderSpacing.Top = 8 - BorderSpacing.Right = 12 - BorderSpacing.Bottom = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick - TabOrder = 14 - end - object CloseBtn: TButton - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 675 - Height = 25 - Top = 421 - Width = 55 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 12 - BorderSpacing.Top = 8 - BorderSpacing.Right = 12 - BorderSpacing.Bottom = 8 - Caption = 'Close' - ModalResult = 11 - TabOrder = 15 - end - object HelpBtn: TButton - Tag = 107 - AnchorSideRight.Control = ResetBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 458 - Height = 25 - Top = 421 - Width = 51 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 12 - BorderSpacing.Top = 8 - BorderSpacing.Right = 12 - BorderSpacing.Bottom = 8 - Caption = 'Help' - OnClick = HelpBtnClick - TabOrder = 12 - end - object Panel1: TPanel - AnchorSideTop.Control = VarList - AnchorSideRight.Control = Panel3 - AnchorSideRight.Side = asrBottom - Left = 217 - Height = 60 - Top = 25 - Width = 186 - Anchors = [akTop, akRight] - AutoSize = True - BevelOuter = bvNone - ClientHeight = 60 - ClientWidth = 186 - TabOrder = 1 - object DepIn: TBitBtn - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = Panel1 - Left = 0 - Height = 28 - Top = 0 - Width = 28 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = DepInClick - Spacing = 0 - TabOrder = 0 - end - object DepOut: TBitBtn - AnchorSideLeft.Control = Panel1 + object DepOut: TBitBtn[7] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = DepIn AnchorSideTop.Side = asrBottom - Left = 0 - Height = 28 - Top = 32 - Width = 28 + Left = 187 + Height = 26 + Top = 47 + Width = 26 BorderSpacing.Top = 4 Images = MainDataModule.ImageList ImageIndex = 0 OnClick = DepOutClick Spacing = 0 - TabOrder = 1 + TabOrder = 5 end - object StaticText1: TStaticText - AnchorSideLeft.Control = DepOut - AnchorSideLeft.Side = asrBottom - AnchorSideBottom.Control = DepVar - Left = 36 - Height = 16 - Top = 7 - Width = 103 - Anchors = [akLeft, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Bottom = 2 - Caption = 'Dependent Variable' - TabOrder = 2 - end - object DepVar: TEdit - AnchorSideLeft.Control = DepOut - AnchorSideLeft.Side = asrBottom - AnchorSideRight.Control = Panel1 - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = DepOut - AnchorSideBottom.Side = asrBottom - Left = 36 - Height = 23 - Top = 25 - Width = 150 - Anchors = [akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Bottom = 12 - Constraints.MinWidth = 150 - OnChange = VarChange - ReadOnly = True - TabOrder = 3 - Text = 'DepVar' - end - end - object Panel2: TPanel - AnchorSideTop.Control = Panel1 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Fact1Grp - Left = 217 - Height = 60 - Top = 109 - Width = 186 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Top = 24 - BorderSpacing.Right = 8 - BevelOuter = bvNone - ClientHeight = 60 - ClientWidth = 186 - TabOrder = 2 - object Fact1In: TBitBtn - AnchorSideLeft.Control = Panel2 - AnchorSideTop.Control = Panel2 - Left = 0 - Height = 28 - Top = 0 - Width = 28 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = Fact1InClick - Spacing = 0 - TabOrder = 0 - end - object Fact1Out: TBitBtn - AnchorSideLeft.Control = Panel2 + object Fact1Out: TBitBtn[8] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = Fact1In AnchorSideTop.Side = asrBottom - Left = 0 - Height = 28 - Top = 32 - Width = 28 + Left = 187 + Height = 26 + Top = 119 + Width = 26 BorderSpacing.Top = 4 Images = MainDataModule.ImageList ImageIndex = 0 OnClick = Fact1OutClick Spacing = 0 - TabOrder = 1 + TabOrder = 6 end - object StaticText2: TStaticText - AnchorSideLeft.Control = Factor1 - AnchorSideBottom.Control = Factor1 - Left = 36 - Height = 16 - Top = 7 - Width = 87 - Anchors = [akLeft, akBottom] - AutoSize = True - BorderSpacing.Bottom = 2 - Caption = 'Factor 1 Variable' - TabOrder = 2 - end - object Factor1: TEdit - AnchorSideLeft.Control = Fact1Out - AnchorSideLeft.Side = asrBottom - AnchorSideRight.Control = Panel2 - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Fact1Out - AnchorSideBottom.Side = asrBottom - Left = 36 - Height = 23 - Top = 25 - Width = 150 - Anchors = [akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Bottom = 12 - Constraints.MinWidth = 150 - OnChange = VarChange - ReadOnly = True - TabOrder = 3 - Text = 'Factor1' - end - end - object Panel3: TPanel - AnchorSideTop.Control = Panel2 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Fact2Grp - Left = 217 - Height = 60 - Top = 193 - Width = 186 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Top = 24 - BorderSpacing.Right = 8 - BevelOuter = bvNone - ClientHeight = 60 - ClientWidth = 186 - TabOrder = 4 - object Fact2In: TBitBtn - AnchorSideLeft.Control = Panel3 - AnchorSideTop.Control = Panel3 - Left = 0 - Height = 28 - Top = 0 - Width = 28 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = Fact2InClick - Spacing = 0 - TabOrder = 0 - end - object Fact2Out: TBitBtn - AnchorSideLeft.Control = Panel3 + object Fact2Out: TBitBtn[9] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = Fact2In AnchorSideTop.Side = asrBottom - Left = 0 - Height = 28 - Top = 32 - Width = 28 + Left = 187 + Height = 26 + Top = 203 + Width = 26 BorderSpacing.Top = 4 Images = MainDataModule.ImageList ImageIndex = 0 OnClick = Fact2OutClick Spacing = 0 - TabOrder = 1 + TabOrder = 7 end - object StaticText3: TStaticText - AnchorSideLeft.Control = Fact2In - AnchorSideLeft.Side = asrBottom - AnchorSideBottom.Control = Factor2 - Left = 36 - Height = 16 - Top = 7 - Width = 87 - Anchors = [akLeft, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Bottom = 2 - Caption = 'Factor 2 Variable' - TabOrder = 2 - end - object Factor2: TEdit - AnchorSideLeft.Control = Fact2In - AnchorSideLeft.Side = asrBottom - AnchorSideRight.Control = Panel3 - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Fact2Out - AnchorSideBottom.Side = asrBottom - Left = 36 - Height = 23 - Top = 25 - Width = 150 - Anchors = [akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Bottom = 12 - Constraints.MinWidth = 150 - OnChange = VarChange - ReadOnly = True - TabOrder = 3 - Text = 'Factor2' - end - end - object Panel4: TPanel - AnchorSideLeft.Control = Panel1 - AnchorSideTop.Control = Panel3 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Fact3Grp - Left = 217 - Height = 60 - Top = 277 - Width = 186 - Anchors = [akTop, akLeft, akRight] - AutoSize = True - BorderSpacing.Top = 24 - BorderSpacing.Right = 8 - BevelOuter = bvNone - ClientHeight = 60 - ClientWidth = 186 - TabOrder = 6 - object Fact3In: TBitBtn - AnchorSideLeft.Control = Panel4 - AnchorSideTop.Control = Panel4 - Left = 0 - Height = 28 - Top = 0 - Width = 28 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = Fact3InClick - Spacing = 0 - TabOrder = 0 - end - object Fact3Out: TBitBtn - AnchorSideLeft.Control = Panel4 + object Fact3Out: TBitBtn[10] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = Fact3In AnchorSideTop.Side = asrBottom - Left = 0 - Height = 28 - Top = 32 - Width = 28 + Left = 187 + Height = 26 + Top = 287 + Width = 26 BorderSpacing.Top = 4 Images = MainDataModule.ImageList ImageIndex = 0 OnClick = Fact3OutClick Spacing = 0 - TabOrder = 1 + TabOrder = 8 end - object StaticText4: TStaticText + object DepIn: TBitBtn[11] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = VarList + Left = 187 + Height = 26 + Top = 17 + Width = 26 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = DepInClick + Spacing = 0 + TabOrder = 9 + end + object StaticText1: TStaticText[12] + AnchorSideLeft.Control = DepVarEdit + AnchorSideTop.Control = DepIn + AnchorSideBottom.Control = DepVarEdit + Left = 219 + Height = 16 + Top = 17 + Width = 103 + AutoSize = True + BorderSpacing.Bottom = 2 + Caption = 'Dependent Variable' + TabOrder = 10 + end + object DepVarEdit: TEdit[13] + AnchorSideLeft.Control = DepIn + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = StaticText1 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Side = asrBottom + Left = 219 + Height = 23 + Top = 35 + Width = 181 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 6 + BorderSpacing.Top = 2 + Constraints.MinWidth = 150 + OnChange = VarChange + ReadOnly = True + TabOrder = 11 + Text = 'DepVarEdit' + end + object Fact1In: TBitBtn[14] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = DepOut + AnchorSideTop.Side = asrBottom + Left = 187 + Height = 26 + Top = 89 + Width = 26 + BorderSpacing.Top = 16 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = Fact1InClick + Spacing = 0 + TabOrder = 12 + end + object StaticText2: TStaticText[15] + AnchorSideLeft.Control = Factor1Edit + AnchorSideTop.Control = Fact1In + AnchorSideBottom.Control = Factor1Edit + Left = 221 + Height = 16 + Top = 89 + Width = 87 + AutoSize = True + BorderSpacing.Bottom = 2 + Caption = 'Factor 1 Variable' + TabOrder = 13 + end + object Factor1Edit: TEdit[16] + AnchorSideLeft.Control = Fact1In + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = StaticText2 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Side = asrBottom + Left = 221 + Height = 23 + Top = 107 + Width = 179 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + Constraints.MinWidth = 150 + OnChange = VarChange + ReadOnly = True + TabOrder = 14 + Text = 'Factor1Edit' + end + object Fact1Combo: TComboBox[17] + AnchorSideLeft.Control = Label6 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Factor1Edit + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Factor1Edit + AnchorSideRight.Side = asrBottom + Left = 261 + Height = 23 + Top = 132 + Width = 139 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'Fixed' + 'Random' + ) + Style = csDropDownList + TabOrder = 15 + Text = 'Fixed' + end + object Label6: TLabel[18] + AnchorSideLeft.Control = Factor1Edit + AnchorSideTop.Control = Fact1Combo + AnchorSideTop.Side = asrCenter + Left = 221 + Height = 15 + Top = 136 + Width = 32 + Caption = 'Levels' + ParentColor = False + end + object Fact2In: TBitBtn[19] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = Fact1Combo + AnchorSideTop.Side = asrBottom + Left = 187 + Height = 26 + Top = 173 + Width = 26 + BorderSpacing.Top = 18 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = Fact2InClick + Spacing = 0 + TabOrder = 16 + end + object StaticText3: TStaticText[20] + AnchorSideLeft.Control = Fact2In + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Fact2In + AnchorSideBottom.Control = Factor2Edit + Left = 221 + Height = 16 + Top = 173 + Width = 87 + AutoSize = True + BorderSpacing.Left = 8 + BorderSpacing.Bottom = 2 + Caption = 'Factor 2 Variable' + TabOrder = 17 + end + object Factor2Edit: TEdit[21] + AnchorSideLeft.Control = Fact2In + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = StaticText3 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Side = asrBottom + Left = 221 + Height = 23 + Top = 191 + Width = 179 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + Constraints.MinWidth = 150 + OnChange = VarChange + ReadOnly = True + TabOrder = 18 + Text = 'Factor2Edit' + end + object Label7: TLabel[22] + AnchorSideLeft.Control = Factor1Edit + AnchorSideTop.Control = Fact2Combo + AnchorSideTop.Side = asrCenter + Left = 221 + Height = 15 + Top = 220 + Width = 32 + Caption = 'Levels' + ParentColor = False + end + object Fact2Combo: TComboBox[23] + AnchorSideLeft.Control = Label7 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Factor2Edit + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Factor1Edit + AnchorSideRight.Side = asrBottom + Left = 261 + Height = 23 + Top = 216 + Width = 139 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'Fixed' + 'Random' + ) + Style = csDropDownList + TabOrder = 19 + Text = 'Fixed' + end + object Fact3In: TBitBtn[24] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = Fact2Combo + AnchorSideTop.Side = asrBottom + Left = 187 + Height = 26 + Top = 257 + Width = 26 + BorderSpacing.Top = 18 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = Fact3InClick + Spacing = 0 + TabOrder = 20 + end + object StaticText4: TStaticText[25] AnchorSideLeft.Control = Fact3In AnchorSideLeft.Side = asrBottom - AnchorSideBottom.Control = Factor3 - Left = 36 + AnchorSideTop.Control = Fact3In + Left = 221 Height = 16 - Top = 7 + Top = 257 Width = 72 - Anchors = [akLeft, akBottom] AutoSize = True BorderSpacing.Left = 8 BorderSpacing.Bottom = 2 Caption = 'Factor 3 Clark' - TabOrder = 2 + TabOrder = 21 end - object Factor3: TEdit + object Factor3Edit: TEdit[26] AnchorSideLeft.Control = Fact3In AnchorSideLeft.Side = asrBottom - AnchorSideRight.Control = Panel4 + AnchorSideTop.Control = StaticText4 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Fact3Out AnchorSideBottom.Side = asrBottom - Left = 36 + Left = 221 Height = 23 - Top = 25 - Width = 150 - Anchors = [akLeft, akRight, akBottom] + Top = 275 + Width = 179 + Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 - BorderSpacing.Bottom = 12 + BorderSpacing.Bottom = 2 OnChange = VarChange ReadOnly = True - TabOrder = 3 - Text = 'Factor3' + TabOrder = 22 + Text = 'Factor3Edit' + end + object Label8: TLabel[27] + AnchorSideLeft.Control = Factor1Edit + AnchorSideTop.Control = Fact3Combo + AnchorSideTop.Side = asrCenter + Left = 221 + Height = 15 + Top = 304 + Width = 32 + Caption = 'Levels' + ParentColor = False + end + object Fact3Combo: TComboBox[28] + AnchorSideLeft.Control = Label8 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Factor3Edit + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + Left = 261 + Height = 23 + Top = 300 + Width = 139 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'Fixed' + 'Random' + ) + Style = csDropDownList + TabOrder = 23 + Text = 'Fixed' + end + object GroupBox3: TGroupBox[29] + AnchorSideLeft.Control = Bevel1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PosthocGroup + Left = 207 + Height = 66 + Top = 331 + Width = 196 + AutoSize = True + Caption = 'Corrections for unequal variances' + ChildSizing.LeftRightSpacing = 12 + ChildSizing.TopBottomSpacing = 2 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 46 + ClientWidth = 192 + TabOrder = 24 + object BrownForsythe: TCheckBox + Left = 12 + Height = 19 + Top = 2 + Width = 157 + Caption = 'Brown-Forsythe for 1-way' + TabOrder = 0 + end + object Welch: TCheckBox + Left = 12 + Height = 19 + Top = 21 + Width = 157 + BorderSpacing.Bottom = 6 + Caption = 'Welch for 1-way' + TabOrder = 1 + end + end + object PosthocGroup: TGroupBox[30] + AnchorSideLeft.Control = ParamsPanel + AnchorSideRight.Control = Bevel1 + AnchorSideBottom.Control = ButtonBevel + Left = 0 + Height = 165 + Top = 331 + Width = 186 + Anchors = [akLeft, akRight, akBottom] + AutoSize = True + BorderSpacing.Right = 8 + Caption = 'Post-Hoc Comparisons:' + ChildSizing.LeftRightSpacing = 12 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 145 + ClientWidth = 182 + TabOrder = 25 + object Scheffe: TCheckBox + Left = 12 + Height = 19 + Top = 6 + Width = 138 + Caption = 'Scheffe' + TabOrder = 0 + end + object TukeyHSD: TCheckBox + Left = 12 + Height = 19 + Top = 25 + Width = 138 + Caption = 'Tukey HSD (= n''s)' + TabOrder = 1 + end + object TukeyB: TCheckBox + Left = 12 + Height = 19 + Top = 44 + Width = 138 + Caption = 'Tukey B (= n''s)' + TabOrder = 2 + end + object TukeyKramer: TCheckBox + Left = 12 + Height = 19 + Top = 63 + Width = 138 + Caption = 'Tukey-Kramer' + TabOrder = 3 + end + object NewmanKeuls: TCheckBox + Left = 12 + Height = 19 + Top = 82 + Width = 138 + Caption = 'Newman-Keuls (= n''s)' + TabOrder = 4 + end + object Bonferoni: TCheckBox + Left = 12 + Height = 19 + Top = 101 + Width = 138 + Caption = 'Bonferroni' + TabOrder = 5 + end + object OrthoContrasts: TCheckBox + Left = 12 + Height = 19 + Top = 120 + Width = 138 + Caption = 'Orthogonal Contrasts' + TabOrder = 6 + end + end + object GroupBox1: TGroupBox[31] + AnchorSideLeft.Control = GroupBox3 + AnchorSideRight.Control = GroupBox3 + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = ButtonBevel + Left = 207 + Height = 80 + Top = 416 + Width = 196 + Anchors = [akLeft, akRight, akBottom] + AutoSize = True + Caption = 'Alpha Levels' + ClientHeight = 60 + ClientWidth = 192 + TabOrder = 26 + object Label3: TLabel + AnchorSideTop.Control = OverallAlpha + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = Label4 + AnchorSideRight.Side = asrBottom + Left = 40 + Height = 15 + Top = 8 + Width = 65 + Alignment = taRightJustify + Anchors = [akTop, akRight] + BorderSpacing.Left = 8 + Caption = 'Overall Tests' + ParentColor = False + end + object OverallAlpha: TEdit + AnchorSideLeft.Control = PostAlpha + AnchorSideTop.Control = GroupBox1 + AnchorSideRight.Control = GroupBox1 + AnchorSideRight.Side = asrBottom + Left = 113 + Height = 23 + Top = 4 + Width = 71 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + TabOrder = 0 + Text = 'OverallAlpha' + end + object Label4: TLabel + AnchorSideLeft.Control = GroupBox1 + AnchorSideTop.Control = PostAlpha + AnchorSideTop.Side = asrCenter + Left = 24 + Height = 15 + Top = 33 + Width = 81 + BorderSpacing.Left = 24 + BorderSpacing.Right = 8 + Caption = 'Post-Hoc Tests:' + ParentColor = False + end + object PostAlpha: TEdit + AnchorSideLeft.Control = Label4 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = OverallAlpha + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = OverallAlpha + AnchorSideRight.Side = asrBottom + Left = 113 + Height = 23 + Top = 29 + Width = 71 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + BorderSpacing.Bottom = 8 + TabOrder = 1 + Text = 'PostAlpha' + end + end + object Bevel1: TBevel[32] + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = PosthocGroup + Left = 194 + Height = 42 + Top = 331 + Width = 13 + Shape = bsSpacer end end - object Bevel1: TBevel - AnchorSideLeft.Control = Owner - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CloseBtn - Left = 0 - Height = 8 - Top = 405 - Width = 742 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine + inherited ParamsSplitter: TSplitter + Left = 412 + Height = 553 + end + inherited PageControl: TPageControl + Left = 421 + Height = 537 + Width = 485 end end diff --git a/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas b/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas index 005a766bc..ab9726819 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/blkanovaunit.pas @@ -7,23 +7,26 @@ unit BlkANOVAUnit; interface uses - Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, - StdCtrls, Buttons, ExtCtrls, - MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, GraphLib, - ANOVATestsUnit, ContextHelpUnit; + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, + StdCtrls, Buttons, ExtCtrls, ComCtrls, + MainUnit, Globals, FunctionsLib, DataProcs, GraphLib, + ANOVATestsUnit, BasicStatsReportAndChartFormUnit; type { TBlksAnovaFrm } - TBlksAnovaFrm = class(TForm) + TBlksAnovaFrm = class(TBasicStatsReportAndChartForm) Bevel1: TBevel; BrownForsythe: TCheckBox; - Label5: TLabel; - Panel1: TPanel; - Panel2: TPanel; - Panel3: TPanel; - Panel4: TPanel; + Fact1Combo: TComboBox; + Fact2Combo: TComboBox; + Fact3Combo: TComboBox; + GroupBox1: TGroupBox; + GroupBox3: TGroupBox; + Label6: TLabel; + Label7: TLabel; + Label8: TLabel; Welch: TCheckBox; DepIn: TBitBtn; DepOut: TBitBtn; @@ -33,41 +36,28 @@ type Fact2Out: TBitBtn; Fact3In: TBitBtn; Fact3Out: TBitBtn; - HelpBtn: TButton; - ResetBtn: TButton; - ComputeBtn: TButton; - CloseBtn: TButton; Scheffe: TCheckBox; - Plot3DLines: TCheckBox; TukeyHSD: TCheckBox; TukeyB: TCheckBox; TukeyKramer: TCheckBox; NewmanKeuls: TCheckBox; Bonferoni: TCheckBox; OrthoContrasts: TCheckBox; - PlotMeans: TCheckBox; - Plot2DLines: TCheckBox; - DepVar: TEdit; - Factor1: TEdit; - Factor2: TEdit; - Factor3: TEdit; + DepVarEdit: TEdit; + Factor1Edit: TEdit; + Factor2Edit: TEdit; + Factor3Edit: TEdit; OverallAlpha: TEdit; PostAlpha: TEdit; - GroupBox1: TGroupBox; - GroupBox2: TGroupBox; + PosthocGroup: TGroupBox; Label1: TLabel; - Label2: TLabel; Label3: TLabel; Label4: TLabel; VarList: TListBox; - Fact1Grp: TRadioGroup; - Fact2Grp: TRadioGroup; - Fact3Grp: TRadioGroup; StaticText1: TStaticText; StaticText2: TStaticText; StaticText3: TStaticText; StaticText4: TStaticText; - procedure ComputeBtnClick(Sender: TObject); procedure DepInClick(Sender: TObject); procedure DepOutClick(Sender: TObject); procedure VarChange(Sender: TObject); @@ -77,15 +67,10 @@ type procedure Fact3InClick(Sender: TObject); procedure Fact3OutClick(Sender: TObject); procedure Fact1InClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormShow(Sender: TObject); - procedure HelpBtnClick(Sender: TObject); - procedure ResetBtnClick(Sender: TObject); + procedure VarListDblClick(Sender: TObject); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); private { private declarations } - FAutoSized: Boolean; NoSelected, N: integer; ColNoSelected: IntDyneVec; outline, cellstring: string; @@ -97,7 +82,8 @@ type OmegaF1F3, OmegaF2F3, OmegaF1F2F3: double; FF1, FF2, FF1F2, ProbF1, ProbF2, ProbF3, ProbF1F2, ProbF1F3: double; FF3, FF2F3, FF1F3, FF1F2F3, ProbF2F3, ProbF1F2F3: double; - DepVarCol, F1Col, F2Col, F3Col, Nf1cells, Nf2cells, Nf3cells: integer; + //DepVarCol, F1Col, F2Col, F3Col, + Nf1cells, Nf2cells, Nf3cells: integer; MeanDep, MeanF1, MeanF2, MeanF3: double; minf1, maxf1, minf2, maxf2, minf3, maxf3, nofactors, totcells: integer; cellcnts: IntDyneVec; // array of cell counts @@ -122,30 +108,37 @@ type wsum, wx2: DblDyneCube; ncnt: IntDyneCube; OKterms: array[1..14] of integer; - CompError: boolean; procedure GetLevels; - procedure Calc1Way; + + function Calc1Way: Boolean; procedure OneWayTable(AReport: TStrings); procedure OneWayPlot; - procedure Calc2Way; + + function Calc2Way: Boolean; procedure TwoWayTable(AReport: TStrings); procedure TwoWayPlot; procedure TwoWayContrasts(AReport: TStrings); - procedure Calc3Way; + + function Calc3Way: Boolean; procedure ThreeWayTable(AReport: TStrings); procedure ThreeWayPlot; procedure ThreeWayContrasts(AReport: TStrings); + procedure BrownForsytheOneWay(AReport: TStrings); procedure WelchOneWay(AReport: TStrings); procedure WelchtTests(AReport: TStrings); - procedure UpdateBtnStates; - function Validate(out AMsg: String; out AControl: TWinControl; - DepVarIndex, Fact1Index, Fact2Index, Fact3Index: Integer): 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 @@ -153,25 +146,57 @@ var implementation +{$R *.lfm} + uses Math, - Utils, MathUnit; + Utils, MathUnit, MatrixUnit, GridProcs; { TBlksAnovaFrm } -procedure TBlksAnovaFrm.ResetBtnClick(Sender: TObject); +constructor TBlksAnovaFrm.Create(AOwner: TComponent); +begin + inherited; + + if GraphFrm = nil then + Application.CreateForm(TGraphFrm, GraphFrm); + + OverallAlpha.Text := FloatToStr(DEFAULT_ALPHA_LEVEL); + PostAlpha.Text := FloatToStr(DEFAULT_ALPHA_LEVEL); +end; + + +procedure TBlksAnovaFrm.AdjustConstraints; +begin + inherited; + ParamsPanel.Constraints.MinHeight := Fact3Combo.Top + Fact3Combo.Height + + VarList.BorderSpacing.Bottom + PosthocGroup.Height + + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; + ParamsPanel.Constraints.MinWidth := Max( + GroupBox3.Width * 2 + Bevel1.Width, + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left + ); +end; + + +procedure TBlksAnovaFrm.Reset; var i: integer; begin + inherited; + VarList.Clear; - DepVar.Text := ''; - Factor1.Text := ''; - Factor2.Text := ''; - Factor3.Text := ''; - Fact1Grp.ItemIndex := 0; - Fact2Grp.ItemIndex := 0; - Fact3Grp.ItemIndex := 0; - PlotMeans.Checked := false; + for i := 1 to NoVariables do + VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); + + DepVarEdit.Text := ''; + Factor1Edit.Text := ''; + Factor2Edit.Text := ''; + Factor3Edit.Text := ''; + Fact1Combo.ItemIndex := 0; + Fact2Combo.ItemIndex := 0; + Fact3Combo.ItemIndex := 0; +// PlotMeans.Checked := false; Scheffe.Checked := false; TukeyHSD.Checked := false; TukeyB.Checked := false; @@ -180,79 +205,30 @@ begin Bonferoni.Checked := false; PostAlpha.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL); OverAllalpha.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL); - for i := 1 to NoVariables do - VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); UpdateBtnStates; end; -procedure TBlksAnovaFrm.FormActivate(Sender: TObject); -var - w: Integer; -begin - if FAutoSized then - exit; - - w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); - HelpBtn.Constraints.MinWidth := w; - ResetBtn.Constraints.MinWidth := w; - ComputeBtn.Constraints.MinWidth := w; - CloseBtn.Constraints.MinWidth := w; - - VarList.Constraints.MinWidth := OverallAlpha.Left + OverallAlpha.Width - VarList.Left; - Constraints.MinWidth := Width; - Constraints.MinHeight := Height; - - FAutoSized := true; -end; - -procedure TBlksAnovaFrm.FormCreate(Sender: TObject); -begin - Assert(OS3MainFrm <> nil); - if GraphFrm = nil then - Application.CreateForm(TGraphFrm, GraphFrm); - - OverallAlpha.Text := FloatToStr(DEFAULT_ALPHA_LEVEL); - PostAlpha.Text := FloatToStr(DEFAULT_ALPHA_LEVEL); -end; - -procedure TBlksAnovaFrm.FormShow(Sender: TObject); -begin - ResetBtnClick(self); -end; - -procedure TBlksAnovaFrm.HelpBtnClick(Sender: TObject); -begin - if ContextHelpForm = nil then - Application.CreateForm(TContextHelpForm, ContextHelpForm); - ContextHelpForm.HelpMessage((Sender as TButton).tag); -end; procedure TBlksAnovaFrm.DepInClick(Sender: TObject); var index: integer; begin index := VarList.ItemIndex; - if (index > -1) and (DepVar.Text = '') then + if (index > -1) and (DepVarEdit.Text = '') then begin - DepVar.Text := VarList.Items[index]; + DepVarEdit.Text := VarList.Items[index]; VarList.Items.Delete(index); UpdateBtnStates; end; end; -procedure TBlksAnovaFrm.ComputeBtnClick(Sender: TObject); +procedure TBlksAnovaFrm.Compute; var i: integer; - msg: String; - C: TWinControl; lReport: TStrings; + DepVarCol, F1Col, F2Col, F3Col: Integer; begin // initialize values - SetLength(ColNoSelected, NoVariables); - DepVarCol := 0; - F1Col := 0; - F2Col := 0; - F3Col := 0; SSDep := 0.0; SSF1 := 0.0; SSF2 := 0.0; @@ -277,31 +253,54 @@ begin minf3 := 0; maxf3 := 0; + // Get column numbers of dependent variable and factors + NoSelected := 2; + DepVarCol := GetVariableIndex(OS3MainFrm.DataGrid, DepVarEdit.Text); + F1Col := GetVariableIndex(OS3MainFrm.DataGrid, Factor1Edit.Text); + if Factor2Edit.Text <> '' then + begin + F2Col := GetVariableIndex(OS3MainFrm.DataGrid, Factor2Edit.Text); + inc(NoSelected); + end; + if Factor3Edit.Text <> '' then + begin + F3Col := GetVariableIndex(OS3MainFrm.DataGrid, Factor3Edit.Text); + inc(NoSelected); + end; + NoFactors := NoSelected - 1; + + SetLength(ColNoSelected, NoSelected); + ColNoSelected[0] := DepVarCol; + ColNoSelected[1] := F1Col; + if NoSelected > 2 then ColNoSelected[2] := F2Col; + if NoSelected > 3 then ColNoSelected[3] := F3Col; + lReport := TStringList.Create; try + (* // Get column numbers of dependent variable and factors for i := 1 to NoVariables do begin cellstring := OS3MainFrm.DataGrid.Cells[i,0]; - if cellstring = DepVar.Text then + if cellstring = DepVarEdit.Text then begin DepVarCol := i; NoSelected := NoSelected + 1; ColNoSelected[NoSelected-1] := DepVarCol; end; - if cellstring = Factor1.Text then + if cellstring = Factor1Edit.Text then begin F1Col := i; NoSelected := NoSelected + 1; ColNoSelected[NoSelected-1] := F1Col; end; - if cellstring = Factor2.Text then + if cellstring = Factor2Edit.Text then begin F2Col := i; NoSelected := NoSelected + 1; ColNoSelected[NoSelected-1] := F2Col; end; - if cellstring = Factor3.Text then + if cellstring = Factor3Edit.Text then begin F3Col := i; NoSelected := NoSelected + 1; @@ -309,14 +308,9 @@ begin end; end; - if not Validate(msg, C, DepVarCol, F1Col, F2Col, F3Col) then begin - C.SetFocus; - ErrorMsg(msg); - exit; - end; - if F2Col = 0 then nofactors := 1 else nofactors := 2; if F3Col <> 0 then nofactors := 3; + *) allAlpha := StrToFloat(OverAllalpha.Text); PostHocAlpha := StrToFloat(PostAlpha.Text); @@ -341,8 +335,7 @@ begin case nofactors of 1 : // single factor anova begin - Calc1Way; - if CompError then + if not Calc1Way then exit; OneWayTable(lReport); // output the results if Scheffe.Checked then @@ -363,12 +356,8 @@ begin BrownForsytheOneWay(lReport); if Welch.Checked then WelchOneWay(lReport); - - if not DisplayReport(lReport) then - exit; - - if PlotMeans.Checked or Plot2DLines.Checked or Plot3DLines.Checked then - OneWayPlot; + FReportFrame.DisplayReport(lReport); + OneWayPlot; end; 2 : // two-way anova @@ -383,28 +372,13 @@ begin SetLength(OrdMeansA,Nf1cells); // ordered means for factor 1 SetLength(OrdMeansB,Nf2cells); // ordered means for factor 2 - Calc2Way; - if not CompError then - begin - TwoWayTable(lReport); - TwoWayContrasts(lReport); + if not Calc2Way then + exit; - if not DisplayReport(lReport) then - exit; - - if PlotMeans.Checked or Plot2DLines.Checked or Plot3DLines.Checked then - TwoWayPlot; - end; - - OrdMeansB := nil; - OrdMeansA := nil; - ColCount := nil; - RowCount := nil; - ColSums := nil; - RowSums := nil; - vars := nil; - sums := nil; - counts := nil; + TwoWayTable(lReport); + TwoWayContrasts(lReport); + FReportFrame.DisplayReport(lReport); + TwoWayPlot; end; 3 : // three way anova @@ -422,50 +396,27 @@ begin SetLength(wx2, Nf1cells, Nf2cells, Nf3cells); SetLength(ncnt, Nf1cells, Nf2cells, Nf3cells); - Calc3Way; + if not Calc3Way then + exit; - if not CompError then - begin - ThreeWayTable(lReport); - ThreeWayContrasts(lReport); - - if not DisplayReport(lReport) then - exit; - - if (PlotMeans.Checked) or (Plot2DLines.Checked) or (Plot3DLines.Checked) then - ThreeWayPlot; - end; - - ncnt := nil; - wx2 := nil; - wsum := nil; - OrdMeansC := nil; - OrdMeansB := nil; - OrdMeansA := nil; - SlcCount := nil; - SlcSums := nil; - ColCount := nil; - ColSums := nil; - RowCount := nil; - RowSums := nil; + ThreeWayTable(lReport); + ThreeWayContrasts(lReport); + FReportFrame.DisplayReport(lReport); + ThreeWayPlot; end; end; finally lReport.Free; - cellcnts := nil; - cellvars := nil; - cellsums := nil; - ColNoSelected := nil; end; end; procedure TBlksAnovaFrm.DepOutClick(Sender: TObject); begin - if DepVar.Text <> '' then + if DepVarEdit.Text <> '' then begin - VarList.Items.Add(DepVar.Text); - DepVar.Text := ''; + VarList.Items.Add(DepVarEdit.Text); + DepVarEdit.Text := ''; end; UpdateBtnStates; end; @@ -477,10 +428,10 @@ end; procedure TBlksAnovaFrm.Fact1OutClick(Sender: TObject); begin - if Factor1.Text <> '' then + if Factor1Edit.Text <> '' then begin - VarList.Items.Add(Factor1.Text); - Factor1.Text := ''; + VarList.Items.Add(Factor1Edit.Text); + Factor1Edit.Text := ''; UpdateBtnStates; end; end; @@ -490,9 +441,9 @@ var index: integer; begin index := VarList.ItemIndex; - if (index > -1) and (Factor2.Text = '') then + if (index > -1) and (Factor2Edit.Text = '') then begin - Factor2.Text := VarList.Items[index]; + Factor2Edit.Text := VarList.Items[index]; VarList.Items.Delete(index); UpdateBtnStates; end; @@ -500,10 +451,10 @@ end; procedure TBlksAnovaFrm.Fact2OutClick(Sender: TObject); begin - if Factor2.Text <> '' then + if Factor2Edit.Text <> '' then begin - VarList.Items.Add(Factor2.Text); - Factor2.Text := ''; + VarList.Items.Add(Factor2Edit.Text); + Factor2Edit.Text := ''; UpdateBtnStates; end; end; @@ -513,9 +464,9 @@ var index: integer; begin index := VarList.ItemIndex; - if (index > -1) and (Factor3.Text = '') then + if (index > -1) and (Factor3Edit.Text = '') then begin - Factor3.Text := VarList.Items[index]; + Factor3Edit.Text := VarList.Items[index]; VarList.Items.Delete(index); UpdateBtnStates; end; @@ -523,10 +474,10 @@ end; procedure TBlksAnovaFrm.Fact3OutClick(Sender: TObject); begin - if Factor3.Text <> '' then + if Factor3Edit.Text <> '' then begin - VarList.Items.Add(Factor3.Text); - Factor3.Text := ''; + VarList.Items.Add(Factor3Edit.Text); + Factor3Edit.Text := ''; UpdateBtnStates; end; end; @@ -536,9 +487,9 @@ var index: integer; begin index := VarList.ItemIndex; - if (index > -1) and (Factor1.Text = '') then + if (index > -1) and (Factor1Edit.Text = '') then begin - Factor1.Text := VarList.Items[index]; + Factor1Edit.Text := VarList.Items[index]; VarList.Items.Delete(index); UpdateBtnStates; end; @@ -556,8 +507,8 @@ begin maxf1 := -MaxInt; for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col, i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); if intvalue > maxf1 then maxf1 := intvalue; if intvalue < minf1 then minf1 := intvalue; end; @@ -569,8 +520,8 @@ begin maxf2 := -MaxInt; for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F2Col, i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]))); if intvalue > maxf2 then maxf2 := intvalue; if intvalue < minf2 then minf2 := intvalue; end; @@ -583,32 +534,30 @@ begin maxf3 := -MaxInt; for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F3Col, i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]))); if intvalue > maxf3 then maxf3 := intvalue; if intvalue < minf3 then minf3 := intvalue; end; Nf3cells := maxf3 - minf3 + 1; - - Caption := IntToStr(Nf3Cells); end; totcells := Nf1cells + Nf2cells + Nf3cells; end; -procedure TBlksAnovaFrm.Calc1Way; +function TBlksAnovaFrm.Calc1Way: Boolean; var i, intValue: integer; X, X2: Double; begin - CompError := false; + Result := true; // get working totals for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); - X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); + X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); X2 := X*X; intvalue := intvalue - minf1; cellcnts[intvalue] := cellcnts[intvalue] + 1; @@ -654,8 +603,8 @@ begin AReport.Add(DIVIDER); AReport.Add('ONE WAY ANALYSIS OF VARIANCE RESULTS'); AReport.Add(DIVIDER); - AReport.Add('Dependent variable is: %s', [DepVar.Text]); - AReport.Add('Independent variable is: %s', [Factor1.Text]); + AReport.Add('Dependent variable is: %s', [DepVarEdit.Text]); + AReport.Add('Independent variable is: %s', [Factor1Edit.Text]); AReport.Add(''); AReport.Add(DIVIDER_SMALL); AReport.Add('SOURCE D.F. SS MS F PROB.>F OMEGA SQR.'); @@ -737,10 +686,11 @@ var plottype : integer; begin plotType := 2; + { if PlotMeans.Checked then plottype := 2; if Plot2DLines.Checked then plottype := 5; if Plot3DLines.Checked then plottype := 6; - + } GraphFrm.SetLabels[1] := 'FACTOR A'; SetLength(GraphFrm.YPoints,1,NF1cells); SetLength(GraphFrm.Xpoints,1,NF1cells); @@ -755,7 +705,7 @@ begin end; GraphFrm.nosets := 1; GraphFrm.nbars := NF1cells; - GraphFrm.Heading := Factor1.Text; + GraphFrm.Heading := Factor1Edit.Text; GraphFrm.XTitle := 'FACTOR A LEVEL'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; @@ -773,15 +723,13 @@ begin GraphFrm.Ypoints := nil; end; -procedure TBlksAnovaFrm.Calc2Way; +function TBlksAnovaFrm.Calc2Way: Boolean; var i, j : integer; grpA, grpB : integer; Constant, RowsTotCnt, ColsTotCnt, SSCells : double; X, X2: Double; begin - CompError := false; - // initialize matrix values NoGrpsA := maxf1 - minf1 + 1; NoGrpsB := maxf2 - minf2 + 1; @@ -813,10 +761,10 @@ begin // get working totals for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - grpA := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); - grpB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F2Col,i]))); - X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + grpA := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); + grpB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]))); + X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); X2 := X*X; grpA := grpA - minf1 + 1; grpB := grpB - minf2 + 1; @@ -862,7 +810,7 @@ begin if (SSF1F2 < 0) or (SSF1 < 0) or (SSF2 < 0) then begin ErrorMsg('A negative SS found. Unbalanced design? Ending analysis.'); - CompError := true; + Result := false; exit; end; @@ -883,7 +831,7 @@ begin MeanDep := MeanDep / N; // F tests for fixed effects - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) then begin FF1 := abs(MSF1 / MSErr); FF2 := abs(MSF2 / MSErr); @@ -894,7 +842,7 @@ begin end; // F tests if both factors are random - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 1) then begin FF1 := abs(MSF1 / MSF1F2); FF2 := abs(MSF2 / MSF1F2); @@ -905,7 +853,7 @@ begin end; // F test if factor A is random - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 0) then begin FF1 := abs(MSF1 / MSErr); FF2 := abs(MSF2 / MSF1F2); @@ -916,7 +864,7 @@ begin end; // F test if factor b is random - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 1) then begin FF1 := abs(MSF1 / MSF1F2); FF2 := abs(MSF2 / MSErr); @@ -930,12 +878,13 @@ begin if (ProbF2 > 1.0) then ProbF2 := 1.0; if (ProbF1F2 > 1.0) then ProbF1F2 := 1.0; - // Obtain omega squared (proportion of dependent variable explained) if (OmegaF1 < 0.0) then OmegaF1 := 0.0; if (OmegaF2 < 0.0) then OmegaF2 := 0.0; if (OmegaF1F2 < 0.0) then OmegaF1F2 := 0.0; if (Omega < 0.0) then Omega := 0.0; + + Result := true; end; procedure TBlksAnovaFrm.TwoWayTable(AReport: TStrings); @@ -946,23 +895,20 @@ var XBar, V, S, RowSS, ColSS: double; sumfreqlogvar, c, bartlett, cochran, hartley, chiprob: double; begin - if CompError then - exit; - AReport.Add('Two Way Analysis of Variance'); AReport.Add(''); - AReport.Add('Variable analyzed: %s', [DepVar.Text]); + AReport.Add('Variable analyzed: %s', [DepVarEdit.Text]); AReport.Add(''); - outline := format('Factor A (rows) variable: %s',[Factor1.Text]); - if Fact1Grp.ItemIndex = 0 then + outline := format('Factor A (rows) variable: %s',[Factor1Edit.Text]); + if Fact1Combo.ItemIndex = 0 then outline := outline + ' (Fixed Levels)' else outline := outline + ' (Random Levels)'; AReport.Add(outline); - outline := format('Factor B (columns) variable: %s',[Factor2.Text]); - if Fact2Grp.ItemIndex = 0 then + outline := format('Factor B (columns) variable: %s',[Factor2Edit.Text]); + if Fact2Combo.ItemIndex = 0 then outline := outline + ' (Fixed Levels)' else outline := outline + ' (Random Levels)'; @@ -979,16 +925,16 @@ begin AReport.Add(''); AReport.Add('Omega squared for combined effects = %8.3f', [Omega]); AReport.Add(''); - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) then AReport.Add('Note: Denominator of F ratio is MSErr'); - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 1) then AReport.Add('Note: Denominator of F ratio is MSAxB'); - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 1) then begin AReport.Add('Note: Denominator of F ratio for A is MSAxB'); AReport.Add('and denominator for B and AxB is MSErr'); end; - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 0) then begin AReport.Add('Note: Denominator of F ratio for B is MSAxB'); AReport.Add('and denominator for A and AxB is MSErr'); @@ -1081,13 +1027,12 @@ var maxmean, XBar : double; plottype : integer; begin - if CompError then - exit; - plottype := 2; + { if PlotMeans.Checked then plottype := 2; if Plot2DLines.Checked then plottype := 5; if Plot3DLines.Checked then plottype := 6; + } // do Factor A first GraphFrm.SetLabels[1] := 'FACTOR A'; @@ -1105,8 +1050,8 @@ begin GraphFrm.nosets := 1; GraphFrm.nbars := NF1cells; - GraphFrm.Heading := Factor1.Text; - GraphFrm.XTitle := Factor1.Text + ' Codes'; + GraphFrm.Heading := Factor1Edit.Text; + GraphFrm.XTitle := Factor1Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1136,8 +1081,8 @@ begin GraphFrm.nosets := 1; GraphFrm.nbars := NF2cells; - GraphFrm.Heading := Factor2.Text; - GraphFrm.XTitle := Factor2.Text + ' Codes'; + GraphFrm.Heading := Factor2Edit.Text; + GraphFrm.XTitle := Factor2Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1157,7 +1102,7 @@ begin maxmean := 0.0; for i := 1 to NF1cells do begin - GraphFrm.SetLabels[i] := Factor1.Text + ' ' + IntToStr(i); + GraphFrm.SetLabels[i] := Factor1Edit.Text + ' ' + IntToStr(i); for j := 1 to NF2cells do begin XBar := sums[i-1,j-1] / counts[i-1,j-1]; @@ -1172,7 +1117,7 @@ begin GraphFrm.nosets := NF1cells; GraphFrm.nbars := NF2cells; GraphFrm.Heading := 'Factor A x Factor B'; - GraphFrm.XTitle := Factor2.Text + ' Codes'; + GraphFrm.XTitle := Factor2Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1189,16 +1134,14 @@ begin GraphFrm.Ypoints := nil; end; -procedure TBlksAnovaFrm.Calc3Way; +function TBlksAnovaFrm.Calc3Way: Boolean; var i, j, k : integer; grpA, grpB, grpC : integer; Constant, RowsTotCnt, ColsTotCnt, SlcsTotCnt, SSCells : double; p, n2 : double; - X, X2: Double; + X, Xsq: Double; begin - CompError := false; - // initialize matrix values NoGrpsA := maxf1 - minf1 + 1; NoGrpsB := maxf2 - minf2 + 1; @@ -1249,18 +1192,18 @@ begin // get working totals for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - grpA := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); - grpB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F2Col,i]))); - grpC := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F3Col,i]))); - X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); - X2 := X*X; + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + grpA := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); + grpB := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[2], i]))); + grpC := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[3], i]))); + X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); + Xsq := X*X; grpA := grpA - minf1 + 1; grpB := grpB - minf2 + 1; grpC := grpC - minf3 + 1; ncnt[grpA-1,grpB-1,grpC-1] := ncnt[grpA-1,grpB-1,grpC-1] + 1; wsum[grpA-1,grpB-1,grpC-1] := wsum[grpA-1,grpB-1,grpc-1] + X; - wx2[grpA-1,grpB-1,grpC-1] := wx2[grpA-1,grpB-1,grpC-1] + X2; + wx2[grpA-1,grpB-1,grpC-1] := wx2[grpA-1,grpB-1,grpC-1] + Xsq; RowSums[GrpA-1] := RowSums[GrpA-1] + X; ColSums[GrpB-1] := ColSums[GrpB-1] + X; SlcSums[GrpC-1] := SlcSums[GrpC-1] + X; @@ -1268,7 +1211,7 @@ begin ColCount[GrpB-1] := ColCount[GrpB-1] + 1; SlcCount[GrpC-1] := SlcCount[GrpC-1] + 1; MeanDep := MeanDep + X; - SSDep := SSDep + X2; + SSDep := SSDep + Xsq; N := N + 1; end; @@ -1367,7 +1310,7 @@ begin (SSF1F3 < 0.0) or (SSF2F3 < 0.0) or (SSF1F2F3 < 0.0) then begin ErrorMsg('ERROR! A negative SS found. Unbalanced Design? Ending analysis.'); - CompError := true; + Result := false; exit; end; @@ -1400,7 +1343,7 @@ begin MeanDep := MeanDep / N; // F tests for fixed effects - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 0) then begin FF1 := abs(MSF1 / MSErr); FF2 := abs(MSF2 / MSErr); @@ -1421,7 +1364,7 @@ begin // F tests if all factors are random for i := 1 to 14 do OKterms[i] := 1; // initialize as OK - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 1) then begin if (MSF1F2 + MSF1F3 - MSF1F2F3) < 0.0 then OKTerms[1] := 0 @@ -1446,7 +1389,7 @@ begin end; // F test if factor A is random, B and C Fixed - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 0) then begin FF1 := abs(MSF1 / MSErr); FF2 := abs(MSF2 / MSF1F2); @@ -1465,7 +1408,7 @@ begin end; // F test if factor b is random and A and C are Fixed - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 0) then begin FF1 := abs(MSF1 / MSF1F2); FF2 := abs(MSF2 / MSErr); @@ -1484,7 +1427,7 @@ begin end; // F test if factor c is random and A and B are Fixed - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 1) then begin FF1 := abs(MSF1 / MSF1F3); FF2 := abs(MSF2 / MSF2F3); @@ -1503,7 +1446,7 @@ begin end; // F tests if A is fixed, B and C are random - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 1) then begin if (MSF1F3 + MSF1F2 - MSF1F2F3) < 0.0 then OKTerms[1] := 0 @@ -1526,7 +1469,7 @@ begin end; // F tests if B is fixed, A and C are random - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 1) then begin FF1 := abs(MSF2 / MSF1F3); if (MSF2F3 + MSF1F2 - MSF1F2F3) <= 0.0 @@ -1549,7 +1492,7 @@ begin end; // F tests if C is fixed A and B are random - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 0) then begin FF1 := abs(MSF1 / MSF1F2); FF2 := abs(MSF2 / MSF1F2); @@ -1588,6 +1531,8 @@ begin if OmegaF2F3 < 0.0 then OmegaF2F3 := 0.0; if OmegaF1F2F3 < 0.0 then OmegaF1F2F3 := 0.0; if (Omega < 0.0) then Omega := 0.0; + + Result := true; end; procedure TBlksAnovaFrm.ThreeWayTable(AReport: TStrings); @@ -1597,33 +1542,29 @@ var i, j, k: integer; XBar, V, S, RowSS, ColSS, SlcSS: double; sumfreqlogvar, c, bartlett, cochran, hartley, chiprob: double; - problem: boolean; + problem: boolean = false; begin - if CompError then - exit; - - problem := false; AReport.Add('Three Way Analysis of Variance'); AReport.Add(''); - AReport.Add('Variable analyzed: %s', [DepVar.Text]); + AReport.Add('Variable analyzed: %s', [DepVarEdit.Text]); AReport.Add(''); - outline := format('Factor A (rows) variable: %s', [Factor1.Text]); - if Fact1Grp.ItemIndex = 0 then + outline := format('Factor A (rows) variable: %s', [Factor1Edit.Text]); + if Fact1Combo.ItemIndex = 0 then outline := outline + ' (Fixed Levels)' else outline := outline + ' (Random Levels)'; AReport.Add(outline); - outline := format('Factor B (columns) variable: %s', [Factor2.Text]); - if Fact2Grp.ItemIndex = 0 then + outline := format('Factor B (columns) variable: %s', [Factor2Edit.Text]); + if Fact2Combo.ItemIndex = 0 then outline := outline + ' (Fixed Levels)' else outline := outline + ' (Random Levels)'; AReport.Add(outline); - outline := format('Factor C (slices) variable: %s', [Factor3.Text]); - if Fact3Grp.ItemIndex = 0 then + outline := format('Factor C (slices) variable: %s', [Factor3Edit.Text]); + if Fact3Combo.ItemIndex = 0 then outline := outline + ' (Fixed Levels)' else outline := outline + ' (Random Levels)'; @@ -1656,9 +1597,9 @@ begin AReport.Add(''); AReport.Add('Omega squared for combined effects = %8.3f', [Omega]); AReport.Add(''); - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 0) then AReport.Add('Note: MSErr denominator for all F ratios.'); - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 1) then begin AReport.Add('Note: Error term for A is MSAxB + MSAxC - MSAxBxC'); AReport.Add('Error term for B is MSAxB + MSBxC - MSAxBxC'); @@ -1666,7 +1607,7 @@ begin AReport.Add('Error term for AxB, AxC and BxC is MSAxBxC'); AReport.Add('Error term for AxBxC is MSErr.'); end; - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 0) then begin AReport.Add('Note: Error term for A is MSErr'); AReport.Add('Note: Error term for B is MSAxB'); @@ -1676,7 +1617,7 @@ begin AReport.Add('Note: Error term for BxC is MSAxBxC'); AReport.Add('Note: Error term for AxBxC is MSErr'); end; - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 0) then begin AReport.Add('Note: Error term for A is MSAxB'); AReport.Add('Note: Error term for B is MSErr'); @@ -1686,7 +1627,7 @@ begin AReport.Add('Note: Error term for BxC is MSErr'); AReport.Add('Note: Error term for AxBxC is MSErr'); end; - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 1) then begin AReport.Add('Note: Error term for A is MSAxC'); AReport.Add('Note: Error term for B is MSBxC'); @@ -1696,7 +1637,7 @@ begin AReport.Add('Note: Error term for BxC is MSErr'); AReport.Add('Note: Error term for AxBxC is MSErr'); end; - if (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 1) then begin AReport.Add('Note: Error term for A is MSAxC + MSAxB - MSAxBxC'); AReport.Add('Note: Error term for B is MSBxC'); @@ -1706,7 +1647,7 @@ begin AReport.Add('Note: Error term for BxC is MSErr'); AReport.Add('Note: Error term for AxBxC is MSErr'); end; - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 0) and (Fact3Grp.ItemIndex = 1) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 0) and (Fact3Combo.ItemIndex = 1) then begin AReport.Add('Note: Error term for A is MSAxC'); AReport.Add('Note: Error term for B is MSBxC + MSAxB - MSAxBxC'); @@ -1716,7 +1657,7 @@ begin AReport.Add('Note: Error term for BxC is MSAxBxC'); AReport.Add('Note: Error term for AxBxC is MSErr'); end; - if (Fact1Grp.ItemIndex = 1) and (Fact2Grp.ItemIndex = 1) and (Fact3Grp.ItemIndex = 0) then + if (Fact1Combo.ItemIndex = 1) and (Fact2Combo.ItemIndex = 1) and (Fact3Combo.ItemIndex = 0) then begin AReport.Add('Note: Error term for A is MSAxB'); AReport.Add('Note: Error term for B is MSAxB'); @@ -1729,7 +1670,9 @@ begin AReport.Add(''); for i := 1 to 10 do - if OKTerms[i] = 0 then problem := true; + if OKTerms[i] = 0 then + problem := true; + if problem then begin AReport.Add('An error occurred due to either an estimate of MS being negative'); @@ -1842,13 +1785,12 @@ var maxmean, XBar : double; plottype : integer; begin - if CompError then exit; - plottype := 2; + { if PlotMeans.Checked then plottype := 2; if Plot2DLines.Checked then plottype := 5; if Plot3DLines.Checked then plottype := 6; - + } // do Factor A first GraphFrm.SetLabels[1] := 'FACTOR A'; SetLength(GraphFrm.Xpoints,1,NF1cells); @@ -1864,8 +1806,8 @@ begin GraphFrm.nosets := 1; GraphFrm.nbars := NF1cells; - GraphFrm.Heading := Factor1.Text; - GraphFrm.XTitle := Factor1.Text + ' Codes'; + GraphFrm.Heading := Factor1Edit.Text; + GraphFrm.XTitle := Factor1Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1893,8 +1835,8 @@ begin end; GraphFrm.nosets := 1; GraphFrm.nbars := NF2cells; - GraphFrm.Heading := Factor2.Text; - GraphFrm.XTitle := Factor2.Text + ' Codes'; + GraphFrm.Heading := Factor2Edit.Text; + GraphFrm.XTitle := Factor2Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1922,8 +1864,8 @@ begin end; GraphFrm.nosets := 1; GraphFrm.nbars := NF3cells; - GraphFrm.Heading := Factor3.Text; - GraphFrm.XTitle := Factor2.Text + ' Codes'; + GraphFrm.Heading := Factor3Edit.Text; + GraphFrm.XTitle := Factor2Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1945,7 +1887,7 @@ begin maxmean := 0.0; for i := 0 to NF1cells-1 do begin - GraphFrm.SetLabels[i+1] := Factor1.Text + ' ' + IntToStr(i+1); + GraphFrm.SetLabels[i+1] := Factor1Edit.Text + ' ' + IntToStr(i+1); for j := 0 to NF2cells-1 do begin XBar := wsum[i,j,k] / ncnt[i,j,k]; @@ -1959,7 +1901,7 @@ begin GraphFrm.nosets := NF1cells; GraphFrm.nbars := NF2cells; GraphFrm.Heading := 'Factor A x Factor B Within Slice' + IntToStr(k); - GraphFrm.XTitle := Factor2.Text + ' Codes'; + GraphFrm.XTitle := Factor2Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -1982,7 +1924,7 @@ begin maxmean := 0.0; for i := 0 to NF1cells-1 do begin - GraphFrm.SetLabels[i+1] := Factor1.Text + ' ' + IntToStr(i+1); + GraphFrm.SetLabels[i+1] := Factor1Edit.Text + ' ' + IntToStr(i+1); for k := 0 to NF3cells-1 do begin XBar := wsum[i,j,k] / ncnt[i,j,k]; @@ -1996,7 +1938,7 @@ begin GraphFrm.nosets := NF1cells; GraphFrm.nbars := NF3cells; GraphFrm.Heading := 'Factor A x Factor C Within Column ' + IntToStr(j+1); - GraphFrm.XTitle := Factor3.Text + ' Codes'; + GraphFrm.XTitle := Factor3Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -2019,7 +1961,7 @@ begin maxmean := 0.0; for j := 0 to NF2cells-1 do begin - GraphFrm.SetLabels[j+1] := Factor2.Text + ' ' + IntToStr(j+1); + GraphFrm.SetLabels[j+1] := Factor2Edit.Text + ' ' + IntToStr(j+1); for k := 0 to NF3cells-1 do begin XBar := wsum[i,j,k] / ncnt[i,j,k]; @@ -2033,7 +1975,7 @@ begin GraphFrm.nosets := NF2cells; GraphFrm.nbars := NF3cells; GraphFrm.Heading := 'Factor B x Factor C Within Row ' + IntToStr(i+1); - GraphFrm.XTitle := Factor3.Text + ' Codes'; + GraphFrm.XTitle := Factor3Edit.Text + ' Codes'; GraphFrm.YTitle := 'Mean'; GraphFrm.barwideprop := 0.5; GraphFrm.AutoScaled := false; @@ -2051,7 +1993,8 @@ begin GraphFrm.Xpoints := nil; GraphFrm.Ypoints := nil; end; -//------------------------------------------------------------------- + + procedure TBlksAnovaFrm.TwoWayContrasts(AReport: TStrings); var i, j : integer; @@ -2060,15 +2003,12 @@ var RowSS, ColSS : double; begin - if CompError then - exit; - SetLength(variances, totcells); // Do row comparisons if (NF1cells > 2) then if ProbF1 < allAlpha then - if Fact2Grp.ItemIndex = 0 then + if Fact2Combo.ItemIndex = 0 then begin for i := 0 to NoGrpsA-1 do begin @@ -2101,7 +2041,7 @@ begin end; // Do column comparisons - if (NF2cells > 2) and (ProbF2 < allAlpha) and (Fact2Grp.ItemIndex = 0) then + if (NF2cells > 2) and (ProbF2 < allAlpha) and (Fact2Combo.ItemIndex = 0) then begin for j := 0 to NoGrpsB-1 do begin @@ -2132,7 +2072,7 @@ begin end; // do simple effects for columns within each row - if (ProbF3 < allAlpha) and (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) then + if (ProbF3 < allAlpha) and (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) then begin AReport.Add(''); AReport.Add('COMPARISONS AMONG COLUMNS WITHIN EACH ROW'); @@ -2168,7 +2108,7 @@ begin end; // do simple effects for rows within each column - if (ProbF3 < allAlpha) and (Fact1Grp.ItemIndex = 0) and (Fact2Grp.ItemIndex = 0) then + if (ProbF3 < allAlpha) and (Fact1Combo.ItemIndex = 0) and (Fact2Combo.ItemIndex = 0) then begin AReport.Add(''); AReport.Add('COMPARISONS AMONG ROWS WITHIN EACH COLUMN'); @@ -2207,19 +2147,16 @@ end; procedure TBlksAnovaFrm.ThreeWayContrasts(AReport: TStrings); var - i, j, k : integer; - value : double; - variances : DblDyneVec = nil; - RowSS, ColSS, SlcSS : double; - + i, j, k: integer; + value: double; + variances: DblDyneVec = nil; + RowSS, ColSS, SlcSS: double; begin - if CompError then - exit; - if (Scheffe.Checked = false) and (TukeyHSD.Checked = false) and (TukeyB.Checked = false) and (TukeyKramer.Checked = false) and (NewmanKeuls.Checked = false) and (Bonferoni.Checked = false) and (OrthoContrasts.Checked = false) then exit; + SetLength(variances,totcells); // Do row comparisons @@ -2483,7 +2420,7 @@ var sumc1: double; fdegfree: double; Fnumerator, Fdenominator, NewF: double; - X, X2: Double; + X, Xsq: Double; begin for i := 1 to 50 do begin @@ -2493,8 +2430,8 @@ begin for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); // X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); intvalue := intvalue - minf1; cellcnts[intvalue] := 0; @@ -2510,16 +2447,16 @@ begin for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); - X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); - X2 := X*X; + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); + X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); + Xsq := X*X; intvalue := intvalue - minf1; cellcnts[intvalue] := cellcnts[intvalue] + 1; cellsums[intvalue] := cellsums[intvalue] + X; - cellvars[intvalue] := cellvars[intvalue] + X2; + cellvars[intvalue] := cellvars[intvalue] + Xsq; MeanDep := MeanDep + X; - SSDep := SSDep + X2; + SSDep := SSDep + Xsq; N := N + 1; end; @@ -2554,7 +2491,7 @@ begin AReport.Add(DIVIDER); AReport.Add('BROWN-FORSYTHE ONE WAY ANALYSIS OF VARIANCE RESULTS'); AReport.Add(''); - AReport.Add('Dependent variable is: %s, Independent variable is: %s', [DepVar.Text, Factor1.Text]); + AReport.Add('Dependent variable is: %s, Independent variable is: %s', [DepVarEdit.Text, Factor1Edit.Text]); AReport.Add(''); AReport.Add('Traditional One-Way ANOVA Results'); AReport.Add(DIVIDER_SMALL); @@ -2621,7 +2558,7 @@ var barxj: array[1..50] of double; sumc1: double; fdegfree, term1, term2, term3: double; - X, X2: Double; + X, Xsq: Double; begin for i := 1 to 50 do begin @@ -2632,8 +2569,8 @@ begin for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); // X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); intvalue := intvalue - minf1; cellcnts[intvalue] := 0; @@ -2649,16 +2586,16 @@ begin for i := 1 to NoCases do begin - if not GoodRecord(i,NoSelected,ColNoSelected) then continue; - intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[F1Col,i]))); - X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[DepVarCol,i])); - X2 := X*X; + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; + intvalue := round(StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[1], i]))); + X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[0], i])); + Xsq := X*X; intvalue := intvalue - minf1; cellcnts[intvalue] := cellcnts[intvalue] + 1; cellsums[intvalue] := cellsums[intvalue] + X; - cellvars[intvalue] := cellvars[intvalue] + X2; + cellvars[intvalue] := cellvars[intvalue] + Xsq; MeanDep := MeanDep + X; - SSDep := SSDep + X2; + SSDep := SSDep + Xsq; barxj[intvalue+1] := barxj[intvalue+1] + X; N := N + 1; end; @@ -2743,8 +2680,8 @@ begin AReport.Add(DIVIDER); AReport.Add('WELCH ONE WAY ANALYSIS OF VARIANCE RESULTS'); AReport.Add(''); - AReport.Add('Dependent variable is: %s', [DepVar.Text]); - AReport.Add('Independent variable is: %s', [Factor1.Text]); + AReport.Add('Dependent variable is: %s', [DepVarEdit.Text]); + AReport.Add('Independent variable is: %s', [Factor1Edit.Text]); AReport.Add(''); { OutputFrm.RichEdit.Lines.Add('---------------------------------------------------------------------'); OutputFrm.RichEdit.Lines.Add('SOURCE D.F. SS MS F PROB.>F OMEGA SQR.'); @@ -2811,79 +2748,54 @@ begin v := round(gnu); AReport.Add('Rounded degrees of freedom: %8d', [v]); - probability := probt(t,gnu); + probability := ProbT(t, gnu); AReport.Add('Probability > t: %8.3f', [probability]); AReport.Add(''); end; end; end; + procedure TBlksAnovaFrm.UpdateBtnStates; begin - DepIn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = ''); - DepOut.Enabled := DepVar.Text <> ''; + DepIn.Enabled := (VarList.ItemIndex > -1) and (DepVarEdit.Text = ''); + DepOut.Enabled := DepVarEdit.Text <> ''; - Fact1In.Enabled := (VarList.ItemIndex > -1) and (Factor1.Text = ''); - Fact1Out.Enabled := Factor1.Text <> ''; + Fact1In.Enabled := (VarList.ItemIndex > -1) and (Factor1Edit.Text = ''); + Fact1Out.Enabled := Factor1Edit.Text <> ''; - Fact2In.Enabled := (VarList.ItemIndex > -1) and (Factor2.Text = ''); - Fact2Out.Enabled := Factor2.Text <> ''; + Fact2In.Enabled := (VarList.ItemIndex > -1) and (Factor2Edit.Text = ''); + Fact2Out.Enabled := Factor2Edit.Text <> ''; - Fact3In.Enabled := (VarList.ItemIndex > -1) and (Factor3.Text = ''); - Fact3Out.Enabled := Factor3.Text <> ''; + Fact3In.Enabled := (VarList.ItemIndex > -1) and (Factor3Edit.Text = ''); + Fact3Out.Enabled := Factor3Edit.Text <> ''; end; -procedure TBlksAnovaFrm.VarListSelectionChange(Sender: TObject; User: boolean); -begin - UpdateBtnStates; -end; -function TBlksAnovaFrm.Validate(out AMsg: String; out AControl: TWinControl; - DepVarIndex, Fact1Index, Fact2Index, Fact3Index: Integer): Boolean; +function TBlksAnovaFrm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; var a: Double; begin Result := false; - if (DepVarIndex = 0) then + if DepVarEdit.Text = '' then begin - if DepVar.Text <> '' then - begin - AMsg := 'Dependent variable not found.'; - AControl := DepVar; - end else - begin - AMsg := 'Dependent variable not specified.'; - AControl := VarList; - end; + AMsg := 'Dependent variable not specified.'; + AControl := VarList; exit; end; - if (Fact1Index = 0) then + if Factor1Edit.Text = '' then begin - if Factor1.Text <> '' then - begin - AMsg := 'Factor 1 variable not found'; - AControl := Factor1; - end else - begin - Amsg := 'Factor 1 variable not specified.'; - AControl := VarList; - end; + AMsg := 'Factor 1 variable not specified.'; + AControl := VarList; exit; end; - if (Fact2Index = 0) and (Factor2.Text <> '') then + if (Factor2Edit.Text = '') and (Factor3Edit.Text <> '') then begin - AMsg := 'Factor 2 variable not found.'; - AControl := Factor2; - exit; - end; - - if (Fact3Index = 0) and (Factor3.Text <> '') then - begin - AMsg := 'Factor3 variable not found.'; - AControl := Factor3; + AMsg := 'A two-way ANOVA needs factors 1 and 2 (not 3), a three-way analysis needs all factors.'; + AControl := VarList; exit; end; @@ -2893,9 +2805,9 @@ begin AControl := OverallAlpha; exit; end; - if not TryStrToFloat(OverallAlpha.Text, a) then + if not TryStrToFloat(OverallAlpha.Text, a) or (a <= 0) or (a >= 1) then begin - AMsg := 'Overall alpha level is not a valid number.'; + AMsg := 'Overall alpha level is not a valid number between 0 and 1.'; AControl := OverallAlpha; exit; end; @@ -2906,9 +2818,9 @@ begin AControl := PostAlpha; exit; end; - if not TryStrToFloat(PostAlpha.Text, a) then + if not TryStrToFloat(PostAlpha.Text, a) or (a <= 0) or (a >= 1) then begin - AMsg := 'Post-hoc alpha level is not a valid number.'; + AMsg := 'Post-hoc alpha level is not a valid number between 0 and 1.'; AControl := PostAlpha; exit; end; @@ -2917,8 +2829,34 @@ begin end; -initialization - {$I blkanovaunit.lrs} +procedure TBlksAnovaFrm.VarListDblClick(Sender: TObject); +var + index: Integer; + s: String; +begin + index := VarList.ItemIndex; + if index > -1 then + begin + s := VarList.Items[index]; + if DepVarEdit.Text = '' then + DepVarEdit.Text := s + else if Factor1Edit.Text = '' then + Factor1Edit.Text := s + else if Factor2Edit.Text = '' then + Factor2Edit.Text := s + else if Factor3Edit.Text = '' then + Factor3Edit.Text := s; + VarList.Items.Delete(index); + UpdateBtnStates; + end; +end; + + +procedure TBlksAnovaFrm.VarListSelectionChange(Sender: TObject; User: boolean); +begin + UpdateBtnStates; +end; + end.