From 9f7194f62b73d6371ca31180768e66d59ca57f42 Mon Sep 17 00:00:00 2001 From: Koen Derks Date: Sun, 19 Jan 2025 12:50:51 -0500 Subject: [PATCH] Add mcmc options --- R/auditBayesianEvaluation.R | 5 +++ R/auditCommonFunctions.R | 2 +- inst/qml/common/planning/Algorithm.qml | 61 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/R/auditBayesianEvaluation.R b/R/auditBayesianEvaluation.R index 815bbaa1..e3098227 100644 --- a/R/auditBayesianEvaluation.R +++ b/R/auditBayesianEvaluation.R @@ -19,6 +19,11 @@ # reviewer in the pull Request. auditBayesianEvaluation <- function(jaspResults, dataset, options, ...) { + set.seed(options[["mcmc.seed"]]) + options(mc.iterations = options[["iter"]], + mc.warmup = options[["warmup"]], + mc.chains = options[["chains"]], + jfa.iterations = options[["iter"]]) # For the evaluation constituents, see auditCommonFunctions.R .jfaEvaluationStage(options, jaspResults, workflow = FALSE) .jfaCreatedByText(jaspResults) diff --git a/R/auditCommonFunctions.R b/R/auditCommonFunctions.R index 451a6554..a3ce53e3 100644 --- a/R/auditCommonFunctions.R +++ b/R/auditCommonFunctions.R @@ -742,7 +742,7 @@ "min_precision_test", "min_precision_rel_val", "by", "prior_method", "prior_n", "prior_x", "alpha", "beta", "critical_items", "critical_negative", "critical_action", - "stratum", "pooling", "hurdle" + "stratum", "pooling", "hurdle", "mcmc.seed", "iter", "warmup", "chains" )) jaspResults[["evaluationContainer"]] <- container diff --git a/inst/qml/common/planning/Algorithm.qml b/inst/qml/common/planning/Algorithm.qml index 1c93e031..b80ca436 100644 --- a/inst/qml/common/planning/Algorithm.qml +++ b/inst/qml/common/planning/Algorithm.qml @@ -100,4 +100,65 @@ Group helpPage: "Audit/hurdle" } } + + Section + { + title: qsTr("MCMC Options") + enabled: hurdle.checked || enable_pooling + info: qsTr("Options to customize the MCMC sampling process.") + visible: !(hide_hurdle && hide_pooling) + + Group + { + IntegerField + { + id: warmup + name: "warmup" + text: qsTr("Warmup") + defaultValue: 1000 + min: 100 + max: iter.value + fieldWidth: 60 * preferencesModel.uiScale + Layout.leftMargin: 15 * preferencesModel.uiScale + info: qsTr("Sets the number of warmup MCMC iterations.") + } + + IntegerField + { + id: iter + name: "iter" + text: qsTr("Iterations") + defaultValue: 2000 + min: warmup.value + max: 10000 + fieldWidth: 60 * preferencesModel.uiScale + Layout.leftMargin: 15 * preferencesModel.uiScale + info: qsTr("Sets the total number of MCMC iterations.") + } + + IntegerField + { + name: "chains" + text: qsTr("Chains") + defaultValue: 4 + min: 1 + max: 10 + fieldWidth: 60 * preferencesModel.uiScale + Layout.leftMargin: 15 * preferencesModel.uiScale + info: qsTr("Sets the number of MCMC chains.") + } + + IntegerField + { + name: "mcmc.seed" + text: qsTr("Seed") + defaultValue: Math.floor(Math.random() * 1000) // Init with random integer in [1,...,999] + min: -999 + max: 999 + fieldWidth: 60 * preferencesModel.uiScale + Layout.leftMargin: 15 * preferencesModel.uiScale + info: qsTr("Selects the seed for the random number generator in order to reproduce results.") + } + } + } }