Skip to content

Commit

Permalink
Merge pull request IDEMSInternational#2226 from lilyclements/dlgNonPa…
Browse files Browse the repository at this point in the history
…rametricTwoWay

fixed bugs in regression simple and non parametric designer
  • Loading branch information
dannyparsons authored Nov 8, 2016
2 parents 702f8ef + 90c0f8f commit 6917698
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 67 deletions.
32 changes: 16 additions & 16 deletions instat/dlgNon_ParametricTwoWayAnova.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 60 additions & 51 deletions instat/dlgRegressionSimple.vb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ Public Class dlgRegressionSimple
ucrResponse.SetMeAsReceiver()
ucrSelectorSimpleReg.Focus()
chkSaveModel.Checked = True
chkSaveModel.Enabled = True
ucrModelName.Visible = True
chkConvertToVariate.Checked = False
chkConvertToVariate.Visible = False
chkFunction.Checked = False
Expand All @@ -88,27 +86,25 @@ Public Class dlgRegressionSimple
sdgSimpleRegOptions.chkDisplayCLimits.Enabled = True
sdgSimpleRegOptions.lblDisplayCLevel.Enabled = True
sdgSimpleRegOptions.nudDisplayCLevel.Enabled = True
SetEnableDists()
End Sub

Private Sub LM()
clsRLmOrGLM.ClearParameters()
clsRLmOrGLM.SetRCommand("lm")
clsRLmOrGLM.AddParameter("data", clsRFunctionParameter:=ucrSelectorSimpleReg.ucrAvailableDataFrames.clsCurrDataFrame)
ucrBase.clsRsyntax.SetBaseRFunction(clsRLmOrGLM)
clsRLmOrGLM.AddParameter("formula", clsROperatorParameter:=clsModel)
clsModel.SetOperation("~")
clsRLmOrGLM.AddParameter("data", ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
ConvertToVariate()
End Sub

Private Sub GLM()
clsRLmOrGLM.ClearParameters()
clsRLmOrGLM.SetRCommand("glm")
clsRLmOrGLM.AddParameter("data", clsRFunctionParameter:=ucrSelectorSimpleReg.ucrAvailableDataFrames.clsCurrDataFrame)
ucrBase.clsRsyntax.SetBaseRFunction(clsRLmOrGLM)
clsRLmOrGLM.AddParameter("formula", clsROperatorParameter:=clsModel)
clsModel.SetOperation("~")
clsRCIFunction.SetRCommand(ucrFamily.clsCurrDistribution.strGLMFunctionName)
clsRLmOrGLM.AddParameter("family", clsRFunctionParameter:=clsRCIFunction)
ConvertToVariate()
End Sub

Private Sub SetTTest()
Expand Down Expand Up @@ -180,6 +176,9 @@ Public Class dlgRegressionSimple
End Sub

Private Sub SetPoissonTest()
Dim clsxFunc As New RFunction
Dim clsTFunc As New RFunction

If ucrFamily.clsCurrDistribution.strNameTag = "Poisson" Then
If ucrExplanatory.strCurrDataType = "factor" Or ucrExplanatory.strCurrDataType = "character" Then
ucrExplanatory.Clear()
Expand All @@ -200,8 +199,16 @@ Public Class dlgRegressionSimple
clsRMean.AddParameter("x", clsRFunctionParameter:=ucrResponse.GetVariables())
clsRMean2.SetRCommand("mean")
clsRMean2.AddParameter("x", clsRFunctionParameter:=ucrExplanatory.GetVariables())
clsRPoisson.AddParameter("x", "c(" & clsRLength.ToScript & "," & clsRLength2.ToScript & ")")
clsRPoisson.AddParameter("T", "c(" & clsRMean.ToScript & "," & clsRMean2.ToScript & ")")

clsxFunc.SetRCommand("c")
clsxFunc.AddParameter("l1", clsRFunctionParameter:=clsRLength, bIncludeArgumentName:=False)
clsxFunc.AddParameter("l2", clsRFunctionParameter:=clsRLength2, bIncludeArgumentName:=False)
clsRPoisson.AddParameter("x", clsRFunctionParameter:=clsxFunc)

clsTFunc.SetRCommand("c")
clsTFunc.AddParameter("m1", clsRFunctionParameter:=clsRMean, bIncludeArgumentName:=False)
clsTFunc.AddParameter("m2", clsRFunctionParameter:=clsRMean2, bIncludeArgumentName:=False)
clsRPoisson.AddParameter("T", clsRFunctionParameter:=clsTFunc)
End Sub

Private Sub SetRCode()
Expand All @@ -212,10 +219,8 @@ Public Class dlgRegressionSimple
clsRLmOrGLM.ClearParameters()
If rdoGeneral.Checked Then
If (ucrFamily.clsCurrDistribution.strNameTag = "Normal") Then
clsRLmOrGLM.ClearParameters()
LM()
Else
clsRLmOrGLM.ClearParameters()
GLM()
End If
ElseIf rdoSpecific.Checked Then
Expand Down Expand Up @@ -254,50 +259,59 @@ Public Class dlgRegressionSimple
End Sub

Public Sub ConvertToVariate()
If rdoGeneral.Checked AndAlso Not ucrResponse.IsEmpty Then
' ucrFamily.RecieverDatatype(ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text, ucrResponse.GetVariableNames(bWithQuotes:=False))
If ucrFamily.strDataType = "numeric" Then
chkConvertToVariate.Checked = False
chkConvertToVariate.Visible = False
If rdoGeneral.Checked Then
If Not ucrResponse.IsEmpty Then
ucrFamily.RecieverDatatype(ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text, ucrResponse.GetVariableNames(bWithQuotes:=False))
If ucrFamily.strDataType = "numeric" Then
chkConvertToVariate.Checked = False
chkConvertToVariate.Visible = False
Else
chkConvertToVariate.Visible = True
End If
sdgModelOptions.ucrFamily.RecieverDatatype(ucrFamily.strDataType)
If chkConvertToVariate.Checked Then
clsRConvert.SetRCommand("as.numeric")
clsRConvert.AddParameter("x", ucrResponse.GetVariableNames(bWithQuotes:=False))
clsModel.SetParameter(True, clsRFunc:=clsRConvert)
clsModel.SetParameter(False, clsRFunc:=ucrExplanatory.GetVariables())
ucrFamily.RecieverDatatype("numeric")
Else
clsModel.SetParameter(True, clsRFunc:=ucrResponse.GetVariables())
clsModel.SetParameter(False, clsRFunc:=ucrExplanatory.GetVariables())
clsModel.SetParameter(True, strValue:=ucrResponse.GetVariableNames(bWithQuotes:=False))
ucrFamily.RecieverDatatype(ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text, ucrResponse.GetVariableNames(bWithQuotes:=False))
End If
Else
chkConvertToVariate.Visible = True
If ucrFamily.lstCurrentDistributions.Count = 0 Or ucrResponse.IsEmpty() Then
ucrFamily.cboDistributions.Text = ""
cmdModelOptions.Enabled = False
Else
cmdModelOptions.Enabled = True
End If
End If
sdgModelOptions.ucrFamily.RecieverDatatype(ucrFamily.strDataType)
End If

If chkConvertToVariate.Checked Then
clsRConvert.SetRCommand("as.numeric")
clsRConvert.AddParameter("x", ucrResponse.GetVariableNames(bWithQuotes:=False))
clsModel.SetParameter(True, clsRFunc:=clsRConvert)
clsModel.SetParameter(False, clsRFunc:=ucrExplanatory.GetVariables())
' ucrFamily.RecieverDatatype("numeric")
Else
clsModel.SetParameter(True, clsRFunc:=ucrResponse.GetVariables())
clsModel.SetParameter(False, clsRFunc:=ucrExplanatory.GetVariables())
clsModel.SetParameter(True, strValue:=ucrResponse.GetVariableNames(bWithQuotes:=False))
' ucrFamily.RecieverDatatype(ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text, ucrResponse.GetVariableNames(bWithQuotes:=False))
End If
If ucrFamily.lstCurrentDistributions.Count = 0 Or ucrResponse.IsEmpty() Then
ucrFamily.cboDistributions.Text = ""
cmdModelOptions.Enabled = False
Else
cmdModelOptions.Enabled = True
End If
End Sub

Private Sub DistributionsOffered()
If rdoGeneral.Checked Then
' ucrFamily.SetGLMDistributions()
ucrFamily.SetAllDistributions() ' this is just temporary. It will move back to SetGLMDistributions once some bugs are fixed
ucrFamily.SetGLMDistributions()
'ucrFamily.SetAllDistributions() ' this is just temporary. It will move back to SetGLMDistributions once some bugs are fixed
Else
ucrFamily.SetExactDistributions()
End If
End Sub

Private Sub ucrResponse_SelectionChanged() Handles ucrResponse.SelectionChanged
SetRCode()
ConvertToVariate()
TestOKEnabled()
DataTypeAccepted()
SetEnableDists()
End Sub

Public Sub SetEnableDists()
ucrFamily.Enabled = Not ucrResponse.IsEmpty
End Sub

Private Sub chkConvertToVariate_CheckedChanged(sender As Object, e As EventArgs) Handles chkConvertToVariate.CheckedChanged, chkConvertToVariate.VisibleChanged
Expand Down Expand Up @@ -350,9 +364,9 @@ Public Class dlgRegressionSimple

Private Sub chkModelName_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveModel.CheckedChanged
If chkSaveModel.Checked Then
ucrModelName.Enabled = True
ucrModelName.Visible = True
Else
ucrModelName.Enabled = False
ucrModelName.Visible = False
End If
AssignModelName()
TestOKEnabled()
Expand All @@ -361,7 +375,11 @@ Public Class dlgRegressionSimple
Private Sub AssignModelName()
If chkSaveModel.Checked AndAlso Not ucrModelName.IsEmpty Then
ucrBase.clsRsyntax.SetAssignTo(ucrModelName.GetText, strTempModel:=ucrModelName.GetText, strTempDataframe:=ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = True
If rdoGeneral.Checked Then
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = True
Else
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False
End If
Else
ucrBase.clsRsyntax.SetAssignTo("last_model", strTempModel:="last_model", strTempDataframe:=ucrSelectorSimpleReg.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False
Expand All @@ -372,7 +390,6 @@ Public Class dlgRegressionSimple
sdgModelOptions.ucrFamily.RecieverDatatype(ucrFamily.strDataType)
sdgModelOptions.ucrFamily.cboDistributions.SelectedIndex = sdgModelOptions.ucrFamily.lstCurrentDistributions.FindIndex(Function(dist) dist.strNameTag = ucrFamily.clsCurrDistribution.strNameTag)
sdgModelOptions.RestrictLink()
ConvertToVariate()
ExplanatoryFunctionSelect()
SetRCode()
Display()
Expand Down Expand Up @@ -467,14 +484,6 @@ Public Class dlgRegressionSimple
DistributionsOffered()
TestOKEnabled()
DataTypeAccepted()
If rdoGeneral.Checked Then
chkSaveModel.Enabled = True
ucrModelName.Visible = True
AssignModelName()
ElseIf rdoSpecific.Checked Then
chkSaveModel.Enabled = False
ucrModelName.Visible = False
ucrBase.clsRsyntax.RemoveAssignTo()
End If
AssignModelName()
End Sub
End Class

0 comments on commit 6917698

Please sign in to comment.