diff --git a/instat/clsRegressionDefaults.vb b/instat/clsRegressionDefaults.vb index fcc166aeff4..f2b2c25e218 100644 --- a/instat/clsRegressionDefaults.vb +++ b/instat/clsRegressionDefaults.vb @@ -57,6 +57,18 @@ Public Class clsRegressionDefaults Return clsMultinomFunction End Get End Property + + Public Shared ReadOnly Property clsDefaultGLmBayesFunction As RFunction + Get + + Dim clsBayesFunction As New RFunction + + clsBayesFunction.SetRCommand("bas.lm") + clsBayesFunction.SetPackageName("BAS") + Return clsBayesFunction + End Get + End Property + Public Shared ReadOnly Property clsDefaultGlmFunction As RFunction Get @@ -105,6 +117,14 @@ Public Class clsRegressionDefaults End Get End Property + Public Shared ReadOnly Property clsDefaultConfintBas As RFunction + Get + Dim clsDefaultRConfint As New RFunction + clsDefaultRConfint.SetRCommand("confint") + Return clsDefaultRConfint + End Get + End Property + Public Shared ReadOnly Property clsDefaultRaovPValueFunction As RFunction Get Dim clsDefaultRaovpvalFunction As New RFunction diff --git a/instat/dlgOneVarFitModel.vb b/instat/dlgOneVarFitModel.vb index 473f3368c3c..1720e2436cc 100644 --- a/instat/dlgOneVarFitModel.vb +++ b/instat/dlgOneVarFitModel.vb @@ -22,12 +22,18 @@ Public Class dlgOneVarFitModel Private clsRplotFunction, clsRplotPPCompFunction, clsRplotCdfCompFunction, clsRplotQqCompFunction, clsRplotDensCompFunction As New RFunction Private clsBionomialFunction, clsProportionFunction, clsSignTestFunction, clsTtestFunction, clsWilcoxonFunction, clsZTestFunction, clsBartelFunction, clsBrFunction, clsRunsFunction, clsSenFunction, clsSerialCorrFunction, clsSnhFunction, clsAdFunction, clsCvmFunction, clsLillieFunction, clsPearsonFunction, clsSfFunction As New RFunction Private clsMeanCIFunction, clsMedianCIFunction, clsNormCIFunction, clsQuantileCIFunction, clsSdCIFunction, clsVarCIFunction As New RFunction - Private clsGetFactorLevelFunction, clsConvertToColumnTypeFunction, clsColumnNameFunction As New RFunction + Private clsGetFactorLevelFunction, clsConvertToColumnTypeFunction, clsConcatenateFunction, clsConcatenateBetaFuction, clsDummyFunction, + clsBayesInferenceFunction, clsColumnNameFunction As New RFunction + Private WithEvents ucrDistribution As ucrDistributions + Private bFirstload As Boolean = True Private bReset As Boolean = True + Private bResetFittingOptions As Boolean = False Private bResetFitModDisplay As Boolean = False + Private bResetSubdialog As Boolean = False + Private bRCodeSet As Boolean = True Private ReadOnly strSeparator As String = "---------------------" @@ -57,6 +63,11 @@ Public Class dlgOneVarFitModel Dim dctConfidence As New Dictionary(Of String, String) Dim dctQMethod As New Dictionary(Of String, String) Dim dctConfidenceInterval As New Dictionary(Of String, String) + Dim dctStatistic As New Dictionary(Of String, String) + Dim dctAlternative As New Dictionary(Of String, String) + Dim dctType As New Dictionary(Of String, String) + Dim dctCredibleLevel As New Dictionary(Of String, String) + Dim dctMethod As New Dictionary(Of String, String) Dim lstCommandButtons As New List(Of Control) ucrBase.iHelpTopicID = 296 @@ -68,8 +79,8 @@ Public Class dlgOneVarFitModel ucrPnlGeneralExactCase.AddRadioButton(rdoEstimate) ucrPnlGeneralExactCase.AddFunctionNamesCondition(rdoGeneralCase, "fitdist") - ucrPnlGeneralExactCase.AddFunctionNamesCondition(rdoTest, {"binom.test", "prop.test", "SignTest", "t.test", "wilcox.test", "ZTest", "BartelsRankTest", "br.test", "RunsTest", "sens.slope", "serialCorrelationTest", "snh.test", "ad.test", "cvm.test", "lillie.test", "pearson.test", "sf.test"}) - ucrPnlGeneralExactCase.AddFunctionNamesCondition(rdoEstimate, {"MeanCI", "MedianCI ", "normCI", "quantileCI", "sdCI", "VarCI"}) + ucrPnlGeneralExactCase.AddFunctionNamesCondition(rdoTest, {"binom.test", "prop.test", "SignTest", "t.test", "wilcox.test", "ZTest", "BartelsRankTest", "br.test", "RunsTest", "sens.slope", "serialCorrelationTest", "snh.test", "ad.test", "cvm.test", "lillie.test", "pearson.test", "sf.test", "bayes_inference"}) + ucrPnlGeneralExactCase.AddFunctionNamesCondition(rdoEstimate, {"MeanCI", "MedianCI ", "normCI", "quantileCI", "sdCI", "VarCI", "bayes_inference"}) ucrSelectorOneVarFitMod.SetParameter(New RParameter("data_name", 0)) ucrSelectorOneVarFitMod.SetParameterIsString() @@ -78,6 +89,7 @@ Public Class dlgOneVarFitModel ucrReceiverVariable.Selector = ucrSelectorOneVarFitMod ucrReceiverVariable.SetParameterIsRFunction() ucrReceiverVariable.SetMeAsReceiver() + ucrReceiverVariable.SetIncludedDataTypes({"numeric", "dates", "logical", "factor"}, bStrict:=True) ucrChkConvertVariate.SetText("Convert to Numeric") ucrChkConvertVariate.AddParameterValueFunctionNamesCondition(True, "data", "as.numeric", True) @@ -93,10 +105,10 @@ Public Class dlgOneVarFitModel ucrSaveModel.SetIsComboBox() ucrSaveModel.SetAssignToIfUncheckedValue("last_model") - ucrInputComboTests.SetItems({"binomial", "proportion", "sign", "t", "Wilcoxon", "Z", strSeparator, "Bartel", "br", "runs", "Sen", "serial corr", "snh", strSeparator, "ad", "cvm", "lillie", "pearson", "sf"}) + ucrInputComboTests.SetItems({"binomial", "proportion", "sign", "t", "Wilcoxon", "Z", strSeparator, "Bayes:Mean", "Bayes:Proportion", strSeparator, "Bartel", "br", "runs", "Sen", "serial corr", "snh", strSeparator, "ad", "cvm", "lillie", "pearson", "sf"}) ucrInputComboTests.SetDropDownStyleAsNonEditable() - ucrInputComboEstimate.SetItems({"mean", "median", "normal", "quantile", "sd", "variance"}) + ucrInputComboEstimate.SetItems({"mean", "median", "normal", "quantile", "sd", "variance", strSeparator, "bayes:mean", "bayes:proportion"}) ucrInputComboEstimate.SetDropDownStyleAsNonEditable() ucrInputMeanCIMethod.SetParameter(New RParameter("method", 3)) @@ -211,6 +223,30 @@ Public Class dlgOneVarFitModel ucrInputConfidenceInterval.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) ucrInputConfidenceInterval.bAllowNonConditionValues = True + ucrInputMethod.SetParameter(New RParameter("method", 7)) + dctMethod.Add("theoretical", Chr(34) & "theoretical" & Chr(34)) + dctMethod.Add("simulation", Chr(34) & "simulation" & Chr(34)) + ucrInputMethod.SetDropDownStyleAsNonEditable() + ucrInputMethod.SetItems(dctMethod) + ucrInputComboTests.AddToLinkedControls(ucrInputMethod, {"Bayes:Mean", "Bayes:Proportion", "bayes:mean", "bayes:proportion"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="theoretical") + ucrInputComboEstimate.AddToLinkedControls(ucrInputMethod, {"bayes:mean", "bayes:proportion"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="theoretical") + + ucrInputNullValue.SetParameter(New RParameter("null", 8)) + ucrInputNullValue.SetValidationTypeAsNumeric() + ucrInputNullValue.AddQuotesIfUnrecognised = False + ucrInputComboTests.AddToLinkedControls(ucrInputNullValue, {"Bayes:Mean", "Bayes:Proportion"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="0.0") + + ucrInputCredibleLevel.SetParameter(New RParameter("cred_level", 10)) + dctCredibleLevel.Add("0.900", "0.90") + dctCredibleLevel.Add("0.950", "0.95") + dctCredibleLevel.Add("0.980", "0.98") + dctCredibleLevel.Add("0.990", "0.99") + dctCredibleLevel.Add("0.999", "0.999") + ucrInputCredibleLevel.SetItems(dctCredibleLevel) + ucrInputCredibleLevel.AddQuotesIfUnrecognised = False + ucrInputCredibleLevel.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) + ucrInputCredibleLevel.bAllowNonConditionValues = True + ucrInputComboEstimate.AddToLinkedControls(ucrInputCredibleLevel, {"bayes:mean", "bayes:proportion"}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="0.95") ucrPnlGeneralExactCase.AddToLinkedControls(ucrInputComboTests, {rdoTest}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Binomial") ucrPnlGeneralExactCase.AddToLinkedControls(ucrInputComboEstimate, {rdoEstimate}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Mean") @@ -252,6 +288,9 @@ Public Class dlgOneVarFitModel ucrInputComboQMethod.SetLinkedDisplayControl(lblQMethod) ucrInputConfidenceInterval.SetLinkedDisplayControl(lblConfidenceLevel) ucrInputSuccess.SetLinkedDisplayControl(lblSuccess) + ucrInputMethod.SetLinkedDisplayControl(lblMethodInference) + ucrInputNullValue.SetLinkedDisplayControl(lblNullValue) + ucrInputCredibleLevel.SetLinkedDisplayControl(lblCredibleLevel) lstCommandButtons.AddRange({cmdDisplayOptions, cmdFittingOptions}) ucrDistributionChoice.SetLinkedDisplayControl(lstCommandButtons) @@ -292,7 +331,10 @@ Public Class dlgOneVarFitModel clsLillieFunction = New RFunction clsPearsonFunction = New RFunction clsSfFunction = New RFunction - + clsBayesInferenceFunction = New RFunction + clsConcatenateFunction = New RFunction + clsConcatenateBetaFuction = New RFunction + clsDummyFunction = New RFunction clsMeanCIFunction = New RFunction clsMedianCIFunction = New RFunction @@ -308,12 +350,15 @@ Public Class dlgOneVarFitModel ucrSelectorOneVarFitMod.Reset() ucrSaveModel.Reset() + ucrChkConvertVariate.Visible = False 'hide convert to numeric checkbox by default clsGetFactorLevelFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_column_factor_levels") clsConvertToColumnTypeFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$convert_column_to_type") + clsDummyFunction.AddParameter("check", "False", iPosition:=0) + clsColumnNameFunction.SetRCommand("c") 'General Case clsROneVarFitModelFunction.SetPackageName("fitdistrplus") @@ -332,7 +377,6 @@ Public Class dlgOneVarFitModel clsRConvertNumericFunction.SetRCommand("as.numeric") clsRConvertNumericFunction.AddParameter("x", clsRFunctionParameter:=clsNaExcludeFunction, iPosition:=0) - clsRConvertIntegerFunction.SetRCommand("as.integer") clsRConvertIntegerFunction.AddParameter("x", clsRFunctionParameter:=clsNaExcludeFunction, iPosition:=0) @@ -414,7 +458,6 @@ Public Class dlgOneVarFitModel clsWilcoxonFunction.SetRCommand("wilcox.test") clsWilcoxonFunction.AddParameter("mu", "0", iPosition:=1) - clsZTestFunction.SetPackageName("DescTools") clsZTestFunction.SetRCommand("ZTest") clsZTestFunction.AddParameter("sd_pop", "1", iPosition:=2) @@ -455,6 +498,26 @@ Public Class dlgOneVarFitModel clsSfFunction.SetPackageName("nortest") clsSfFunction.SetRCommand("sf.test") + clsConcatenateFunction.SetRCommand("c") + clsConcatenateFunction.AddParameter("H1", 0.5, iPosition:=0) + + clsConcatenateBetaFuction.SetRCommand("c") + clsConcatenateBetaFuction.AddParameter("a", 1, iPosition:=0) + clsConcatenateBetaFuction.AddParameter("b", 1, iPosition:=1) + + + clsBayesInferenceFunction.SetRCommand("bayes_inference") + clsBayesInferenceFunction.SetPackageName("statsr") + clsBayesInferenceFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorOneVarFitMod.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) + clsBayesInferenceFunction.AddParameter("show_plot", "FALSE", iPosition:=1) + clsBayesInferenceFunction.AddParameter("hypothesis_prior", clsRFunctionParameter:=clsConcatenateFunction, iPosition:=9) + clsBayesInferenceFunction.AddParameter("n_0", 1, iPosition:=10) + clsBayesInferenceFunction.AddParameter("s_0", 0, iPosition:=11) + clsBayesInferenceFunction.AddParameter("v_0", -1, iPosition:=12) + clsBayesInferenceFunction.AddParameter("rscale", 1, iPosition:=13) + clsBayesInferenceFunction.AddParameter("prior", Chr(34) & "JZS" & Chr(34), iPosition:=14) + clsBayesInferenceFunction.AddParameter("beta_prior", clsRFunctionParameter:=clsConcatenateBetaFuction, iPosition:=15) + 'Estimate clsMeanCIFunction.SetPackageName("DescTools") clsMeanCIFunction.SetRCommand("MeanCI") @@ -473,7 +536,6 @@ Public Class dlgOneVarFitModel clsNormCIFunction.AddParameter("R", "9999", iPosition:=5) clsNormCIFunction.AddParameter("bootci.type", Chr(34) & "all" & Chr(34), iPosition:=6) - clsQuantileCIFunction.SetPackageName("MKinfer") clsQuantileCIFunction.SetRCommand("quantileCI") clsQuantileCIFunction.AddParameter("prob", "0.5", iPosition:=1) @@ -497,6 +559,7 @@ Public Class dlgOneVarFitModel ucrBase.clsRsyntax.SetBaseRFunction(clsROneVarFitModelFunction) bResetFittingOptions = True bResetFitModDisplay = True + bResetSubdialog = True End Sub Private Sub assignToControlsChanged(ucrChangedControl As ucrCore) Handles ucrSaveModel.ControlValueChanged @@ -510,7 +573,8 @@ Public Class dlgOneVarFitModel Private Sub SetRCodeForControls(bReset As Boolean) ucrReceiverVariable.AddAdditionalCodeParameterPair(clsBionomialFunction, New RParameter("x", 0), iAdditionalPairNo:=1) ucrReceiverVariable.AddAdditionalCodeParameterPair(clsProportionFunction, New RParameter("x", 0), iAdditionalPairNo:=2) - ucrReceiverVariable.AddAdditionalCodeParameterPair(clsProportionFunction, New RParameter("col_name", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=3) + ucrReceiverVariable.AddAdditionalCodeParameterPair(clsBayesInferenceFunction, New RParameter("y", 0), iAdditionalPairNo:=3) + ucrReceiverVariable.AddAdditionalCodeParameterPair(clsProportionFunction, New RParameter("col_name", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=4) ucrChkOmitMissing.AddAdditionalCodeParameterPair(clsMedianCIFunction, ucrChkOmitMissing.GetParameter(), iAdditionalPairNo:=1) ucrChkOmitMissing.AddAdditionalCodeParameterPair(clsVarCIFunction, ucrChkOmitMissing.GetParameter(), iAdditionalPairNo:=2) ucrChkOmitMissing.AddAdditionalCodeParameterPair(clsSdCIFunction, ucrChkOmitMissing.GetParameter(), iAdditionalPairNo:=3) @@ -560,9 +624,12 @@ Public Class dlgOneVarFitModel ucrSaveModel.AddAdditionalRCode(clsSdCIFunction, iAdditionalPairNo:=21) ucrSaveModel.AddAdditionalRCode(clsVarCIFunction, iAdditionalPairNo:=22) + If bReset Then + ucrPnlGeneralExactCase.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + End If - ucrPnlGeneralExactCase.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) ucrReceiverVariable.SetRCode(clsNaExcludeFunction, bReset) + ucrChkConvertVariate.SetRCode(clsROneVarFitModelFunction, bReset) ucrChkOmitMissing.SetRCode(clsMeanCIFunction, bReset) ucrInputNullHypothesis.SetRCode(clsBionomialFunction, bReset) @@ -579,11 +646,13 @@ Public Class dlgOneVarFitModel ucrInputTxtHypothesis.SetRCode(clsSignTestFunction, bReset) ucrInputComboQMethod.SetRCode(clsQuantileCIFunction, bReset) ucrInputNulHypothesis.SetRCode(clsTtestFunction, bReset) + ucrInputMethod.SetRCode(clsBayesInferenceFunction, bReset) + ucrInputCredibleLevel.SetRCode(clsBayesInferenceFunction, bReset) + ucrInputNullValue.SetRCode(clsBayesInferenceFunction, bReset) ucrInputTextM.SetRCode(clsBrFunction) ucrSelectorOneVarFitMod.SetRCode(clsGetFactorLevelFunction, bReset) ucrSaveModel.SetRCode(clsROneVarFitModelFunction, bReset) - End Sub Private Sub TestOKEnabled() @@ -651,6 +720,28 @@ Public Class dlgOneVarFitModel sdgOneVarFitModel.ShowDialog() End Sub + Private Sub cmdPrior_Click(sender As Object, e As EventArgs) Handles cmdPrior.Click + sdgPriorParameters.SetRFunction(clsNewBayesIferenceFunction:=clsBayesInferenceFunction, + clsNewConcatenateFunction:=clsConcatenateFunction, bReset:=bResetSubdialog) + bResetSubdialog = False + sdgPriorParameters.ShowDialog() + End Sub + + Private Sub cmdEstimation_Click(sender As Object, e As EventArgs) Handles cmdEstimation.Click + sdgEstimationParameters.SetRFunction(clsNewBayesIferenceFunction:=clsBayesInferenceFunction, + clsNewConcatenateFunction:=clsConcatenateFunction, bReset:=bResetSubdialog) + bResetSubdialog = False + sdgEstimationParameters.ShowDialog() + End Sub + + Private Sub cmdProportionPrioirs_Click(sender As Object, e As EventArgs) Handles cmdProportionPrioirs.Click + sdgPriorProportions.SetRFunction(clsNewConcatenateFunction:=clsConcatenateFunction, + clsNewConcatenateBetaFuction:=clsConcatenateBetaFuction, bReset:=bResetSubdialog) + bResetSubdialog = False + sdgPriorProportions.ShowDialog() + End Sub + + Private Sub SetSaveLabelTextAndPrefix() If rdoGeneralCase.Checked Then ucrSaveModel.SetCheckBoxText("Save Model") @@ -677,6 +768,7 @@ Public Class dlgOneVarFitModel AddAsNumeric() EstimatesAsNumeric() AddFactorLevels() + PriorsVisibility() End Sub Private Sub ucrDistributions_cboDistributionsIndexChanged() Handles ucrDistributionChoice.DistributionsIndexChanged @@ -690,7 +782,9 @@ Public Class dlgOneVarFitModel End Sub Private Sub EnableDisableConvertVariate() - If ucrReceiverVariable.strCurrDataType = "numeric" Then + If ucrReceiverVariable.strCurrDataType = "numeric" OrElse + ucrInputComboTests.GetText() = "Bayes:Mean" OrElse + ucrInputComboTests.GetText() = "Bayes:Proportion" Then ucrChkConvertVariate.Checked = False ucrChkConvertVariate.Visible = False Else @@ -778,7 +872,7 @@ Public Class dlgOneVarFitModel clsBrFunction.AddParameter("x", clsRFunctionParameter:=ucrReceiverVariable.GetParameter().clsArgumentCodeStructure, iPosition:=0) Case "Sen" tttests.SetToolTip(ucrInputComboTests.cboInput, "Sen's slope for linear rate of change") - clsSenFunction.AddParameter("x", clsRFunctionParameter:=ucrReceiverVariable.GetParameter().clsArgumentCodeStructure, iPosition:=0) + clsSenFunction.AddParameter("x", clsRFunctionParameter:=ucrReceiverVariable.GetParameter().clsArgumentCodeStructure, iPosition:=0) Case "serial corr" clsSerialCorrFunction.AddParameter("x", clsRFunctionParameter:=clsRConvertVectorFunction, iPosition:=0) @@ -889,6 +983,10 @@ Public Class dlgOneVarFitModel ucrBase.clsRsyntax.SetBaseRFunction(clsPearsonFunction) Case "sf" ucrBase.clsRsyntax.SetBaseRFunction(clsSfFunction) + Case "Bayes:Mean" + ucrBase.clsRsyntax.SetBaseRFunction(clsBayesInferenceFunction) + Case "Bayes:Proportion" + ucrBase.clsRsyntax.SetBaseRFunction(clsBayesInferenceFunction) End Select ElseIf rdoEstimate.Checked Then @@ -906,6 +1004,10 @@ Public Class dlgOneVarFitModel ucrBase.clsRsyntax.SetBaseRFunction(clsSdCIFunction) Case "variance" ucrBase.clsRsyntax.SetBaseRFunction(clsVarCIFunction) + Case "bayes:mean" + ucrBase.clsRsyntax.SetBaseRFunction(clsBayesInferenceFunction) + Case "bayes:proportion" + ucrBase.clsRsyntax.SetBaseRFunction(clsBayesInferenceFunction) Case Else MsgBox("Developer error: there is no Estimate called" & Chr(34) & ucrInputComboEstimate.GetValue() & Chr(34) & vbNewLine & "Default Estimate will be selected.") End Select @@ -921,15 +1023,22 @@ Public Class dlgOneVarFitModel End If Dim bDatatype As Boolean = ucrReceiverVariable.strCurrDataType.ToLower = "logical" Or ucrReceiverVariable.strCurrDataType.ToLower = "factor" - Dim bTest As Boolean = ucrInputComboTests.GetText() = "binomial" Or ucrInputComboTests.GetText() = "proportion" + Dim bTest As Boolean = ucrInputComboTests.GetText() = "binomial" Dim bTypeIsNumeric As Boolean = ucrReceiverVariable.strCurrDataType.ToLower = "numeric" If Not ucrReceiverVariable.IsEmpty AndAlso rdoTest.Checked AndAlso (bDatatype OrElse bTypeIsNumeric) AndAlso bTest Then FindLevels() + ElseIf Not ucrReceiverVariable.IsEmpty AndAlso rdoEstimate.Checked AndAlso ucrInputComboEstimate.GetText() = "bayes:proportion" AndAlso + (bDatatype) Then + FindLevels() + ElseIf Not ucrReceiverVariable.IsEmpty AndAlso rdoTest.Checked AndAlso ucrInputComboTests.GetText() = "Bayes:Proportion" AndAlso + (bDatatype) Then + FindLevels() Else ucrInputSuccess.Visible = False clsBionomialFunction.RemoveParameterByName("success") clsProportionFunction.RemoveParameterByName("success") + clsBayesInferenceFunction.RemoveParameterByName("success") End If End Sub @@ -970,8 +1079,6 @@ Public Class dlgOneVarFitModel ucrInputSuccess.SetText(lstFactor(0)) ucrInputSuccess.Visible = True End If - - End Sub Private Sub ucrInputTests_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputComboTests.ControlValueChanged, ucrInputComboEstimate.ControlValueChanged @@ -980,6 +1087,11 @@ Public Class dlgOneVarFitModel AddAsNumeric() EstimatesAsNumeric() AddFactorLevels() + SampleStatistic() + TypeStatistic() + CredibleInterval() + EnableDisableConvertVariate() + PriorsVisibility() If ucrInputComboTests.GetText = strSeparator Then ucrInputComboTests.cboInput.SelectedIndex = 0 End If @@ -993,6 +1105,71 @@ Public Class dlgOneVarFitModel If ucrInputSuccess.Visible Then clsBionomialFunction.AddParameter("success", ucrInputSuccess.GetText(), iPosition:=4) clsProportionFunction.AddParameter("success", ucrInputSuccess.GetText(), iPosition:=4) + clsBayesInferenceFunction.AddParameter("success", ucrInputSuccess.GetText(), iPosition:=3) + Else + clsBayesInferenceFunction.RemoveParameterByName("success") + clsBionomialFunction.RemoveParameterByName("success") + clsProportionFunction.RemoveParameterByName("success") + End If + CredibleInterval() + SampleStatistic() + End Sub + + Private Sub SampleStatistic() + If ucrInputComboTests.GetText() = "Bayes:Mean" Then + clsBayesInferenceFunction.AddParameter("statistic", Chr(34) & "mean" & Chr(34), iPosition:=4) + clsBayesInferenceFunction.AddParameter("alternative", Chr(34) & "twosided" & Chr(34), iPosition:=5) + ucrInputNullValue.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=Integer.MaxValue, bIncludeMax:=True) + + ElseIf ucrInputComboTests.GetText() = "Bayes:Proportion" Then + ucrInputNullValue.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) + clsBayesInferenceFunction.AddParameter("statistic", Chr(34) & "proportion" & Chr(34), iPosition:=4) + clsBayesInferenceFunction.AddParameter("alternative", Chr(34) & "twosided" & Chr(34), iPosition:=5) End If End Sub + + Private Sub TypeStatistic() + If rdoTest.Checked Then + If ucrInputComboTests.GetText() = "Bayes:Mean" OrElse ucrInputComboTests.GetText() = "Bayes:Proportion" Then + clsBayesInferenceFunction.AddParameter("type", Chr(34) & "ht" & Chr(34), iPosition:=6) + Else + clsBayesInferenceFunction.RemoveParameterByName("type") + End If + ElseIf rdoEstimate.Checked Then + If ucrInputComboEstimate.GetText() = "bayes:mean" OrElse ucrInputComboEstimate.GetText() = "bayes:proportion" Then + clsBayesInferenceFunction.AddParameter("type", Chr(34) & "ci" & Chr(34), iPosition:=6) + clsBayesInferenceFunction.AddParameter("mu_0", 0, iPosition:=15) + Else + clsBayesInferenceFunction.RemoveParameterByName("mu_0") + clsBayesInferenceFunction.RemoveParameterByName("type") + End If + End If + End Sub + + Private Sub CredibleInterval() + If ucrInputComboEstimate.GetText() = "bayes:mean" Then + clsBayesInferenceFunction.AddParameter("statistic", Chr(34) & "mean" & Chr(34), iPosition:=4) + ElseIf ucrInputComboEstimate.GetText() = "bayes:proportion" Then + clsBayesInferenceFunction.AddParameter("statistic", Chr(34) & "proportion" & Chr(34), iPosition:=4) + End If + End Sub + + Private Sub PriorsVisibility() + cmdPrior.Visible = rdoTest.Checked AndAlso ( + ucrInputComboTests.GetText() = "Bayes:Mean") + 'ucrInputComboTests.GetText() = "Bayes:Proportion") + cmdEstimation.Visible = rdoEstimate.Checked AndAlso ( + ucrInputComboEstimate.GetText() = "bayes:mean") + 'ucrInputComboEstimate.GetText() = "bayes:proportion") + cmdProportionPrioirs.Visible = rdoTest.Checked AndAlso ( + ucrInputComboTests.GetText() = "Bayes:Proportion") OrElse + rdoEstimate.Checked AndAlso ( + ucrInputComboEstimate.GetText() = "bayes:proportion") + + End Sub + + Private Sub ucrInputNullValue_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputNullValue.ControlValueChanged + TypeStatistic() + CredibleInterval() + End Sub End Class diff --git a/instat/dlgOneVarFitModel2.Designer.vb b/instat/dlgOneVarFitModel2.Designer.vb index 8aed92c8e7c..3f3b8b2186b 100644 --- a/instat/dlgOneVarFitModel2.Designer.vb +++ b/instat/dlgOneVarFitModel2.Designer.vb @@ -64,6 +64,13 @@ Partial Class dlgOneVarFitModel Me.lblConfidenceLevel = New System.Windows.Forms.Label() Me.tttests = New System.Windows.Forms.ToolTip(Me.components) Me.lblSuccess = New System.Windows.Forms.Label() + Me.lblMethodInference = New System.Windows.Forms.Label() + Me.lblNullValue = New System.Windows.Forms.Label() + Me.lblCredibleLevel = New System.Windows.Forms.Label() + Me.cmdPrior = New System.Windows.Forms.Button() + Me.cmdEstimation = New System.Windows.Forms.Button() + Me.ucrInputCredibleLevel = New instat.ucrInputComboBox() + Me.ucrInputMethod = New instat.ucrInputComboBox() Me.ucrInputSuccess = New instat.ucrInputComboBox() Me.ucrInputConfidenceInterval = New instat.ucrInputComboBox() Me.ucrInputComboQMethod = New instat.ucrInputComboBox() @@ -90,6 +97,8 @@ Partial Class dlgOneVarFitModel Me.ucrReceiverVariable = New instat.ucrReceiverSingle() Me.ucrSelectorOneVarFitMod = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() + Me.ucrInputNullValue = New instat.ucrInputTextBox() + Me.cmdProportionPrioirs = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'LblVariable @@ -133,7 +142,7 @@ Partial Class dlgOneVarFitModel ' 'cmdDisplayOptions ' - Me.cmdDisplayOptions.Location = New System.Drawing.Point(295, 323) + Me.cmdDisplayOptions.Location = New System.Drawing.Point(295, 331) Me.cmdDisplayOptions.Name = "cmdDisplayOptions" Me.cmdDisplayOptions.Size = New System.Drawing.Size(127, 23) Me.cmdDisplayOptions.TabIndex = 44 @@ -142,7 +151,7 @@ Partial Class dlgOneVarFitModel ' 'cmdFittingOptions ' - Me.cmdFittingOptions.Location = New System.Drawing.Point(295, 298) + Me.cmdFittingOptions.Location = New System.Drawing.Point(295, 306) Me.cmdFittingOptions.Name = "cmdFittingOptions" Me.cmdFittingOptions.Size = New System.Drawing.Size(127, 23) Me.cmdFittingOptions.TabIndex = 43 @@ -325,19 +334,88 @@ Partial Class dlgOneVarFitModel 'lblSuccess ' Me.lblSuccess.AutoSize = True - Me.lblSuccess.Location = New System.Drawing.Point(232, 229) + Me.lblSuccess.Location = New System.Drawing.Point(273, 229) Me.lblSuccess.Name = "lblSuccess" Me.lblSuccess.Size = New System.Drawing.Size(51, 13) Me.lblSuccess.TabIndex = 87 Me.lblSuccess.Text = "Success:" ' + 'lblMethodInference + ' + Me.lblMethodInference.AutoSize = True + Me.lblMethodInference.Location = New System.Drawing.Point(278, 197) + Me.lblMethodInference.Name = "lblMethodInference" + Me.lblMethodInference.Size = New System.Drawing.Size(46, 13) + Me.lblMethodInference.TabIndex = 105 + Me.lblMethodInference.Text = "Method:" + ' + 'lblNullValue + ' + Me.lblNullValue.AutoSize = True + Me.lblNullValue.Location = New System.Drawing.Point(266, 254) + Me.lblNullValue.Name = "lblNullValue" + Me.lblNullValue.Size = New System.Drawing.Size(58, 13) + Me.lblNullValue.TabIndex = 109 + Me.lblNullValue.Text = "Null Value:" + ' + 'lblCredibleLevel + ' + Me.lblCredibleLevel.AutoSize = True + Me.lblCredibleLevel.Location = New System.Drawing.Point(247, 144) + Me.lblCredibleLevel.Name = "lblCredibleLevel" + Me.lblCredibleLevel.Size = New System.Drawing.Size(77, 13) + Me.lblCredibleLevel.TabIndex = 115 + Me.lblCredibleLevel.Text = "Credible Level:" + ' + 'cmdPrior + ' + Me.cmdPrior.Location = New System.Drawing.Point(324, 164) + Me.cmdPrior.Name = "cmdPrior" + Me.cmdPrior.Size = New System.Drawing.Size(101, 23) + Me.cmdPrior.TabIndex = 117 + Me.cmdPrior.Text = "Hypothesis Priors" + Me.cmdPrior.UseVisualStyleBackColor = True + ' + 'cmdEstimation + ' + Me.cmdEstimation.Location = New System.Drawing.Point(324, 165) + Me.cmdEstimation.Name = "cmdEstimation" + Me.cmdEstimation.Size = New System.Drawing.Size(100, 23) + Me.cmdEstimation.TabIndex = 118 + Me.cmdEstimation.Text = "Estimation Priors" + Me.cmdEstimation.UseVisualStyleBackColor = True + ' + 'ucrInputCredibleLevel + ' + Me.ucrInputCredibleLevel.AddQuotesIfUnrecognised = True + Me.ucrInputCredibleLevel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputCredibleLevel.GetSetSelectedIndex = -1 + Me.ucrInputCredibleLevel.IsReadOnly = False + Me.ucrInputCredibleLevel.Location = New System.Drawing.Point(326, 140) + Me.ucrInputCredibleLevel.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputCredibleLevel.Name = "ucrInputCredibleLevel" + Me.ucrInputCredibleLevel.Size = New System.Drawing.Size(71, 21) + Me.ucrInputCredibleLevel.TabIndex = 116 + ' + 'ucrInputMethod + ' + Me.ucrInputMethod.AddQuotesIfUnrecognised = True + Me.ucrInputMethod.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputMethod.GetSetSelectedIndex = -1 + Me.ucrInputMethod.IsReadOnly = False + Me.ucrInputMethod.Location = New System.Drawing.Point(326, 193) + Me.ucrInputMethod.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputMethod.Name = "ucrInputMethod" + Me.ucrInputMethod.Size = New System.Drawing.Size(94, 21) + Me.ucrInputMethod.TabIndex = 104 + ' 'ucrInputSuccess ' Me.ucrInputSuccess.AddQuotesIfUnrecognised = True Me.ucrInputSuccess.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputSuccess.GetSetSelectedIndex = -1 Me.ucrInputSuccess.IsReadOnly = False - Me.ucrInputSuccess.Location = New System.Drawing.Point(350, 225) + Me.ucrInputSuccess.Location = New System.Drawing.Point(326, 225) Me.ucrInputSuccess.Margin = New System.Windows.Forms.Padding(5) Me.ucrInputSuccess.Name = "ucrInputSuccess" Me.ucrInputSuccess.Size = New System.Drawing.Size(71, 21) @@ -619,18 +697,45 @@ Partial Class dlgOneVarFitModel ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(10, 353) + Me.ucrBase.Location = New System.Drawing.Point(10, 361) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(405, 52) + Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 0 ' + 'ucrInputNullValue + ' + Me.ucrInputNullValue.AddQuotesIfUnrecognised = True + Me.ucrInputNullValue.AutoSize = True + Me.ucrInputNullValue.IsMultiline = False + Me.ucrInputNullValue.IsReadOnly = False + Me.ucrInputNullValue.Location = New System.Drawing.Point(326, 251) + Me.ucrInputNullValue.Name = "ucrInputNullValue" + Me.ucrInputNullValue.Size = New System.Drawing.Size(92, 21) + Me.ucrInputNullValue.TabIndex = 114 + ' + 'cmdProportionPrioirs + ' + Me.cmdProportionPrioirs.Location = New System.Drawing.Point(325, 164) + Me.cmdProportionPrioirs.Name = "cmdProportionPrioirs" + Me.cmdProportionPrioirs.Size = New System.Drawing.Size(101, 23) + Me.cmdProportionPrioirs.TabIndex = 119 + Me.cmdProportionPrioirs.Text = "Proportion Prioirs" + Me.cmdProportionPrioirs.UseVisualStyleBackColor = True + ' 'dlgOneVarFitModel ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(428, 420) + Me.ClientSize = New System.Drawing.Size(428, 422) + Me.Controls.Add(Me.cmdProportionPrioirs) + Me.Controls.Add(Me.cmdPrior) + Me.Controls.Add(Me.ucrInputCredibleLevel) + Me.Controls.Add(Me.lblCredibleLevel) + Me.Controls.Add(Me.lblNullValue) + Me.Controls.Add(Me.lblMethodInference) + Me.Controls.Add(Me.ucrInputMethod) Me.Controls.Add(Me.ucrInputSuccess) Me.Controls.Add(Me.ucrInputConfidenceInterval) Me.Controls.Add(Me.ucrInputComboQMethod) @@ -681,6 +786,8 @@ Partial Class dlgOneVarFitModel Me.Controls.Add(Me.lblNullHyp) Me.Controls.Add(Me.lblSuccess) Me.Controls.Add(Me.lblQMethod) + Me.Controls.Add(Me.ucrInputNullValue) + Me.Controls.Add(Me.cmdEstimation) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False @@ -744,4 +851,13 @@ Partial Class dlgOneVarFitModel Friend WithEvents tttests As ToolTip Friend WithEvents ucrInputSuccess As ucrInputComboBox Friend WithEvents lblSuccess As Label + Friend WithEvents lblMethodInference As Label + Friend WithEvents ucrInputMethod As ucrInputComboBox + Friend WithEvents lblNullValue As Label + Friend WithEvents ucrInputNullValue As ucrInputTextBox + Friend WithEvents ucrInputCredibleLevel As ucrInputComboBox + Friend WithEvents lblCredibleLevel As Label + Friend WithEvents cmdPrior As Button + Friend WithEvents cmdEstimation As Button + Friend WithEvents cmdProportionPrioirs As Button End Class \ No newline at end of file diff --git a/instat/dlgTwoVariableFitModel.Designer.vb b/instat/dlgTwoVariableFitModel.Designer.vb index 8242868d3c1..492d10f751e 100644 --- a/instat/dlgTwoVariableFitModel.Designer.vb +++ b/instat/dlgTwoVariableFitModel.Designer.vb @@ -55,6 +55,15 @@ Partial Class dlgTwoVariableFitModel Me.lblFirstVariableType = New System.Windows.Forms.Label() Me.cmdExplanatoryFunction = New System.Windows.Forms.Button() Me.lblSecondVariableType = New System.Windows.Forms.Label() + Me.lblConfidenceLevel = New System.Windows.Forms.Label() + Me.lblNullHypothesis = New System.Windows.Forms.Label() + Me.lblType = New System.Windows.Forms.Label() + Me.lblSuccess = New System.Windows.Forms.Label() + Me.lblMethodInference = New System.Windows.Forms.Label() + Me.lblCredibleLevel = New System.Windows.Forms.Label() + Me.cmdPrior = New System.Windows.Forms.Button() + Me.cmdEstimation = New System.Windows.Forms.Button() + Me.ucrInputCredibleLevel = New instat.ucrInputComboBox() Me.ucrDistributionChoice = New instat.ucrDistributions() Me.ucrInputTest = New instat.ucrInputComboBox() Me.ucrTryModelling = New instat.ucrTry() @@ -66,10 +75,12 @@ Partial Class dlgTwoVariableFitModel Me.ucrPnlModelType = New instat.UcrPanel() Me.ucrModelPreview = New instat.ucrInputTextBox() Me.ucrBase = New instat.ucrButtons() - Me.ucrInputConfidenceInterval = New instat.ucrInputComboBox() - Me.lblConfidenceLevel = New System.Windows.Forms.Label() + Me.ucrInputType = New instat.ucrInputComboBox() + Me.ucrInputSuccess = New instat.ucrInputComboBox() Me.ucrInputNullHypothesis = New instat.ucrInputTextBox() - Me.lblNullHypothesis = New System.Windows.Forms.Label() + Me.ucrInputConfidenceInterval = New instat.ucrInputComboBox() + Me.ucrInputMethod = New instat.ucrInputComboBox() + Me.cmdProprtionPriors = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'lblResidualMsg @@ -242,6 +253,90 @@ Partial Class dlgTwoVariableFitModel Me.lblSecondVariableType.Size = New System.Drawing.Size(0, 13) Me.lblSecondVariableType.TabIndex = 26 ' + 'lblConfidenceLevel + ' + Me.lblConfidenceLevel.AutoSize = True + Me.lblConfidenceLevel.Location = New System.Drawing.Point(238, 237) + Me.lblConfidenceLevel.Name = "lblConfidenceLevel" + Me.lblConfidenceLevel.Size = New System.Drawing.Size(93, 13) + Me.lblConfidenceLevel.TabIndex = 87 + Me.lblConfidenceLevel.Text = "Confidence Level:" + ' + 'lblNullHypothesis + ' + Me.lblNullHypothesis.AutoSize = True + Me.lblNullHypothesis.Location = New System.Drawing.Point(238, 268) + Me.lblNullHypothesis.Name = "lblNullHypothesis" + Me.lblNullHypothesis.Size = New System.Drawing.Size(83, 13) + Me.lblNullHypothesis.TabIndex = 89 + Me.lblNullHypothesis.Text = "Null Hypothesis:" + ' + 'lblType + ' + Me.lblType.AutoSize = True + Me.lblType.Location = New System.Drawing.Point(227, 298) + Me.lblType.Name = "lblType" + Me.lblType.Size = New System.Drawing.Size(94, 13) + Me.lblType.TabIndex = 95 + Me.lblType.Text = "Type of Inference:" + ' + 'lblSuccess + ' + Me.lblSuccess.AutoSize = True + Me.lblSuccess.Location = New System.Drawing.Point(271, 271) + Me.lblSuccess.Name = "lblSuccess" + Me.lblSuccess.Size = New System.Drawing.Size(51, 13) + Me.lblSuccess.TabIndex = 97 + Me.lblSuccess.Text = "Success:" + ' + 'lblMethodInference + ' + Me.lblMethodInference.AutoSize = True + Me.lblMethodInference.Location = New System.Drawing.Point(274, 243) + Me.lblMethodInference.Name = "lblMethodInference" + Me.lblMethodInference.Size = New System.Drawing.Size(46, 13) + Me.lblMethodInference.TabIndex = 99 + Me.lblMethodInference.Text = "Method:" + ' + 'lblCredibleLevel + ' + Me.lblCredibleLevel.AutoSize = True + Me.lblCredibleLevel.Location = New System.Drawing.Point(245, 323) + Me.lblCredibleLevel.Name = "lblCredibleLevel" + Me.lblCredibleLevel.Size = New System.Drawing.Size(77, 13) + Me.lblCredibleLevel.TabIndex = 117 + Me.lblCredibleLevel.Text = "Credible Level:" + ' + 'cmdPrior + ' + Me.cmdPrior.Location = New System.Drawing.Point(322, 209) + Me.cmdPrior.Name = "cmdPrior" + Me.cmdPrior.Size = New System.Drawing.Size(105, 23) + Me.cmdPrior.TabIndex = 119 + Me.cmdPrior.Text = "Hypothesis Priors" + Me.cmdPrior.UseVisualStyleBackColor = True + ' + 'cmdEstimation + ' + Me.cmdEstimation.Location = New System.Drawing.Point(322, 208) + Me.cmdEstimation.Name = "cmdEstimation" + Me.cmdEstimation.Size = New System.Drawing.Size(95, 23) + Me.cmdEstimation.TabIndex = 120 + Me.cmdEstimation.Text = "Estimation Priors" + Me.cmdEstimation.UseVisualStyleBackColor = True + ' + 'ucrInputCredibleLevel + ' + Me.ucrInputCredibleLevel.AddQuotesIfUnrecognised = True + Me.ucrInputCredibleLevel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputCredibleLevel.GetSetSelectedIndex = -1 + Me.ucrInputCredibleLevel.IsReadOnly = False + Me.ucrInputCredibleLevel.Location = New System.Drawing.Point(324, 319) + Me.ucrInputCredibleLevel.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputCredibleLevel.Name = "ucrInputCredibleLevel" + Me.ucrInputCredibleLevel.Size = New System.Drawing.Size(106, 21) + Me.ucrInputCredibleLevel.TabIndex = 118 + ' 'ucrDistributionChoice ' Me.ucrDistributionChoice.AutoSize = True @@ -351,49 +446,76 @@ Partial Class dlgTwoVariableFitModel Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrBase.Location = New System.Drawing.Point(10, 449) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(405, 52) + Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 17 ' + 'ucrInputType + ' + Me.ucrInputType.AddQuotesIfUnrecognised = True + Me.ucrInputType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputType.GetSetSelectedIndex = -1 + Me.ucrInputType.IsReadOnly = False + Me.ucrInputType.Location = New System.Drawing.Point(324, 294) + Me.ucrInputType.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputType.Name = "ucrInputType" + Me.ucrInputType.Size = New System.Drawing.Size(106, 21) + Me.ucrInputType.TabIndex = 94 + ' + 'ucrInputSuccess + ' + Me.ucrInputSuccess.AddQuotesIfUnrecognised = True + Me.ucrInputSuccess.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputSuccess.GetSetSelectedIndex = -1 + Me.ucrInputSuccess.IsReadOnly = False + Me.ucrInputSuccess.Location = New System.Drawing.Point(324, 267) + Me.ucrInputSuccess.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputSuccess.Name = "ucrInputSuccess" + Me.ucrInputSuccess.Size = New System.Drawing.Size(106, 21) + Me.ucrInputSuccess.TabIndex = 116 + ' + 'ucrInputNullHypothesis + ' + Me.ucrInputNullHypothesis.AddQuotesIfUnrecognised = True + Me.ucrInputNullHypothesis.AutoSize = True + Me.ucrInputNullHypothesis.IsMultiline = False + Me.ucrInputNullHypothesis.IsReadOnly = False + Me.ucrInputNullHypothesis.Location = New System.Drawing.Point(336, 262) + Me.ucrInputNullHypothesis.Name = "ucrInputNullHypothesis" + Me.ucrInputNullHypothesis.Size = New System.Drawing.Size(94, 22) + Me.ucrInputNullHypothesis.TabIndex = 88 + ' 'ucrInputConfidenceInterval ' Me.ucrInputConfidenceInterval.AddQuotesIfUnrecognised = True Me.ucrInputConfidenceInterval.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputConfidenceInterval.GetSetSelectedIndex = -1 Me.ucrInputConfidenceInterval.IsReadOnly = False - Me.ucrInputConfidenceInterval.Location = New System.Drawing.Point(336, 233) + Me.ucrInputConfidenceInterval.Location = New System.Drawing.Point(336, 234) Me.ucrInputConfidenceInterval.Margin = New System.Windows.Forms.Padding(5) Me.ucrInputConfidenceInterval.Name = "ucrInputConfidenceInterval" Me.ucrInputConfidenceInterval.Size = New System.Drawing.Size(94, 21) Me.ucrInputConfidenceInterval.TabIndex = 86 ' - 'lblConfidenceLevel + 'ucrInputMethod ' - Me.lblConfidenceLevel.AutoSize = True - Me.lblConfidenceLevel.Location = New System.Drawing.Point(238, 237) - Me.lblConfidenceLevel.Name = "lblConfidenceLevel" - Me.lblConfidenceLevel.Size = New System.Drawing.Size(93, 13) - Me.lblConfidenceLevel.TabIndex = 87 - Me.lblConfidenceLevel.Text = "Confidence Level:" - ' - 'ucrInputNullHypothesis - ' - Me.ucrInputNullHypothesis.AddQuotesIfUnrecognised = True - Me.ucrInputNullHypothesis.AutoSize = True - Me.ucrInputNullHypothesis.IsMultiline = False - Me.ucrInputNullHypothesis.IsReadOnly = False - Me.ucrInputNullHypothesis.Location = New System.Drawing.Point(336, 262) - Me.ucrInputNullHypothesis.Name = "ucrInputNullHypothesis" - Me.ucrInputNullHypothesis.Size = New System.Drawing.Size(94, 22) - Me.ucrInputNullHypothesis.TabIndex = 88 + Me.ucrInputMethod.AddQuotesIfUnrecognised = True + Me.ucrInputMethod.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputMethod.GetSetSelectedIndex = -1 + Me.ucrInputMethod.IsReadOnly = False + Me.ucrInputMethod.Location = New System.Drawing.Point(324, 237) + Me.ucrInputMethod.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputMethod.Name = "ucrInputMethod" + Me.ucrInputMethod.Size = New System.Drawing.Size(106, 21) + Me.ucrInputMethod.TabIndex = 98 ' - 'lblNullHypothesis + 'cmdProprtionPriors ' - Me.lblNullHypothesis.AutoSize = True - Me.lblNullHypothesis.Location = New System.Drawing.Point(238, 265) - Me.lblNullHypothesis.Name = "lblNullHypothesis" - Me.lblNullHypothesis.Size = New System.Drawing.Size(83, 13) - Me.lblNullHypothesis.TabIndex = 89 - Me.lblNullHypothesis.Text = "Null Hypothesis:" + Me.cmdProprtionPriors.Location = New System.Drawing.Point(322, 209) + Me.cmdProprtionPriors.Name = "cmdProprtionPriors" + Me.cmdProprtionPriors.Size = New System.Drawing.Size(105, 23) + Me.cmdProprtionPriors.TabIndex = 121 + Me.cmdProprtionPriors.Text = "Proportion Priors" + Me.cmdProprtionPriors.UseVisualStyleBackColor = True ' 'dlgTwoVariableFitModel ' @@ -401,10 +523,9 @@ Partial Class dlgTwoVariableFitModel Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.ClientSize = New System.Drawing.Size(462, 510) - Me.Controls.Add(Me.lblNullHypothesis) - Me.Controls.Add(Me.ucrInputNullHypothesis) - Me.Controls.Add(Me.lblConfidenceLevel) - Me.Controls.Add(Me.ucrInputConfidenceInterval) + Me.Controls.Add(Me.cmdProprtionPriors) + Me.Controls.Add(Me.ucrInputCredibleLevel) + Me.Controls.Add(Me.lblCredibleLevel) Me.Controls.Add(Me.lblSecondVariableType) Me.Controls.Add(Me.lblFirstVariableType) Me.Controls.Add(Me.ucrDistributionChoice) @@ -429,6 +550,18 @@ Partial Class dlgTwoVariableFitModel Me.Controls.Add(Me.lblFirstVariable) Me.Controls.Add(Me.lblSecondVariable) Me.Controls.Add(Me.lblTest) + Me.Controls.Add(Me.ucrInputType) + Me.Controls.Add(Me.lblSuccess) + Me.Controls.Add(Me.lblConfidenceLevel) + Me.Controls.Add(Me.lblType) + Me.Controls.Add(Me.lblNullHypothesis) + Me.Controls.Add(Me.ucrInputSuccess) + Me.Controls.Add(Me.ucrInputNullHypothesis) + Me.Controls.Add(Me.ucrInputConfidenceInterval) + Me.Controls.Add(Me.ucrInputMethod) + Me.Controls.Add(Me.lblMethodInference) + Me.Controls.Add(Me.cmdPrior) + Me.Controls.Add(Me.cmdEstimation) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.HelpButton = True Me.MaximizeBox = False @@ -475,4 +608,15 @@ Partial Class dlgTwoVariableFitModel Friend WithEvents lblConfidenceLevel As Label Friend WithEvents ucrInputNullHypothesis As ucrInputTextBox Friend WithEvents lblNullHypothesis As Label + Friend WithEvents lblType As Label + Friend WithEvents ucrInputType As ucrInputComboBox + Friend WithEvents lblSuccess As Label + Friend WithEvents lblMethodInference As Label + Friend WithEvents ucrInputMethod As ucrInputComboBox + Friend WithEvents ucrInputSuccess As ucrInputComboBox + Friend WithEvents ucrInputCredibleLevel As ucrInputComboBox + Friend WithEvents lblCredibleLevel As Label + Friend WithEvents cmdPrior As Button + Friend WithEvents cmdEstimation As Button + Friend WithEvents cmdProprtionPriors As Button End Class \ No newline at end of file diff --git a/instat/dlgTwoVariableFitModel.vb b/instat/dlgTwoVariableFitModel.vb index 029f31c2e1d..38def8ddd51 100644 --- a/instat/dlgTwoVariableFitModel.vb +++ b/instat/dlgTwoVariableFitModel.vb @@ -31,10 +31,11 @@ Public Class dlgTwoVariableFitModel 'Tests Private clsNumericTtestFunction, clsTtestFunction, clsNumericWilcoxTestFunction, clsWilcoxTestFunction, clsNumericVarTestFunction, clsVarTestFunction, clsAnsariTestFunction, clsNumericAnsariTestFuntion, - clsMoodTestFunction, clsNumericMoodTestFunction, clsCorTestFunction, clsKruskalTestFunction, + clsMoodTestFunction, clsNumericMoodTestFunction, clsCorTestFunction, clsKruskalTestFunction, clsConcatenateFunction, clsConcatenateBetaFuction, clsNumericKruskalTestFunction, clsOnewayTestFunction, clsBarletteTestFunction, clsNumericBarletteTestFunction, clsMcnemarTestFunction, clsFlignerTestFunction, clsNumericFlignerTestFunction, clsFisherTestFunction, - clsXchisgTestFunction, clsPropTestFunction As New RFunction + clsXchisgTestFunction, clsPropTestFunction, clsConvertToColumnTypeFunction, clsGetFactorLevelFunction, + clsConfintBas, clsBayesInferenceFunction, clsColumnNameFunction As New RFunction Private clsTtestOperator, clsWilcoxTestOperator, clsVarTestOperator, clsAnsariTestOperator, clsMoodTestOperator, clsKruskalTestOperator, clsBarletteTestOperator, @@ -44,7 +45,9 @@ Public Class dlgTwoVariableFitModel 'General case codes Private clsFormulaOperator As New ROperator - Private clsGLM, clsLM, clsLMOrGLM, clsAsNumeric, clsPolynomialFunc As New RFunction + Private clsGLM, clsLM, clsGLMNB, clsLMOrGLM, clsAsNumeric, clsPolynomialFunc, clsGLMBayes As New RFunction + + Private clsMonthFunc, clsYearFunc, clsAsFactorFunc As New RFunction Private clsAttach As New RFunction Private clsDetach As New RFunction @@ -53,16 +56,21 @@ Public Class dlgTwoVariableFitModel Private clsRstandardFunction, clsHatvaluesFunction, clsResidualFunction, clsFittedValuesFunction As New RFunction 'Display options codes - Public clsFormulaFunction, clsAnovaFunction, clsSummaryFunction, clsConfint As New RFunction + Public clsFormulaFunction, clsAnovaFunction, clsSummaryFunction, clsConfint, clsConfintBasFunction, clsCoefFunction As New RFunction + + 'Public clsFormulaFunction, clsAnovaFunction, clsSummaryFunction, clsConfint As New RFunction - Private bRCodeSet As Boolean + + Private bRCodeSet As Boolean = True Private bReset As Boolean = True Public bResetOptionsSubDialog As Boolean = False Public bResetFirstFunction As Boolean = False + Private bResetSubdialog As Boolean = False + Private dctPlotFunctions As New Dictionary(Of String, RFunction) Public StrMedianValue As String = "" - Private Sub dlgTwoVariableFitModel_Load(sender As Object, e As EventArgs) Handles Me.Load + Private Sub dlgTwoVariableFitModel_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then InitialiseDialog() bFirstLoad = False @@ -78,6 +86,10 @@ Public Class dlgTwoVariableFitModel Private Sub InitialiseDialog() Dim dctConfidenceInterval As New Dictionary(Of String, String) + Dim dctStatistic As New Dictionary(Of String, String) + Dim dctType As New Dictionary(Of String, String) + Dim dctMethod As New Dictionary(Of String, String) + Dim dctCredibleLevel As New Dictionary(Of String, String) Dim lstControl As New List(Of Control)(New Control() {lblTest, lblFirstVariable, lblFirstVariableType, lblSecondVariable, lblSecondVariableType}) @@ -98,11 +110,11 @@ Public Class dlgTwoVariableFitModel ucrPnlModelType.AddFunctionNamesCondition(rdoTest, {"t.test", "wilcox.test", "var.test", "ansari.test", "mood.test", "cor.test", "cor", "kruskal.test", "bartlett.test", "fligner.test", "fisher.test", "xchisq.test", "prop.test", "aov", - "mcnemar.test"}) + "mcnemar.test", "bayes_inference"}) ucrPnlModelType.AddFunctionNamesCondition(rdoGeneralCase, {"t.test", "wilcox.test", "var.test", "ansari.test", "mood.test", "cor.test", "cor", "kruskal.test", "bartlett.test", "fligner.test", "fisher.test", "xchisq.test", "prop.test", "aov", - "mcnemar.test"}, False) + "mcnemar.test", "bayes_inference"}, False) ucrPnlModelType.AddToLinkedControls(ucrDistributionChoice, {rdoGeneralCase}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True) ucrPnlModelType.AddToLinkedControls(ucrChkConvertToVariate, {rdoGeneralCase}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True) ucrPnlModelType.AddToLinkedControls(ucrInputTest, {rdoTest}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True) @@ -110,7 +122,7 @@ Public Class dlgTwoVariableFitModel ucrInputTest.SetItems({"t", "t paired", "wilcox", "var", "ansari", "mood", "cor", "kruskal", "bartlett", "fligner", "fisher", "chisq", - "propotion", "mcnemar"}) + "propotion", "mcnemar", "bayes:mean", "bayes:proportion"}) ucrInputTest.SetDropDownStyleAsNonEditable() 'General case controls @@ -122,10 +134,12 @@ Public Class dlgTwoVariableFitModel ucrReceiverResponse.Selector = ucrSelectorSimpleReg ucrReceiverResponse.SetParameterIsString() ucrReceiverResponse.bWithQuotes = False + ucrReceiverResponse.SetIncludedDataTypes({"numeric", "dates", "logical", "factor"}, bStrict:=True) ucrReceiverExplanatory.SetParameter(New RParameter("x", 1)) ucrReceiverExplanatory.Selector = ucrSelectorSimpleReg ucrReceiverExplanatory.SetParameterIsString() + ucrReceiverExplanatory.SetIncludedDataTypes({"numeric", "dates", "logical", "factor"}, bStrict:=True) ucrReceiverExplanatory.bWithQuotes = False ucrChkConvertToVariate.SetText("Convert to Numeric") @@ -144,6 +158,32 @@ Public Class dlgTwoVariableFitModel ucrInputConfidenceInterval.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) ucrInputConfidenceInterval.bAllowNonConditionValues = True + ucrInputType.SetParameter(New RParameter("type", 6)) + dctType.Add("credible interval", Chr(34) & "ci" & Chr(34)) + dctType.Add("hypothesis test", Chr(34) & "ht" & Chr(34)) + ucrInputType.SetDropDownStyleAsNonEditable() + ucrInputType.SetItems(dctType) + ucrInputTest.AddToLinkedControls(ucrInputType, {"bayes:mean", "bayes:proportion"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="credible interval") + + ucrInputMethod.SetParameter(New RParameter("method", 7)) + dctMethod.Add("theoretical", Chr(34) & "theoretical" & Chr(34)) + dctMethod.Add("simulation", Chr(34) & "simulation" & Chr(34)) + ucrInputMethod.SetDropDownStyleAsNonEditable() + ucrInputMethod.SetItems(dctMethod) + ucrInputTest.AddToLinkedControls(ucrInputMethod, {"bayes:mean", "bayes:proportion"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="theoretical") + + ucrInputCredibleLevel.SetParameter(New RParameter("cred_level", 10)) + dctCredibleLevel.Add("0.900", "0.90") + dctCredibleLevel.Add("0.950", "0.95") + dctCredibleLevel.Add("0.980", "0.98") + dctCredibleLevel.Add("0.990", "0.99") + dctCredibleLevel.Add("0.999", "0.999") + ucrInputCredibleLevel.SetItems(dctCredibleLevel) + ucrInputCredibleLevel.AddQuotesIfUnrecognised = False + ucrInputCredibleLevel.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) + ucrInputCredibleLevel.bAllowNonConditionValues = True + ucrInputType.AddToLinkedControls(ucrInputCredibleLevel, {"credible interval"}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="0.95") + ucrInputNullHypothesis.SetParameter(New RParameter("mu", 3)) ucrInputNullHypothesis.SetValidationTypeAsNumeric() ucrInputNullHypothesis.AddQuotesIfUnrecognised = False @@ -155,6 +195,10 @@ Public Class dlgTwoVariableFitModel ucrInputConfidenceInterval.SetLinkedDisplayControl(lblConfidenceLevel) ucrInputTest.SetLinkedDisplayControl(lstControl) ucrInputNullHypothesis.SetLinkedDisplayControl(lblNullHypothesis) + ucrInputType.SetLinkedDisplayControl(lblType) + ucrInputSuccess.SetLinkedDisplayControl(lblSuccess) + ucrInputMethod.SetLinkedDisplayControl(lblMethodInference) + ucrInputCredibleLevel.SetLinkedDisplayControl(lblCredibleLevel) ucrSaveModels.SetPrefix("two_var") ucrSaveModels.SetSaveTypeAsModel() @@ -171,10 +215,14 @@ Public Class dlgTwoVariableFitModel clsPolynomialFunc = New RFunction clsLM = New RFunction clsGLM = New RFunction + clsGLMBayes = New RFunction + clsGLMNB = New RFunction clsAsNumeric = New RFunction clsFamilyFunction = New RFunction clsFormulaFunction = New RFunction clsConfint = New RFunction + clsConfintBas = New RFunction + clsCoefFunction = New RFunction clsSummaryFunction = New RFunction clsAnovaFunction = New RFunction clsVisReg = New RFunction @@ -209,12 +257,19 @@ Public Class dlgTwoVariableFitModel clsPropTestFunction = New RFunction clsNumericTtestFunction = New RFunction clsTtestFunction = New RFunction + clsBayesInferenceFunction = New RFunction clsMcnemarTestFunction = New RFunction clsAnsariTestFunction = New RFunction clsMoodTestFunction = New RFunction clsKruskalTestFunction = New RFunction clsBarletteTestFunction = New RFunction clsFlignerTestFunction = New RFunction + clsConvertToColumnTypeFunction = New RFunction + clsGetFactorLevelFunction = New RFunction + clsColumnNameFunction = New RFunction + clsConcatenateFunction = New RFunction + clsConcatenateBetaFuction = New RFunction + clsAnsariTestOperator = New ROperator clsMoodTestOperator = New ROperator clsKruskalTestOperator = New ROperator @@ -254,8 +309,23 @@ Public Class dlgTwoVariableFitModel strRDataFrameNameToAddObjectTo:=ucrSelectorSimpleReg.strCurrentDataFrame, strObjectName:="last_model") + clsGLMNB = clsRegressionDefaults.clsDefaultGLmNBFunction.Clone + clsGLMNB.AddParameter("formula", clsROperatorParameter:=clsFormulaOperator, iPosition:=1) + + clsGLMBayes = clsRegressionDefaults.clsDefaultGLmBayesFunction.Clone + clsGLMBayes.AddParameter("formula", clsROperatorParameter:=clsFormulaOperator, iPosition:=1) + clsGLMBayes.AddParameter("na.action", "na.exclude", iPosition:=4) + clsGLMBayes.AddParameter("method", Chr(34) & "BAS" & Chr(34), iPosition:=5) + clsGLMBayes.AddParameter("modelprior", "BAS::beta.binomial(1, 1)", iPosition:=6) + clsGLMBayes.AddParameter("prior", Chr(34) & "ZS-null" & Chr(34), iPosition:=7) + clsPolynomialFunc.SetRCommand("poly") + clsGetFactorLevelFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_column_factor_levels") + + clsConvertToColumnTypeFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$convert_column_to_type") + + clsColumnNameFunction.SetRCommand("c") 'Residual Plots dctPlotFunctions = New Dictionary(Of String, RFunction)(clsRegressionDefaults.dctModelPlotFunctions) @@ -266,6 +336,11 @@ Public Class dlgTwoVariableFitModel clsVisReg.AddParameter("gg", "TRUE") clsVisReg.bExcludeAssignedFunctionOutput = False + 'coef lm + clsCoefFunction.SetRCommand("coef") + clsCoefFunction.AddParameter("object", clsRFunctionParameter:=clsGLMBayes, iPosition:=0) + + 'Model clsFormulaFunction = clsRegressionDefaults.clsDefaultFormulaFunction.Clone 'Summary @@ -280,13 +355,19 @@ Public Class dlgTwoVariableFitModel clsConfint = clsRegressionDefaults.clsDefaultConfint.Clone clsConfint.bExcludeAssignedFunctionOutput = False + 'confidence Bayes + clsConfintBas = clsRegressionDefaults.clsDefaultConfintBas + clsConfintBas.iCallType = 2 + clsAsNumeric.SetRCommand("as.numeric") clsFamilyFunction = ucrDistributionChoice.clsCurrRFunction clsGLM.AddParameter("family", clsRFunctionParameter:=clsFamilyFunction) + clsLM.SetAssignTo("last_model", strTempDataframe:=ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempModel:="last_model") clsLMOrGLM = clsLM + clsLMOrGLM = clsGLMBayes clsResidualFunction.SetRCommand("residuals") clsFittedValuesFunction.SetRCommand("fitted.values") @@ -397,6 +478,29 @@ Public Class dlgTwoVariableFitModel clsTtestFunction.AddParameter("conf.level", "0.95", iPosition:=2) clsTtestFunction.AddParameter("mu", "0", iPosition:=3) + clsConcatenateFunction.SetRCommand("c") + clsConcatenateFunction.AddParameter("H1", 0.5, iPosition:=0) + + clsConcatenateBetaFuction.SetRCommand("c") + clsConcatenateBetaFuction.AddParameter("a", 1, iPosition:=0) + clsConcatenateBetaFuction.AddParameter("b", 1, iPosition:=1) + + clsBayesInferenceFunction.SetRCommand("bayes_inference") + clsBayesInferenceFunction.SetPackageName("statsr") + clsBayesInferenceFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorSimpleReg.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) + clsBayesInferenceFunction.AddParameter("prior", Chr(34) & "JZS" & Chr(34), iPosition:=1) + clsBayesInferenceFunction.AddParameter("type", Chr(34) & "ci" & Chr(34), iPosition:=2) + clsBayesInferenceFunction.AddParameter("show_plot", "FALSE", iPosition:=3) + clsBayesInferenceFunction.AddParameter("hypothesis_prior", clsRFunctionParameter:=clsConcatenateFunction, iPosition:=9) + clsBayesInferenceFunction.AddParameter("n_0", 1, iPosition:=10) + clsBayesInferenceFunction.AddParameter("s_0", 0, iPosition:=11) + clsBayesInferenceFunction.AddParameter("v_0", -1, iPosition:=12) + clsBayesInferenceFunction.AddParameter("rscale", 1, iPosition:=13) + clsBayesInferenceFunction.AddParameter("prior", Chr(34) & "JZS" & Chr(34), iPosition:=14) + clsBayesInferenceFunction.AddParameter("beta_prior2", clsRFunctionParameter:=clsConcatenateBetaFuction, iPosition:=15) + + + clsTtestOperator.SetOperation("~") clsTtestOperator.bSpaceAroundOperation = True @@ -412,6 +516,7 @@ Public Class dlgTwoVariableFitModel ucrTryModelling.SetRSyntax(ucrBase.clsRsyntax) bResetOptionsSubDialog = True bResetFirstFunction = True + bResetSubdialog = True End Sub Private Sub assignToControlsChanged(ucrChangedControl As ucrCore) Handles ucrSaveModels.ControlValueChanged @@ -518,6 +623,7 @@ Public Class dlgTwoVariableFitModel ucrReceiverExplanatory.AddAdditionalCodeParameterPair(clsKruskalTestOperator, New RParameter("y", iNewPosition:=1), iAdditionalPairNo:=27) ucrReceiverExplanatory.AddAdditionalCodeParameterPair(clsFlignerTestOperator, New RParameter("y", iNewPosition:=1), iAdditionalPairNo:=28) ucrReceiverExplanatory.AddAdditionalCodeParameterPair(clsPropTestOperator, New RParameter("y", iNewPosition:=1), iAdditionalPairNo:=29) + ucrReceiverExplanatory.AddAdditionalCodeParameterPair(clsBayesInferenceFunction, New RParameter("x", iNewPosition:=1), iAdditionalPairNo:=30) ucrReceiverResponse.AddAdditionalCodeParameterPair(clsWilcoxTestOperator, New RParameter("x", iNewPosition:=0), iAdditionalPairNo:=1) ucrReceiverResponse.AddAdditionalCodeParameterPair(clsVarTestOperator, New RParameter("x", iNewPosition:=0), iAdditionalPairNo:=2) @@ -541,6 +647,7 @@ Public Class dlgTwoVariableFitModel ucrReceiverResponse.AddAdditionalCodeParameterPair(clsFlignerTestOperator, New RParameter("x", iNewPosition:=0), iAdditionalPairNo:=20) ucrReceiverResponse.AddAdditionalCodeParameterPair(clsPropTestOperator, New RParameter("x", iNewPosition:=0), iAdditionalPairNo:=21) ucrReceiverResponse.AddAdditionalCodeParameterPair(clsKruskalTestOperator, New RParameter("x", iNewPosition:=0), iAdditionalPairNo:=22) + ucrReceiverResponse.AddAdditionalCodeParameterPair(clsBayesInferenceFunction, New RParameter("y", iNewPosition:=0), iAdditionalPairNo:=23) ' Additional Rcode for test functions ucrSaveModels.AddAdditionalRCode(clsWilcoxTestFunction, iAdditionalPairNo:=1) @@ -566,6 +673,8 @@ Public Class dlgTwoVariableFitModel ucrSaveModels.AddAdditionalRCode(clsKruskalTestFunction, iAdditionalPairNo:=21) ucrSaveModels.AddAdditionalRCode(clsBarletteTestFunction, iAdditionalPairNo:=22) ucrSaveModels.AddAdditionalRCode(clsFlignerTestFunction, iAdditionalPairNo:=23) + ucrSaveModels.AddAdditionalRCode(clsGLMBayes, iAdditionalPairNo:=24) + ucrSaveModels.AddAdditionalRCode(clsGLMNB, iAdditionalPairNo:=25) ucrInputConfidenceInterval.AddAdditionalCodeParameterPair(clsWilcoxTestFunction, New RParameter("conf.level", iNewPosition:=2), iAdditionalPairNo:=1) ucrInputConfidenceInterval.AddAdditionalCodeParameterPair(clsVarTestFunction, New RParameter("conf.level", iNewPosition:=2), iAdditionalPairNo:=2) @@ -579,18 +688,26 @@ Public Class dlgTwoVariableFitModel ucrInputConfidenceInterval.AddAdditionalCodeParameterPair(clsMoodTestFunction, New RParameter("conf.level", iNewPosition:=2), iAdditionalPairNo:=10) ucrInputConfidenceInterval.SetRCode(clsTtestFunction, bReset) + ucrInputType.SetRCode(clsBayesInferenceFunction, bReset) + ucrInputMethod.SetRCode(clsBayesInferenceFunction, bReset) + ucrInputCredibleLevel.SetRCode(clsBayesInferenceFunction, bReset) ucrInputNullHypothesis.AddAdditionalCodeParameterPair(clsWilcoxTestFunction, New RParameter("mu", iNewPosition:=4), iAdditionalPairNo:=1) ucrInputNullHypothesis.SetRCode(clsTtestFunction, bReset) 'General case controls ucrSelectorSimpleReg.AddAdditionalCodeParameterPair(clsGLM, ucrSelectorSimpleReg.GetParameter(), 1) + ucrSelectorSimpleReg.AddAdditionalCodeParameterPair(clsGLMBayes, ucrSelectorSimpleReg.GetParameter(), 2) + ucrSelectorSimpleReg.AddAdditionalCodeParameterPair(clsGLMNB, ucrSelectorSimpleReg.GetParameter(), 3) + ucrReceiverResponse.SetRCode(clsAsNumeric, bReset) ucrReceiverExplanatory.SetRCode(clsTransformFunction, bReset) - ucrPnlModelType.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) ucrSelectorSimpleReg.SetRCode(clsLM, bReset) ucrChkConvertToVariate.SetRCode(clsFormulaOperator) ucrSaveModels.SetRCode(clsLM, bReset) - ucrDistributionChoice.SetRCode(clsFamilyFunction, bReset) + If bReset Then + ucrDistributionChoice.SetRCode(clsFamilyFunction, bReset) + ucrPnlModelType.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + End If bRCodeSet = True End Sub @@ -634,6 +751,27 @@ Public Class dlgTwoVariableFitModel UpdatePreview() End Sub + Private Sub cmdPrior_Click(sender As Object, e As EventArgs) Handles cmdPrior.Click + sdgPriorParameters.SetRFunction(clsNewBayesIferenceFunction:=clsBayesInferenceFunction, + clsNewConcatenateFunction:=clsConcatenateFunction, bReset:=bResetSubdialog) + bResetSubdialog = False + sdgPriorParameters.ShowDialog() + End Sub + + Private Sub cmdEstimation_Click(sender As Object, e As EventArgs) Handles cmdEstimation.Click + sdgEstimationParameters.SetRFunction(clsNewBayesIferenceFunction:=clsBayesInferenceFunction, + clsNewConcatenateFunction:=clsConcatenateFunction, bReset:=bResetSubdialog) + bResetSubdialog = False + sdgEstimationParameters.ShowDialog() + End Sub + + Private Sub cmdProprtionPriors_Click(sender As Object, e As EventArgs) Handles cmdProprtionPriors.Click + sdgPriorProportions.SetRFunction(clsNewConcatenateFunction:=clsConcatenateFunction, + clsNewConcatenateBetaFuction:=clsConcatenateBetaFuction, bReset:=bResetSubdialog) + bResetSubdialog = False + sdgPriorProportions.ShowDialog() + End Sub + Private Sub UpdatePreview() If Not ucrReceiverResponse.IsEmpty AndAlso Not ucrReceiverExplanatory.IsEmpty Then ucrModelPreview.SetName(clsFormulaOperator.ToScript()) @@ -644,14 +782,35 @@ Public Class dlgTwoVariableFitModel Private Sub SetBaseFunction() If rdoGeneralCase.Checked Then + ChooseAnovaFunction() If (ucrDistributionChoice.clsCurrDistribution.strNameTag = "Normal") Then clsLMOrGLM = clsLM + ElseIf (ucrDistributionChoice.clsCurrDistribution.strNameTag = "Bayes") Then + clsLMOrGLM = clsGLMBayes + ElseIf (ucrDistributionChoice.clsCurrDistribution.strNameTag = "Negative_Binomial_GLM") Then + clsLMOrGLM = clsGLMNB Else clsLMOrGLM = clsGLM End If - ucrBase.clsRsyntax.AddToAfterCodes(clsAnovaFunction, 1) ucrBase.clsRsyntax.AddToAfterCodes(clsSummaryFunction, 2) ucrBase.clsRsyntax.SetBaseRFunction(clsLMOrGLM) + 'Update display functions to contain correct model + clsFormulaFunction.AddParameter("x", clsRFunctionParameter:=clsLMOrGLM) + clsAnovaFunction.AddParameter("object", clsRFunctionParameter:=clsLMOrGLM) + clsSummaryFunction.AddParameter("object", clsRFunctionParameter:=clsLMOrGLM) + clsConfint.AddParameter("object", clsRFunctionParameter:=clsLMOrGLM) + clsConfintBas.AddParameter("object", clsRFunctionParameter:=clsCoefFunction) + clsVisReg.AddParameter("fit", clsRFunctionParameter:=clsLMOrGLM) + + For Each kvp As KeyValuePair(Of String, RFunction) In dctPlotFunctions + kvp.Value.AddParameter("x", clsRFunctionParameter:=clsLMOrGLM, iPosition:=0) + Next + + clsResidualFunction.AddParameter("object", clsRFunctionParameter:=clsLMOrGLM, iPosition:=0) + clsFittedValuesFunction.AddParameter("object", clsRFunctionParameter:=clsLMOrGLM, iPosition:=0) + clsRstandardFunction.AddParameter("model", clsRFunctionParameter:=clsLMOrGLM, iPosition:=0) + clsHatvaluesFunction.AddParameter("model", clsRFunctionParameter:=clsLMOrGLM, iPosition:=0) + ElseIf rdoTest.Checked Then ucrBase.clsRsyntax.RemoveFromAfterCodes(clsAnovaFunction) ucrBase.clsRsyntax.RemoveFromAfterCodes(clsSummaryFunction) @@ -722,6 +881,10 @@ Public Class dlgTwoVariableFitModel ucrBase.clsRsyntax.SetBaseRFunction(clsFisherTestFunction) Case "chisq" ucrBase.clsRsyntax.SetBaseRFunction(clsXchisgTestFunction) + Case "bayes:proportion" + ucrBase.clsRsyntax.SetBaseRFunction(clsBayesInferenceFunction) + Case "bayes:mean" + ucrBase.clsRsyntax.SetBaseRFunction(clsBayesInferenceFunction) Case "proportion" ucrBase.clsRsyntax.SetBaseRFunction(clsPropTestFunction) Case "mcnemar" @@ -767,8 +930,19 @@ Public Class dlgTwoVariableFitModel End If UpdatePreview() ReceiverColumnType() + AddFactorLevels() End Sub + Private Sub ucrSelectorSimpleReg_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorSimpleReg.ControlValueChanged + GraphAssignTo() + AddFactorLevels() + End Sub + + 'temp fix for graph display problem with RDotNet + 'correct solution is to have save controls linked to each graph + Private Sub GraphAssignTo() + clsVisReg.SetAssignTo("last_visreg", strTempDataframe:=ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_visreg") + End Sub Private Sub ucrReceiverExplanatory_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverExplanatory.ControlValueChanged If bRCodeSet Then @@ -786,6 +960,7 @@ Public Class dlgTwoVariableFitModel cmdExplanatoryFunction.Enabled = False End If ReceiverColumnType() + AddFactorLevels() End Sub '''-------------------------------------------------------------------------------------------- @@ -827,6 +1002,9 @@ Public Class dlgTwoVariableFitModel cmdExplanatoryFunction.Visible = rdoGeneralCase.Checked SetBaseFunction() ReceiverColumnType() + AddFactorLevels() + ChooseAnovaFunction() + PrioirsVisisbility() End Sub Private Sub ucrChkConvertToVariate_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkConvertToVariate.ControlValueChanged @@ -850,10 +1028,22 @@ Public Class dlgTwoVariableFitModel TestOKEnabled() End Sub - Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverResponse.ControlContentsChanged, ucrPnlModelType.ControlContentsChanged, ucrReceiverExplanatory.ControlContentsChanged + Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverResponse.ControlContentsChanged, ucrReceiverExplanatory.ControlContentsChanged, ucrPnlModelType.ControlContentsChanged TestOKEnabled() End Sub + Public Sub ChooseAnovaFunction() + If (ucrDistributionChoice.clsCurrDistribution.strNameTag = "Bayes") Then + ucrBase.clsRsyntax.RemoveFromAfterCodes(clsAnovaFunction) + ucrBase.clsRsyntax.AddToAfterCodes(clsConfintBas, 1) + cmdDisplayOptions.Enabled = False + Else + ucrBase.clsRsyntax.RemoveFromAfterCodes(clsConfintBas) + ucrBase.clsRsyntax.AddToAfterCodes(clsAnovaFunction, 1) + cmdDisplayOptions.Enabled = True + End If + End Sub + Private Sub ReceiverColumnType() If rdoTest.Checked Then If bRCodeSet Then @@ -911,6 +1101,67 @@ Public Class dlgTwoVariableFitModel End If End Function + ''' + '''Lists the factor levels of the selected factor or logical column into the success combobox + ''' + Private Sub AddFactorLevels() + If Not bRCodeSet Then + Exit Sub + End If + + Dim bDatatype As Boolean = ucrReceiverResponse.strCurrDataType.ToLower = "two level factor" Or ucrReceiverResponse.strCurrDataType.ToLower = "factor" + Dim bTest As Boolean = ucrInputTest.GetText() = "bayes:proportion" + Dim bTypeIsNumeric As Boolean = ucrReceiverResponse.strCurrDataType = "numeric" + + If Not ucrReceiverResponse.IsEmpty AndAlso rdoTest.Checked AndAlso + (bDatatype OrElse bTypeIsNumeric) AndAlso bTest Then + FindLevels() + Else + ucrInputSuccess.Visible = False + clsBayesInferenceFunction.RemoveParameterByName("success") + End If + End Sub + + ''' + '''Lists the levels in a column to the success combobox and removes success parameter + ''' + Private Sub FindLevels() + Dim chrCurrentFactorLevels As CharacterVector + Dim lstFactor As List(Of String) = New List(Of String)() + Dim bTypeIsNumeric As Boolean = ucrReceiverResponse.strCurrDataType.ToLower = "numeric" + + 'Converting the numeric column to factor + If bTypeIsNumeric Then + clsConvertToColumnTypeFunction.AddParameter("data_name", Chr(34) & ucrSelectorSimpleReg.ucrAvailableDataFrames.strCurrDataFrame & Chr(34), iPosition:=0) + clsConvertToColumnTypeFunction.AddParameter("to_type", Chr(34) & "factor" & Chr(34), iPosition:=1) + clsConvertToColumnTypeFunction.AddParameter("col_names", clsRFunctionParameter:=clsColumnNameFunction, iPosition:=2) + clsColumnNameFunction.AddParameter("column", ucrReceiverResponse.GetVariableNames(True), iPosition:=0, bIncludeArgumentName:=False) + frmMain.clsRLink.RunInternalScript(clsConvertToColumnTypeFunction.ToScript(), bSilent:=True) + End If + + clsGetFactorLevelFunction.AddParameter("data_name", Chr(34) & ucrSelectorSimpleReg.ucrAvailableDataFrames.strCurrDataFrame & Chr(34), iPosition:=0) + clsGetFactorLevelFunction.AddParameter("col_name", ucrReceiverResponse.GetVariableNames(), iPosition:=1) + chrCurrentFactorLevels = frmMain.clsRLink.RunInternalScriptGetValue(clsGetFactorLevelFunction.ToScript()).AsCharacter + + For Each factor In chrCurrentFactorLevels + lstFactor.Add(Chr(34) & factor & Chr(34)) + Next + + 'converting back to Numeric + If bTypeIsNumeric Then + clsConvertToColumnTypeFunction.AddParameter("to_type", Chr(34) & "numeric" & Chr(34), iPosition:=1) + frmMain.clsRLink.RunInternalScript(clsConvertToColumnTypeFunction.ToScript(), bSilent:=True) + End If + + If lstFactor.ToArray.Count = 0 Then + MsgBox("Developer error: there are no factor levels to be displayed" & Chr(34) & vbNewLine & "Success combobox will be displayed with no inputs") + Else + ucrInputSuccess.SetItems(lstFactor.ToArray) + ucrInputSuccess.SetText(lstFactor(0)) + ucrInputSuccess.Visible = True + End If + End Sub + Private Sub UpdatingTests() If strFirstVariableType = "numeric" Then If strSecondVariableType = "numeric" Then @@ -919,8 +1170,8 @@ Public Class dlgTwoVariableFitModel ucrInputTest.SetText("t") ElseIf strSecondVariableType = "categorical" Then If iNumberOfSecondFactorLevels = 2 Then - ucrInputTest.SetItems({"t", "wilcox", "var", "ansari", "mood", "________", - "oneway", "kruskal", "bartlett", "fligner"}) + ucrInputTest.SetItems({"t", "wilcox", "var", "ansari", "mood", + "________", "bayes:mean", "________", "oneway", "kruskal", "bartlett", "fligner"}) ucrInputTest.SetText("t") ElseIf iNumberOfSecondFactorLevels > 2 Then ucrInputTest.SetItems({"oneway", "kruskal", "bartlett", "fligner"}) @@ -935,7 +1186,7 @@ Public Class dlgTwoVariableFitModel If strSecondVariableType = "categorical" Then If iNumberOfFirstFactorLevels = 2 Then If strSecondVariableType = "categorical" AndAlso iNumberOfSecondFactorLevels = 2 Then - ucrInputTest.SetItems({"proportion", "chisq", "fisher", "mcnemar"}) + ucrInputTest.SetItems({"proportion", "chisq", "fisher", "mcnemar", "bayes:proportion"}) ucrInputTest.SetText("proportion") Else ucrInputTest.SetItems({"None"}) @@ -953,9 +1204,59 @@ Public Class dlgTwoVariableFitModel ucrInputTest.SetItems({"None"}) ucrInputTest.SetText("None") End If + End Sub Private Sub ucrInputTest_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputTest.ControlValueChanged SetBaseFunction() + SampleStatistic() + AddFactorLevels() + PrioirsVisisbility() + GetNullValue() + End Sub + + Private Sub GetNullValue() + If bRCodeSet Then + If ucrInputType.GetText = "credible interval" Then + clsBayesInferenceFunction.RemoveParameterByName("null") + clsBayesInferenceFunction.AddParameter("mu_0", 0, iPosition:=15) + Else + clsBayesInferenceFunction.AddParameter("null", 0, iPosition:=7) + clsBayesInferenceFunction.RemoveParameterByName("mu_0") + End If + End If + End Sub + + Private Sub PrioirsVisisbility() + cmdPrior.Visible = rdoTest.Checked AndAlso ( + ucrInputTest.GetText() = "bayes:mean" AndAlso + ucrInputType.GetText = "hypothesis test") + cmdEstimation.Visible = rdoTest.Checked AndAlso ( + ucrInputTest.GetText() = "bayes:mean" AndAlso + ucrInputType.GetText = "credible interval") + cmdProprtionPriors.Visible = rdoTest.Checked AndAlso ( + ucrInputTest.GetText() = "bayes:proportion") + End Sub + + Private Sub ucrInputType_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputType.ControlValueChanged + GetNullValue() + PrioirsVisisbility() + End Sub + + Private Sub SampleStatistic() + clsBayesInferenceFunction.AddParameter("alternative", Chr(34) & "twosided" & Chr(34), iPosition:=5) + If ucrInputTest.GetText() = "bayes:mean" Then + clsBayesInferenceFunction.AddParameter("statistic", Chr(34) & "mean" & Chr(34), iPosition:=4) + ElseIf ucrInputTest.GetText() = "bayes:proportion" Then + clsBayesInferenceFunction.AddParameter("statistic", Chr(34) & "proportion" & Chr(34), iPosition:=4) + End If + End Sub + + Private Sub ucrInputSuccess_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputSuccess.ControlValueChanged + If ucrInputSuccess.Visible Then + clsBayesInferenceFunction.AddParameter("success", ucrInputSuccess.GetText(), iPosition:=6) + Else + clsBayesInferenceFunction.RemoveParameterByName("success") + End If End Sub End Class \ No newline at end of file diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 7981ae55b48..c6f0c152664 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -253,6 +253,12 @@ Form + + sdgPriorProportions.vb + + + Form + sdgSummaryThemes.vb @@ -581,6 +587,12 @@ Form + + sdgEstimationParameters.vb + + + Form + sdgExportToWWR.vb @@ -689,6 +701,12 @@ Form + + sdgPriorParameters.vb + + + Form + sdgThemesSub.vb @@ -3104,6 +3122,9 @@ sdgPairPlotOptions.vb + + sdgPriorProportions.vb + sdgSummaryThemes.vb @@ -3132,6 +3153,9 @@ sdgDistributionOptions.vb + + sdgEstimationParameters.vb + sdgExportToWWR.vb @@ -3186,6 +3210,9 @@ sdgMissingOptions.vb + + sdgPriorParameters.vb + sdgThemesSub.vb diff --git a/instat/sdgEstimationParameters.Designer.vb b/instat/sdgEstimationParameters.Designer.vb new file mode 100644 index 00000000000..e4778a807c7 --- /dev/null +++ b/instat/sdgEstimationParameters.Designer.vb @@ -0,0 +1,220 @@ + _ +Partial Class sdgEstimationParameters + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.lblPriorFamily = New System.Windows.Forms.Label() + Me.ucrInputPriorFamily = New instat.ucrInputComboBox() + Me.lblStandardDeviation = New System.Windows.Forms.Label() + Me.lblDegreesFreedom = New System.Windows.Forms.Label() + Me.lblScalingParameter = New System.Windows.Forms.Label() + Me.lblSampleSize = New System.Windows.Forms.Label() + Me.ucrNudStandardDeviation = New instat.ucrNud() + Me.ucrNudDegreesFreedom = New instat.ucrNud() + Me.ucrNudScaleParameter = New instat.ucrNud() + Me.ucrNudSampleSize = New instat.ucrNud() + Me.ucrSdgButtons = New instat.ucrButtonsSubdialogue() + Me.ucrInputPriorMean = New instat.ucrInputTextBox() + Me.lblPriorMean = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'lblPriorFamily + ' + Me.lblPriorFamily.AutoSize = True + Me.lblPriorFamily.Location = New System.Drawing.Point(72, 20) + Me.lblPriorFamily.Name = "lblPriorFamily" + Me.lblPriorFamily.Size = New System.Drawing.Size(63, 13) + Me.lblPriorFamily.TabIndex = 103 + Me.lblPriorFamily.Text = "Prior Family:" + ' + 'ucrInputPriorFamily + ' + Me.ucrInputPriorFamily.AddQuotesIfUnrecognised = True + Me.ucrInputPriorFamily.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputPriorFamily.GetSetSelectedIndex = -1 + Me.ucrInputPriorFamily.IsReadOnly = False + Me.ucrInputPriorFamily.Location = New System.Drawing.Point(137, 16) + Me.ucrInputPriorFamily.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputPriorFamily.Name = "ucrInputPriorFamily" + Me.ucrInputPriorFamily.Size = New System.Drawing.Size(133, 21) + Me.ucrInputPriorFamily.TabIndex = 102 + ' + 'lblStandardDeviation + ' + Me.lblStandardDeviation.AutoSize = True + Me.lblStandardDeviation.Location = New System.Drawing.Point(8, 101) + Me.lblStandardDeviation.Name = "lblStandardDeviation" + Me.lblStandardDeviation.Size = New System.Drawing.Size(127, 13) + Me.lblStandardDeviation.TabIndex = 99 + Me.lblStandardDeviation.Text = "Prioir Standard Deviation:" + ' + 'lblDegreesFreedom + ' + Me.lblDegreesFreedom.AutoSize = True + Me.lblDegreesFreedom.Location = New System.Drawing.Point(5, 129) + Me.lblDegreesFreedom.Name = "lblDegreesFreedom" + Me.lblDegreesFreedom.Size = New System.Drawing.Size(130, 13) + Me.lblDegreesFreedom.TabIndex = 98 + Me.lblDegreesFreedom.Text = "Prior Degrees of Freedom:" + ' + 'lblScalingParameter + ' + Me.lblScalingParameter.AutoSize = True + Me.lblScalingParameter.Location = New System.Drawing.Point(39, 160) + Me.lblScalingParameter.Name = "lblScalingParameter" + Me.lblScalingParameter.Size = New System.Drawing.Size(96, 13) + Me.lblScalingParameter.TabIndex = 97 + Me.lblScalingParameter.Text = "Scaling Parameter:" + ' + 'lblSampleSize + ' + Me.lblSampleSize.AutoSize = True + Me.lblSampleSize.Location = New System.Drawing.Point(43, 74) + Me.lblSampleSize.Name = "lblSampleSize" + Me.lblSampleSize.Size = New System.Drawing.Size(92, 13) + Me.lblSampleSize.TabIndex = 95 + Me.lblSampleSize.Text = "Prior Sample Size:" + ' + 'ucrNudStandardDeviation + ' + Me.ucrNudStandardDeviation.AutoSize = True + Me.ucrNudStandardDeviation.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudStandardDeviation.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudStandardDeviation.Location = New System.Drawing.Point(137, 98) + Me.ucrNudStandardDeviation.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudStandardDeviation.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudStandardDeviation.Name = "ucrNudStandardDeviation" + Me.ucrNudStandardDeviation.Size = New System.Drawing.Size(50, 20) + Me.ucrNudStandardDeviation.TabIndex = 94 + Me.ucrNudStandardDeviation.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrNudDegreesFreedom + ' + Me.ucrNudDegreesFreedom.AutoSize = True + Me.ucrNudDegreesFreedom.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Location = New System.Drawing.Point(137, 126) + Me.ucrNudDegreesFreedom.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Name = "ucrNudDegreesFreedom" + Me.ucrNudDegreesFreedom.Size = New System.Drawing.Size(50, 20) + Me.ucrNudDegreesFreedom.TabIndex = 93 + Me.ucrNudDegreesFreedom.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrNudScaleParameter + ' + Me.ucrNudScaleParameter.AutoSize = True + Me.ucrNudScaleParameter.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudScaleParameter.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudScaleParameter.Location = New System.Drawing.Point(137, 156) + Me.ucrNudScaleParameter.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudScaleParameter.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudScaleParameter.Name = "ucrNudScaleParameter" + Me.ucrNudScaleParameter.Size = New System.Drawing.Size(50, 20) + Me.ucrNudScaleParameter.TabIndex = 92 + Me.ucrNudScaleParameter.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrNudSampleSize + ' + Me.ucrNudSampleSize.AutoSize = True + Me.ucrNudSampleSize.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudSampleSize.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudSampleSize.Location = New System.Drawing.Point(137, 70) + Me.ucrNudSampleSize.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudSampleSize.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudSampleSize.Name = "ucrNudSampleSize" + Me.ucrNudSampleSize.Size = New System.Drawing.Size(50, 20) + Me.ucrNudSampleSize.TabIndex = 91 + Me.ucrNudSampleSize.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrSdgButtons + ' + Me.ucrSdgButtons.AutoSize = True + Me.ucrSdgButtons.Location = New System.Drawing.Point(7, 185) + Me.ucrSdgButtons.Name = "ucrSdgButtons" + Me.ucrSdgButtons.Size = New System.Drawing.Size(224, 30) + Me.ucrSdgButtons.TabIndex = 90 + ' + 'ucrInputPriorMean + ' + Me.ucrInputPriorMean.AddQuotesIfUnrecognised = True + Me.ucrInputPriorMean.AutoSize = True + Me.ucrInputPriorMean.IsMultiline = False + Me.ucrInputPriorMean.IsReadOnly = False + Me.ucrInputPriorMean.Location = New System.Drawing.Point(137, 44) + Me.ucrInputPriorMean.Name = "ucrInputPriorMean" + Me.ucrInputPriorMean.Size = New System.Drawing.Size(55, 21) + Me.ucrInputPriorMean.TabIndex = 115 + ' + 'lblPriorMean + ' + Me.lblPriorMean.AutoSize = True + Me.lblPriorMean.Location = New System.Drawing.Point(74, 48) + Me.lblPriorMean.Name = "lblPriorMean" + Me.lblPriorMean.Size = New System.Drawing.Size(61, 13) + Me.lblPriorMean.TabIndex = 114 + Me.lblPriorMean.Text = "Prior Mean:" + ' + 'sdgEstimationParameters + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ClientSize = New System.Drawing.Size(277, 218) + Me.Controls.Add(Me.ucrInputPriorMean) + Me.Controls.Add(Me.lblPriorMean) + Me.Controls.Add(Me.lblPriorFamily) + Me.Controls.Add(Me.ucrInputPriorFamily) + Me.Controls.Add(Me.lblStandardDeviation) + Me.Controls.Add(Me.lblDegreesFreedom) + Me.Controls.Add(Me.lblScalingParameter) + Me.Controls.Add(Me.lblSampleSize) + Me.Controls.Add(Me.ucrNudStandardDeviation) + Me.Controls.Add(Me.ucrNudDegreesFreedom) + Me.Controls.Add(Me.ucrNudScaleParameter) + Me.Controls.Add(Me.ucrNudSampleSize) + Me.Controls.Add(Me.ucrSdgButtons) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "sdgEstimationParameters" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Estimation Prioir Parameters" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents lblPriorFamily As Label + Friend WithEvents ucrInputPriorFamily As ucrInputComboBox + Friend WithEvents lblStandardDeviation As Label + Friend WithEvents lblDegreesFreedom As Label + Friend WithEvents lblScalingParameter As Label + Friend WithEvents lblSampleSize As Label + Friend WithEvents ucrNudStandardDeviation As ucrNud + Friend WithEvents ucrNudDegreesFreedom As ucrNud + Friend WithEvents ucrNudScaleParameter As ucrNud + Friend WithEvents ucrNudSampleSize As ucrNud + Friend WithEvents ucrSdgButtons As ucrButtonsSubdialogue + Friend WithEvents ucrInputPriorMean As ucrInputTextBox + Friend WithEvents lblPriorMean As Label +End Class diff --git a/instat/sdgEstimationParameters.resx b/instat/sdgEstimationParameters.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgEstimationParameters.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/sdgEstimationParameters.vb b/instat/sdgEstimationParameters.vb new file mode 100644 index 00000000000..f0a635bb435 --- /dev/null +++ b/instat/sdgEstimationParameters.vb @@ -0,0 +1,83 @@ +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . +Imports instat.Translations +Public Class sdgEstimationParameters + + Private bControlsInitialised As Boolean = False + Private bFirstLoad As Boolean = True + Private clsBayesInferenceFunction, clsConcatenateFunction As New RFunction + + Private Sub sdgEstimationParameters_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + End Sub + + Private Sub InitialiseControls() + Dim dctPriorFamily As New Dictionary(Of String, String) + ucrNudSampleSize.SetParameter(New RParameter("n_0", 10)) + ucrNudSampleSize.SetMinMax(1, Integer.MaxValue) + ucrNudSampleSize.SetRDefault(1) + + ucrNudStandardDeviation.SetParameter(New RParameter("s_0", 11)) + ucrNudStandardDeviation.SetMinMax(0, Integer.MaxValue) + ucrNudStandardDeviation.SetRDefault(0) + + ucrNudDegreesFreedom.SetParameter(New RParameter("v_0", 12)) + ucrNudDegreesFreedom.SetMinMax(-1, Integer.MaxValue) + ucrNudDegreesFreedom.SetRDefault(-1) + + ucrNudScaleParameter.SetParameter(New RParameter("rscale", 13)) + ucrNudScaleParameter.SetMinMax(1, Integer.MaxValue) + ucrNudScaleParameter.SetRDefault(1) + + ucrInputPriorFamily.SetParameter(New RParameter("prior", 14)) + dctPriorFamily.Add("Jeffreys-reference prior", Chr(34) & "JZS" & Chr(34)) + dctPriorFamily.Add("Unit Information prior", Chr(34) & "JUI" & Chr(34)) + dctPriorFamily.Add("Improper uniform prior", Chr(34) & "ref" & Chr(34)) + dctPriorFamily.Add("Normal-Gamma prior", Chr(34) & "NG" & Chr(34)) + ucrInputPriorFamily.SetItems(dctPriorFamily) + ucrInputPriorFamily.SetRDefault("JSZ") + ucrInputPriorFamily.SetDropDownStyleAsNonEditable() + + ucrInputPriorMean.SetParameter(New RParameter("mu_0", 15)) + ucrInputPriorMean.SetValidationTypeAsNumeric() + ucrInputPriorMean.AddQuotesIfUnrecognised = False + ucrInputPriorMean.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=Integer.MaxValue, bIncludeMax:=True) + + ucrNudSampleSize.SetLinkedDisplayControl(lblSampleSize) + ucrNudScaleParameter.SetLinkedDisplayControl(lblScalingParameter) + ucrNudStandardDeviation.SetLinkedDisplayControl(lblStandardDeviation) + ucrNudDegreesFreedom.SetLinkedDisplayControl(lblDegreesFreedom) + ucrInputPriorFamily.SetLinkedDisplayControl(lblPriorFamily) + ucrInputPriorMean.SetLinkedDisplayControl(lblPriorMean) + End Sub + + Public Sub SetRFunction(clsNewBayesIferenceFunction As RFunction, clsNewConcatenateFunction As RFunction, Optional bReset As Boolean = False) + If Not bControlsInitialised Then + InitialiseControls() + End If + + clsBayesInferenceFunction = clsNewBayesIferenceFunction + clsConcatenateFunction = clsNewConcatenateFunction + + ucrNudSampleSize.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudDegreesFreedom.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudScaleParameter.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudStandardDeviation.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrInputPriorFamily.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrInputPriorMean.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + + End Sub +End Class \ No newline at end of file diff --git a/instat/sdgPriorParameters.Designer.vb b/instat/sdgPriorParameters.Designer.vb new file mode 100644 index 00000000000..5416b376ae6 --- /dev/null +++ b/instat/sdgPriorParameters.Designer.vb @@ -0,0 +1,232 @@ + +Partial Class sdgPriorParameters + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + + Private Sub InitializeComponent() + Me.lblSampleSize = New System.Windows.Forms.Label() + Me.lblPrioir = New System.Windows.Forms.Label() + Me.lblScalingParameter = New System.Windows.Forms.Label() + Me.lblDegreesFreedom = New System.Windows.Forms.Label() + Me.lblStandardDeviation = New System.Windows.Forms.Label() + Me.grpHypothesisPrior = New System.Windows.Forms.GroupBox() + Me.ucrNudPrioirNull = New instat.ucrInputComboBox() + Me.ucrNudStandardDeviation = New instat.ucrNud() + Me.ucrNudDegreesFreedom = New instat.ucrNud() + Me.ucrNudScaleParameter = New instat.ucrNud() + Me.ucrNudSampleSize = New instat.ucrNud() + Me.ucrSdgButtons = New instat.ucrButtonsSubdialogue() + Me.ucrInputPriorFamily = New instat.ucrInputComboBox() + Me.lblPriorFamily = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'lblSampleSize + ' + Me.lblSampleSize.AutoSize = True + Me.lblSampleSize.Location = New System.Drawing.Point(42, 39) + Me.lblSampleSize.Name = "lblSampleSize" + Me.lblSampleSize.Size = New System.Drawing.Size(92, 13) + Me.lblSampleSize.TabIndex = 9 + Me.lblSampleSize.Text = "Prior Sample Size:" + ' + 'lblPrioir + ' + Me.lblPrioir.AutoSize = True + Me.lblPrioir.Location = New System.Drawing.Point(14, 171) + Me.lblPrioir.Name = "lblPrioir" + Me.lblPrioir.Size = New System.Drawing.Size(24, 13) + Me.lblPrioir.TabIndex = 10 + Me.lblPrioir.Text = "H1:" + ' + 'lblScalingParameter + ' + Me.lblScalingParameter.AutoSize = True + Me.lblScalingParameter.Location = New System.Drawing.Point(38, 124) + Me.lblScalingParameter.Name = "lblScalingParameter" + Me.lblScalingParameter.Size = New System.Drawing.Size(96, 13) + Me.lblScalingParameter.TabIndex = 12 + Me.lblScalingParameter.Text = "Scaling Parameter:" + ' + 'lblDegreesFreedom + ' + Me.lblDegreesFreedom.AutoSize = True + Me.lblDegreesFreedom.Location = New System.Drawing.Point(4, 93) + Me.lblDegreesFreedom.Name = "lblDegreesFreedom" + Me.lblDegreesFreedom.Size = New System.Drawing.Size(130, 13) + Me.lblDegreesFreedom.TabIndex = 13 + Me.lblDegreesFreedom.Text = "Prior Degrees of Freedom:" + ' + 'lblStandardDeviation + ' + Me.lblStandardDeviation.AutoSize = True + Me.lblStandardDeviation.Location = New System.Drawing.Point(7, 68) + Me.lblStandardDeviation.Name = "lblStandardDeviation" + Me.lblStandardDeviation.Size = New System.Drawing.Size(127, 13) + Me.lblStandardDeviation.TabIndex = 14 + Me.lblStandardDeviation.Text = "Prioir Standard Deviation:" + ' + 'grpHypothesisPrior + ' + Me.grpHypothesisPrior.Location = New System.Drawing.Point(7, 147) + Me.grpHypothesisPrior.Name = "grpHypothesisPrior" + Me.grpHypothesisPrior.Size = New System.Drawing.Size(146, 57) + Me.grpHypothesisPrior.TabIndex = 16 + Me.grpHypothesisPrior.TabStop = False + Me.grpHypothesisPrior.Text = "Hypothesis Prior" + ' + 'ucrNudPrioirNull + ' + Me.ucrNudPrioirNull.AddQuotesIfUnrecognised = True + Me.ucrNudPrioirNull.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrNudPrioirNull.GetSetSelectedIndex = -1 + Me.ucrNudPrioirNull.IsReadOnly = False + Me.ucrNudPrioirNull.Location = New System.Drawing.Point(38, 165) + Me.ucrNudPrioirNull.Margin = New System.Windows.Forms.Padding(5) + Me.ucrNudPrioirNull.Name = "ucrNudPrioirNull" + Me.ucrNudPrioirNull.Size = New System.Drawing.Size(81, 21) + Me.ucrNudPrioirNull.TabIndex = 87 + ' + 'ucrNudStandardDeviation + ' + Me.ucrNudStandardDeviation.AutoSize = True + Me.ucrNudStandardDeviation.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudStandardDeviation.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudStandardDeviation.Location = New System.Drawing.Point(136, 65) + Me.ucrNudStandardDeviation.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudStandardDeviation.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudStandardDeviation.Name = "ucrNudStandardDeviation" + Me.ucrNudStandardDeviation.Size = New System.Drawing.Size(50, 20) + Me.ucrNudStandardDeviation.TabIndex = 6 + Me.ucrNudStandardDeviation.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrNudDegreesFreedom + ' + Me.ucrNudDegreesFreedom.AutoSize = True + Me.ucrNudDegreesFreedom.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Location = New System.Drawing.Point(136, 90) + Me.ucrNudDegreesFreedom.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudDegreesFreedom.Name = "ucrNudDegreesFreedom" + Me.ucrNudDegreesFreedom.Size = New System.Drawing.Size(50, 20) + Me.ucrNudDegreesFreedom.TabIndex = 5 + Me.ucrNudDegreesFreedom.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrNudScaleParameter + ' + Me.ucrNudScaleParameter.AutoSize = True + Me.ucrNudScaleParameter.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudScaleParameter.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudScaleParameter.Location = New System.Drawing.Point(136, 120) + Me.ucrNudScaleParameter.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudScaleParameter.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudScaleParameter.Name = "ucrNudScaleParameter" + Me.ucrNudScaleParameter.Size = New System.Drawing.Size(50, 20) + Me.ucrNudScaleParameter.TabIndex = 4 + Me.ucrNudScaleParameter.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrNudSampleSize + ' + Me.ucrNudSampleSize.AutoSize = True + Me.ucrNudSampleSize.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudSampleSize.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudSampleSize.Location = New System.Drawing.Point(136, 35) + Me.ucrNudSampleSize.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudSampleSize.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudSampleSize.Name = "ucrNudSampleSize" + Me.ucrNudSampleSize.Size = New System.Drawing.Size(50, 20) + Me.ucrNudSampleSize.TabIndex = 3 + Me.ucrNudSampleSize.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrSdgButtons + ' + Me.ucrSdgButtons.AutoSize = True + Me.ucrSdgButtons.Location = New System.Drawing.Point(1, 212) + Me.ucrSdgButtons.Name = "ucrSdgButtons" + Me.ucrSdgButtons.Size = New System.Drawing.Size(224, 30) + Me.ucrSdgButtons.TabIndex = 2 + ' + 'ucrInputPriorFamily + ' + Me.ucrInputPriorFamily.AddQuotesIfUnrecognised = True + Me.ucrInputPriorFamily.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputPriorFamily.GetSetSelectedIndex = -1 + Me.ucrInputPriorFamily.IsReadOnly = False + Me.ucrInputPriorFamily.Location = New System.Drawing.Point(136, 9) + Me.ucrInputPriorFamily.Margin = New System.Windows.Forms.Padding(5) + Me.ucrInputPriorFamily.Name = "ucrInputPriorFamily" + Me.ucrInputPriorFamily.Size = New System.Drawing.Size(133, 21) + Me.ucrInputPriorFamily.TabIndex = 88 + ' + 'lblPriorFamily + ' + Me.lblPriorFamily.AutoSize = True + Me.lblPriorFamily.Location = New System.Drawing.Point(71, 13) + Me.lblPriorFamily.Name = "lblPriorFamily" + Me.lblPriorFamily.Size = New System.Drawing.Size(63, 13) + Me.lblPriorFamily.TabIndex = 89 + Me.lblPriorFamily.Text = "Prior Family:" + ' + 'sdgPriorParameters + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(274, 246) + Me.Controls.Add(Me.lblPriorFamily) + Me.Controls.Add(Me.ucrInputPriorFamily) + Me.Controls.Add(Me.ucrNudPrioirNull) + Me.Controls.Add(Me.lblStandardDeviation) + Me.Controls.Add(Me.lblDegreesFreedom) + Me.Controls.Add(Me.lblScalingParameter) + Me.Controls.Add(Me.lblPrioir) + Me.Controls.Add(Me.lblSampleSize) + Me.Controls.Add(Me.ucrNudStandardDeviation) + Me.Controls.Add(Me.ucrNudDegreesFreedom) + Me.Controls.Add(Me.ucrNudScaleParameter) + Me.Controls.Add(Me.ucrNudSampleSize) + Me.Controls.Add(Me.ucrSdgButtons) + Me.Controls.Add(Me.grpHypothesisPrior) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "sdgPriorParameters" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Prior Parameters" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents ucrSdgButtons As ucrButtonsSubdialogue + Friend WithEvents ucrNudSampleSize As ucrNud + Friend WithEvents ucrNudScaleParameter As ucrNud + Friend WithEvents ucrNudDegreesFreedom As ucrNud + Friend WithEvents ucrNudStandardDeviation As ucrNud + Friend WithEvents lblSampleSize As Label + Friend WithEvents lblPrioir As Label + Friend WithEvents lblScalingParameter As Label + Friend WithEvents lblDegreesFreedom As Label + Friend WithEvents lblStandardDeviation As Label + Friend WithEvents grpHypothesisPrior As GroupBox + Friend WithEvents ucrNudPrioirNull As ucrInputComboBox + Friend WithEvents ucrInputPriorFamily As ucrInputComboBox + Friend WithEvents lblPriorFamily As Label +End Class diff --git a/instat/sdgPriorParameters.resx b/instat/sdgPriorParameters.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgPriorParameters.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/sdgPriorParameters.vb b/instat/sdgPriorParameters.vb new file mode 100644 index 00000000000..e82efa17102 --- /dev/null +++ b/instat/sdgPriorParameters.vb @@ -0,0 +1,88 @@ +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . +Imports instat.Translations +Public Class sdgPriorParameters + Private bControlsInitialised As Boolean = False + Private bFirstLoad As Boolean = True + + Private clsBayesInferenceFunction, clsConcatenateFunction As New RFunction + + Private Sub sdgPriorParameters_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + End Sub + + Private Sub InitialiseControls() + Dim dctNullHypothesis As New Dictionary(Of String, String) + Dim dctPriorFamily As New Dictionary(Of String, String) + ucrNudSampleSize.SetParameter(New RParameter("n_0", 10)) + ucrNudSampleSize.SetMinMax(1, Integer.MaxValue) + ucrNudSampleSize.SetRDefault(1) + + ucrNudStandardDeviation.SetParameter(New RParameter("s_0", 11)) + ucrNudStandardDeviation.SetMinMax(0, Integer.MaxValue) + ucrNudStandardDeviation.SetRDefault(0) + + ucrNudDegreesFreedom.SetParameter(New RParameter("v_0", 12)) + ucrNudDegreesFreedom.SetMinMax(-1, Integer.MaxValue) + ucrNudDegreesFreedom.SetRDefault(-1) + + ucrNudScaleParameter.SetParameter(New RParameter("rscale", 13)) + ucrNudScaleParameter.SetMinMax(1, Integer.MaxValue) + ucrNudScaleParameter.SetRDefault(1) + + ucrNudPrioirNull.SetParameter(New RParameter("H1", 0)) + dctNullHypothesis.Add("0.1", "0.1") + dctNullHypothesis.Add("0.2", "0.2") + dctNullHypothesis.Add("0.5", "0.5") + dctNullHypothesis.Add("0.8", "0.8") + dctNullHypothesis.Add("0.9", "0.9") + ucrNudPrioirNull.SetItems(dctNullHypothesis) + ucrNudPrioirNull.AddQuotesIfUnrecognised = False + ucrNudPrioirNull.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) + ucrNudPrioirNull.bAllowNonConditionValues = True + ucrNudPrioirNull.SetRDefault(0.5) + + ucrInputPriorFamily.SetParameter(New RParameter("prior", 14)) + dctPriorFamily.Add("Jeffreys-reference prior", Chr(34) & "JZS" & Chr(34)) + dctPriorFamily.Add("Unit Information prior", Chr(34) & "JUI" & Chr(34)) + dctPriorFamily.Add("Normal-Gamma prior", Chr(34) & "NG" & Chr(34)) + ucrInputPriorFamily.SetItems(dctPriorFamily) + ucrInputPriorFamily.SetRDefault("JSZ") + ucrInputPriorFamily.SetDropDownStyleAsNonEditable() + + ucrNudSampleSize.SetLinkedDisplayControl(lblSampleSize) + ucrNudScaleParameter.SetLinkedDisplayControl(lblScalingParameter) + ucrNudStandardDeviation.SetLinkedDisplayControl(lblStandardDeviation) + ucrNudDegreesFreedom.SetLinkedDisplayControl(lblDegreesFreedom) + ucrNudPrioirNull.SetLinkedDisplayControl(lblPrioir) + End Sub + + Public Sub SetRFunction(clsNewBayesIferenceFunction As RFunction, clsNewConcatenateFunction As RFunction, Optional bReset As Boolean = False) + If Not bControlsInitialised Then + InitialiseControls() + End If + + clsBayesInferenceFunction = clsNewBayesIferenceFunction + clsConcatenateFunction = clsNewConcatenateFunction + + ucrNudSampleSize.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudDegreesFreedom.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudScaleParameter.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudStandardDeviation.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrInputPriorFamily.SetRCode(clsBayesInferenceFunction, bReset, bCloneIfNeeded:=True) + ucrNudPrioirNull.SetRCode(clsConcatenateFunction, bReset, bCloneIfNeeded:=True) + End Sub +End Class \ No newline at end of file diff --git a/instat/sdgPriorProportions.Designer.vb b/instat/sdgPriorProportions.Designer.vb new file mode 100644 index 00000000000..82e8a0cba3d --- /dev/null +++ b/instat/sdgPriorProportions.Designer.vb @@ -0,0 +1,161 @@ + _ +Partial Class sdgPriorProportions + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.ucrNudPrioirNull = New instat.ucrInputComboBox() + Me.lblPrioir = New System.Windows.Forms.Label() + Me.grpHypothesisPrior = New System.Windows.Forms.GroupBox() + Me.lblBataA = New System.Windows.Forms.Label() + Me.grpBetaPriors = New System.Windows.Forms.GroupBox() + Me.ucrNudBetaPrioirA = New instat.ucrNud() + Me.ucrSdgButtons = New instat.ucrButtonsSubdialogue() + Me.ucrNudBetaPrioirB = New instat.ucrNud() + Me.lblBetaB = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'ucrNudPrioirNull + ' + Me.ucrNudPrioirNull.AddQuotesIfUnrecognised = True + Me.ucrNudPrioirNull.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrNudPrioirNull.GetSetSelectedIndex = -1 + Me.ucrNudPrioirNull.IsReadOnly = False + Me.ucrNudPrioirNull.Location = New System.Drawing.Point(42, 28) + Me.ucrNudPrioirNull.Margin = New System.Windows.Forms.Padding(5) + Me.ucrNudPrioirNull.Name = "ucrNudPrioirNull" + Me.ucrNudPrioirNull.Size = New System.Drawing.Size(81, 21) + Me.ucrNudPrioirNull.TabIndex = 90 + ' + 'lblPrioir + ' + Me.lblPrioir.AutoSize = True + Me.lblPrioir.Location = New System.Drawing.Point(12, 32) + Me.lblPrioir.Name = "lblPrioir" + Me.lblPrioir.Size = New System.Drawing.Size(24, 13) + Me.lblPrioir.TabIndex = 88 + Me.lblPrioir.Text = "H1:" + ' + 'grpHypothesisPrior + ' + Me.grpHypothesisPrior.Location = New System.Drawing.Point(5, 9) + Me.grpHypothesisPrior.Name = "grpHypothesisPrior" + Me.grpHypothesisPrior.Size = New System.Drawing.Size(146, 57) + Me.grpHypothesisPrior.TabIndex = 89 + Me.grpHypothesisPrior.TabStop = False + Me.grpHypothesisPrior.Text = "Hypothesis Prior" + ' + 'lblBataA + ' + Me.lblBataA.AutoSize = True + Me.lblBataA.Location = New System.Drawing.Point(13, 101) + Me.lblBataA.Name = "lblBataA" + Me.lblBataA.Size = New System.Drawing.Size(16, 13) + Me.lblBataA.TabIndex = 91 + Me.lblBataA.Text = "a:" + ' + 'grpBetaPriors + ' + Me.grpBetaPriors.Location = New System.Drawing.Point(6, 79) + Me.grpBetaPriors.Name = "grpBetaPriors" + Me.grpBetaPriors.Size = New System.Drawing.Size(145, 78) + Me.grpBetaPriors.TabIndex = 92 + Me.grpBetaPriors.TabStop = False + Me.grpBetaPriors.Text = "Beta Priors" + ' + 'ucrNudBetaPrioirA + ' + Me.ucrNudBetaPrioirA.AutoSize = True + Me.ucrNudBetaPrioirA.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudBetaPrioirA.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudBetaPrioirA.Location = New System.Drawing.Point(37, 98) + Me.ucrNudBetaPrioirA.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudBetaPrioirA.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudBetaPrioirA.Name = "ucrNudBetaPrioirA" + Me.ucrNudBetaPrioirA.Size = New System.Drawing.Size(50, 20) + Me.ucrNudBetaPrioirA.TabIndex = 93 + Me.ucrNudBetaPrioirA.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'ucrSdgButtons + ' + Me.ucrSdgButtons.AutoSize = True + Me.ucrSdgButtons.Location = New System.Drawing.Point(3, 169) + Me.ucrSdgButtons.Name = "ucrSdgButtons" + Me.ucrSdgButtons.Size = New System.Drawing.Size(224, 30) + Me.ucrSdgButtons.TabIndex = 94 + ' + 'ucrNudBetaPrioirB + ' + Me.ucrNudBetaPrioirB.AutoSize = True + Me.ucrNudBetaPrioirB.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudBetaPrioirB.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudBetaPrioirB.Location = New System.Drawing.Point(37, 126) + Me.ucrNudBetaPrioirB.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudBetaPrioirB.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudBetaPrioirB.Name = "ucrNudBetaPrioirB" + Me.ucrNudBetaPrioirB.Size = New System.Drawing.Size(50, 20) + Me.ucrNudBetaPrioirB.TabIndex = 95 + Me.ucrNudBetaPrioirB.Value = New Decimal(New Integer() {0, 0, 0, 0}) + ' + 'lblBetaB + ' + Me.lblBetaB.AutoSize = True + Me.lblBetaB.Location = New System.Drawing.Point(11, 130) + Me.lblBetaB.Name = "lblBetaB" + Me.lblBetaB.Size = New System.Drawing.Size(16, 13) + Me.lblBetaB.TabIndex = 96 + Me.lblBetaB.Text = "b:" + ' + 'sdgPriorProportions + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(228, 216) + Me.Controls.Add(Me.lblBetaB) + Me.Controls.Add(Me.ucrNudBetaPrioirB) + Me.Controls.Add(Me.ucrSdgButtons) + Me.Controls.Add(Me.ucrNudBetaPrioirA) + Me.Controls.Add(Me.lblBataA) + Me.Controls.Add(Me.grpBetaPriors) + Me.Controls.Add(Me.ucrNudPrioirNull) + Me.Controls.Add(Me.lblPrioir) + Me.Controls.Add(Me.grpHypothesisPrior) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "sdgPriorProportions" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Proportions Prioirs" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents ucrNudPrioirNull As ucrInputComboBox + Friend WithEvents lblPrioir As Label + Friend WithEvents grpHypothesisPrior As GroupBox + Friend WithEvents lblBataA As Label + Friend WithEvents grpBetaPriors As GroupBox + Friend WithEvents ucrNudBetaPrioirA As ucrNud + Friend WithEvents ucrSdgButtons As ucrButtonsSubdialogue + Friend WithEvents ucrNudBetaPrioirB As ucrNud + Friend WithEvents lblBetaB As Label +End Class diff --git a/instat/sdgPriorProportions.resx b/instat/sdgPriorProportions.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgPriorProportions.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/sdgPriorProportions.vb b/instat/sdgPriorProportions.vb new file mode 100644 index 00000000000..4d40dc873b9 --- /dev/null +++ b/instat/sdgPriorProportions.vb @@ -0,0 +1,62 @@ +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . +Imports instat.Translations +Public Class sdgPriorProportions + Private bControlsInitialised As Boolean = False + + + Private clsBayesInferenceFunction, clsConcatenateFunction, clsConcatenateBetaFuction As New RFunction + Private Sub sdgPriorProportions_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + End Sub + Private Sub InitialiseControls() + Dim dctNullHypothesis As New Dictionary(Of String, String) + + ucrNudBetaPrioirA.SetParameter(New RParameter("a", 11)) + ucrNudBetaPrioirA.SetMinMax(0, Integer.MaxValue) + ucrNudBetaPrioirA.SetRDefault(1) + + ucrNudBetaPrioirB.SetParameter(New RParameter("b", 12)) + ucrNudBetaPrioirB.SetMinMax(1, Integer.MaxValue) + ucrNudBetaPrioirB.SetRDefault(1) + + ucrNudPrioirNull.SetParameter(New RParameter("H1", 0)) + dctNullHypothesis.Add("0.1", "0.1") + dctNullHypothesis.Add("0.2", "0.2") + dctNullHypothesis.Add("0.5", "0.5") + dctNullHypothesis.Add("0.8", "0.8") + dctNullHypothesis.Add("0.9", "0.9") + ucrNudPrioirNull.SetItems(dctNullHypothesis) + ucrNudPrioirNull.AddQuotesIfUnrecognised = False + ucrNudPrioirNull.SetValidationTypeAsNumeric(dcmMin:=0.0, bIncludeMin:=True, dcmMax:=1.0, bIncludeMax:=True) + ucrNudPrioirNull.bAllowNonConditionValues = True + ucrNudPrioirNull.SetRDefault(0.5) + End Sub + + Public Sub SetRFunction(clsNewConcatenateFunction As RFunction, clsNewConcatenateBetaFuction As RFunction, Optional bReset As Boolean = False) + If Not bControlsInitialised Then + InitialiseControls() + End If + + clsConcatenateFunction = clsNewConcatenateFunction + clsConcatenateBetaFuction = clsNewConcatenateBetaFuction + + ucrNudBetaPrioirA.SetRCode(clsConcatenateBetaFuction, bReset, bCloneIfNeeded:=True) + ucrNudBetaPrioirB.SetRCode(clsConcatenateBetaFuction, bReset, bCloneIfNeeded:=True) + + ucrNudPrioirNull.SetRCode(clsConcatenateFunction, bReset, bCloneIfNeeded:=True) + End Sub +End Class \ No newline at end of file diff --git a/instat/ucrDistributions.vb b/instat/ucrDistributions.vb index c5421a64138..720cfdbf3be 100644 --- a/instat/ucrDistributions.vb +++ b/instat/ucrDistributions.vb @@ -239,6 +239,7 @@ Public Class ucrDistributions Dim clsGlmNegativeBinomialDist As New Distribution Dim clsPolarDist As New Distribution Dim clsMultinomDist As New Distribution + Dim clsBayesLinearRegression As New Distribution ' Normal distribution clsNormalDist.strNameTag = "Normal" @@ -552,6 +553,15 @@ Public Class ucrDistributions clsPolarDist.strGLMFunctionName = "polr" lstAllDistributions.Add(clsPolarDist) + 'Bayes Simple linear regression + clsBayesLinearRegression.strNameTag = "Bayes" + clsBayesLinearRegression.strPackagName = "BAS" + clsBayesLinearRegression.strRName = "bas.lm" + clsBayesLinearRegression.strGLMFunctionName = "bas.lm" + clsBayesLinearRegression.bNumeric = True + clsBayesLinearRegression.bTwoLevelFactor = True + lstAllDistributions.Add(clsBayesLinearRegression) + 'multinomial distribution clsMultinomDist.strNameTag = "Multinomial" clsMultinomDist.strPackagName = "nnet"