Skip to content

Commit 8404650

Browse files
kylelangboutinb
andauthored
Proposed fix for release bug #2647 (#217)
* Adding a small positive minimum value to the QML form for the prior parameters; checking for non-positive prior parameters when parsing the options in R * adding conditional on the new error checks to get past unit tests * adding unit tests to check for illegal prior parameter error handlig * setting 'inclusive: 0' in the FormulaFields to enforce strictly positive prior parameters * Apply suggestions from code review Use false instead of 0 * Use JASP.None for inclusive property --------- Co-authored-by: bruno boutin <b.boutin@uva.nl>
1 parent cf89501 commit 8404650

File tree

7 files changed

+139
-247
lines changed

7 files changed

+139
-247
lines changed

R/LSbinaryclassification.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ LSbinaryclassification <- function(jaspResults, dataset, options, state = NULL)
8989
"falseNegative", "trueNegative", "falsePositive", "truePositive")
9090
)
9191

92+
priorParms <- options[grep("^prior\\w+[Alpha,Beta]$", names(options))] |>
93+
unlist() |>
94+
na.omit()
95+
96+
if(!is.null(priorParms) && length(priorParms) > 0 && !all(priorParms > 0))
97+
gettextf(
98+
"JAGS requires strictly positive parameters for Beta priors. Set {\u03B1, \u03B2} > 0 for the prior distributions of Prevalence, Sensitivity, and Specificity."
99+
) |>
100+
jaspBase::.quitAnalysis()
101+
92102
if(options[["inputType"]] == "pointEstimates") options[["ci"]] <- FALSE
93103

94104
colors <- .bcGetColors(options)[["values"]]

inst/qml/LSbinaryclassification.qml

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import QtQuick.Layouts 1.3
2020
import JASP.Controls 1.0
2121
import JASP.Widgets 1.0
2222
import JASP.Theme 1.0
23+
import JASP
2324
import "../qml/qml_components" as LS
2425

2526
Form {
@@ -46,17 +47,79 @@ Form {
4647
visible: inputType.value === "uncertainEstimates" || inputType.value === "data"
4748
columns: 3
4849
title: qsTr("Priors")
50+
4951
Text{ text: qsTr("Prevalence") }
50-
FormulaField { name: "priorPrevalenceAlpha"; label: qsTr("~ Beta(α = "); afterLabel: ","; min: 0; defaultValue: "1" ; fieldWidth: 65}
51-
FormulaField { name: "priorPrevalenceBeta"; label: "β = "; afterLabel: qsTr(")"); min: 0; defaultValue: "9"; fieldWidth: 65 }
52+
53+
FormulaField
54+
{
55+
name: "priorPrevalenceAlpha"
56+
label: qsTr("~ Beta(α = ")
57+
afterLabel: ","
58+
min: 0
59+
inclusive: JASP.None
60+
defaultValue: "1"
61+
fieldWidth: 65
62+
}
63+
64+
FormulaField
65+
{
66+
name: "priorPrevalenceBeta"
67+
label: "β = "
68+
afterLabel: qsTr(")");
69+
min: 0
70+
inclusive: JASP.None
71+
defaultValue: "9"
72+
fieldWidth: 65
73+
}
5274

5375
Text{ text: qsTr("Sensitivity") }
54-
FormulaField { name: "priorSensitivityAlpha"; label: qsTr("~ Beta(α = "); afterLabel: ","; min: 0; defaultValue: "8"; fieldWidth: 65 }
55-
FormulaField { name: "priorSensitivityBeta"; label: "β = "; afterLabel: qsTr(")"); min: 0; defaultValue: "2"; fieldWidth: 65 }
76+
77+
FormulaField
78+
{
79+
name: "priorSensitivityAlpha"
80+
label: qsTr("~ Beta(α = ")
81+
afterLabel: ","
82+
min: 0
83+
inclusive: JASP.None
84+
defaultValue: "8"
85+
fieldWidth: 65
86+
}
87+
88+
FormulaField
89+
{
90+
name: "priorSensitivityBeta"
91+
label: "β = "
92+
afterLabel: qsTr(")")
93+
min: 0
94+
inclusive: JASP.None
95+
defaultValue: "2"
96+
fieldWidth: 65
97+
}
5698

5799
Text{ text: qsTr("Specificity") }
58-
FormulaField { name: "priorSpecificityAlpha"; label: qsTr("~ Beta(α = "); afterLabel: ","; min: 0; defaultValue: "8"; fieldWidth: 65 }
59-
FormulaField { name: "priorSpecificityBeta"; label: "β = "; afterLabel: qsTr(")"); min: 0; defaultValue: "2"; fieldWidth: 65 }
100+
101+
FormulaField
102+
{
103+
name: "priorSpecificityAlpha"
104+
label: qsTr("~ Beta(α = ")
105+
afterLabel: ","
106+
min: 0
107+
inclusive: JASP.None
108+
defaultValue: "8"
109+
fieldWidth: 65
110+
}
111+
112+
FormulaField
113+
{
114+
name: "priorSpecificityBeta"
115+
label: "β = "
116+
afterLabel: qsTr(")")
117+
min: 0
118+
inclusive: JASP.None
119+
defaultValue: "2"
120+
fieldWidth: 65
121+
}
122+
60123
}
61124

62125
Group

tests/testthat/_snaps/lsbinaryclassification/alluvial-plot-data.svg

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)