From c55e45aac8cdadc546aea1b4cd4589ea3ab746e8 Mon Sep 17 00:00:00 2001 From: FBartos Date: Mon, 18 Sep 2023 19:41:59 +0200 Subject: [PATCH 1/3] fix: plot prior distributions under custom models the previous versions was using prior list names generated from RoBMA which no longer matched the priors generated from options (as they had to be renamed) - the fix is a bit ugly but allows for consistency of the option names without renaming the package internals --- R/robustbayesianmetaanalysis.R | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/R/robustbayesianmetaanalysis.R b/R/robustbayesianmetaanalysis.R index e8809c0a..82d41d48 100644 --- a/R/robustbayesianmetaanalysis.R +++ b/R/robustbayesianmetaanalysis.R @@ -530,11 +530,11 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU # extract the priors if (is.null(jaspResults[["model"]]) && options[["modelEnsembleType"]] != "custom") - priors <- RoBMA::check_setup(model_type = options[["modelEnsembleType"]], silent = TRUE)$priors + priors <- .robmaPriorsToOptionsNames(RoBMA::check_setup(model_type = .robmaGetModelTypeOption(options), silent = TRUE)$priors) else if (is.null(jaspResults[["model"]])) priors <- jaspResults[["priors"]][["object"]] else - priors <- jaspResults[["model"]][["object"]][["priors"]] + priors <- .robmaPriorsToOptionsNames(jaspResults[["model"]][["object"]][["priors"]]) # create container for each of the parameters @@ -583,7 +583,12 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU parameterContainer[[type]] <- typeContainer } - tempPriors <- priors[[paste0(parameter, if (type == "null") "Null")]] + tempPriors <- priors[[paste0(switch( + parameter, + "effect" = "modelsEffect", + "heterogeneity" = "modelsHeterogeneity", + "bias" = "modelsBias" + ), if (type == "null") "Null")]] if (length(tempPriors) == 0) next @@ -1770,3 +1775,10 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU modelSaved[["object"]] <- TRUE } +.robmaPriorsToOptionsNames <- function(priors) { + priorNames <- names(priors) + substr(priorNames, 1, 1) <- toupper(substr(priorNames, 1, 1)) + priorNames <- paste0("models", priorNames) + names(priors) <- priorNames + return(priors) +} From c57670cc783701db71ba8dfdbc3a64d8b964b0e7 Mon Sep 17 00:00:00 2001 From: FBartos Date: Mon, 18 Sep 2023 19:44:18 +0200 Subject: [PATCH 2/3] fixing incorrectly disabled prior scale menu on custom --- inst/qml/RobustBayesianMetaAnalysis.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/qml/RobustBayesianMetaAnalysis.qml b/inst/qml/RobustBayesianMetaAnalysis.qml index a188efc0..53b9db23 100644 --- a/inst/qml/RobustBayesianMetaAnalysis.qml +++ b/inst/qml/RobustBayesianMetaAnalysis.qml @@ -230,7 +230,7 @@ Form id: priorScale name: "priorScale" label: qsTr("Prior scale") - enabled: !measuresFitted.checked && !measuresGeneral.checked && !modelType.value == "custom" + enabled: !measuresFitted.checked && !measuresGeneral.checked && modelType.value == "custom" values: [ { label: qsTr("Cohen's d"), value: "cohensD"}, From 75eec329d201a1f9d04c15aa50eac5d1085dc372 Mon Sep 17 00:00:00 2001 From: FBartos Date: Mon, 18 Sep 2023 20:35:11 +0200 Subject: [PATCH 3/3] fix displaying BF instead of marginal likelihood in model summary --- R/robustbayesianmetaanalysis.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/robustbayesianmetaanalysis.R b/R/robustbayesianmetaanalysis.R index 82d41d48..55109745 100644 --- a/R/robustbayesianmetaanalysis.R +++ b/R/robustbayesianmetaanalysis.R @@ -1006,7 +1006,7 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU # compute the BF requested if (options[["inferenceModelsOverviewBfComparison"]] == "inclusion") { - bf <- fitSummary[["summary"]][, 7] + bf <- fitSummary[["summary"]][, 8] } else if (options[["inferenceModelsOverviewBfComparison"]] == "best") { bf <- exp(fitSummary[["summary"]][["marglik"]] - max(fitSummary[["summary"]][["marglik"]])) } else if (options[["inferenceModelsOverviewBfComparison"]] == "previous") {