Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for RoBMA (vol. II) #197

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions R/robustbayesianmetaanalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1001,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") {
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion inst/qml/RobustBayesianMetaAnalysis.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
Loading