From 780ac4498cd5243e98c0f741999229fd00062cb6 Mon Sep 17 00:00:00 2001 From: FBartos Date: Fri, 22 Nov 2024 17:31:39 +0100 Subject: [PATCH 1/4] Merge remote-tracking branch 'upstream/master' From 1b39c396b4712117b602c56d67945d4970ad3cc2 Mon Sep 17 00:00:00 2001 From: FBartos Date: Fri, 22 Nov 2024 17:14:21 +0100 Subject: [PATCH 2/4] fixes --- R/bayesianmetaanalysiscommon.R | 2 +- R/bayesianpredictionperformance.R | 2 +- R/classicalpredictionperformance.R | 28 ++------ R/selectionmodels.R | 19 +---- R/waapwlspetpeese.R | 4 +- inst/Description.qml | 5 ++ inst/Upgrades.qml | 70 ++++++++++++++++++- .../PredictionPerformanceInference.qml | 22 ++++-- inst/qmldir | 3 - 9 files changed, 105 insertions(+), 50 deletions(-) diff --git a/R/bayesianmetaanalysiscommon.R b/R/bayesianmetaanalysiscommon.R index 6b6b47d3..c3abaf49 100644 --- a/R/bayesianmetaanalysiscommon.R +++ b/R/bayesianmetaanalysiscommon.R @@ -301,7 +301,7 @@ SE <- dataset[, options[["effectSizeSe"]]] .hasErrors(dataset = dataset, seCheck.target = options[["effectSizeSe"]], - custom = .metaAnalysisCheckSE, + custom = .maCheckStandardErrors, exitAnalysisIfErrors = TRUE) } diff --git a/R/bayesianpredictionperformance.R b/R/bayesianpredictionperformance.R index 90ebc64d..c3d90e72 100644 --- a/R/bayesianpredictionperformance.R +++ b/R/bayesianpredictionperformance.R @@ -21,7 +21,7 @@ BayesianPredictionPerformance <- function(jaspResults, dataset, options, state ready <- .metamiscReady(options) if (ready) { - dataset <- .metamiscGetData(options, dataset) + .metamiscCheckData(options, dataset) .metamiscFitModelBayesian(jaspResults, options, dataset) } diff --git a/R/classicalpredictionperformance.R b/R/classicalpredictionperformance.R index 847d0618..c2804f29 100644 --- a/R/classicalpredictionperformance.R +++ b/R/classicalpredictionperformance.R @@ -21,7 +21,7 @@ ClassicalPredictionPerformance <- function(jaspResults, dataset, options, stat ready <- .metamiscReady(options) if (ready) { - dataset <- .metamiscGetData(options, dataset) + .metamiscCheckData(options, dataset) .metamiscFitModel(jaspResults, options, dataset) } @@ -76,27 +76,12 @@ ClassicalPredictionPerformance <- function(jaspResults, dataset, options, stat return(FALSE) } -.metamiscGetData <- function(options, dataset) { - - if (!is.null(dataset)) - return(dataset) - +.metamiscCheckData <- function(options, dataset) { varNames <- c(options[["effectSize"]], options[["effectSizeSe"]], unlist(options[["effectSizeCi"]]), options[["numberOfParticipants"]], options[["numberOfObservedEvents"]], options[["numberOfExpectedEvents"]]) varNames <- varNames[varNames != ""] - dataset <- readDataSetToEnd( - columns.as.numeric = varNames, - columns = if (options[["studyLabel"]] != "") options[["studyLabel"]] - ) - - if (options[["studyLabel"]] != "") { - dataset[[options[["studyLabel"]]]] <- as.character(dataset[[options[["studyLabel"]]]]) - if (any(!validUTF8(dataset[[options[["studyLabel"]]]]))) - .quitAnalysis(gettext("The study labels contain invalid characters. Please, remove them before running the analysis.")) - } - .hasErrors(dataset = dataset[,varNames], type = c("infinity", "observations", "negativeValues"), observations.amount = "< 2", @@ -104,11 +89,10 @@ ClassicalPredictionPerformance <- function(jaspResults, dataset, options, stat .hasErrors(dataset = dataset, seCheck.target = varNames[varNames %in% c(options[["effectSizeSe"]],options[["numberOfParticipants"]])], - custom = .metaAnalysisCheckSE, + custom = .maCheckStandardErrors, exitAnalysisIfErrors = TRUE) - - return(dataset) + return() } .metamiscFitModel <- function(jaspResults, options, dataset) { @@ -133,7 +117,7 @@ ClassicalPredictionPerformance <- function(jaspResults, dataset, options, stat O = if (options[["numberOfObservedEvents"]] != "") dataset[, options[["numberOfObservedEvents"]]], E = if (options[["numberOfExpectedEvents"]] != "") dataset[, options[["numberOfExpectedEvents"]]], slab = if (options[["studyLabel"]] != "") dataset[, options[["studyLabel"]]], - method = .metaAnalysisGetMethod(options), + method = .maGetMethodOptions(options), pars = list( model.oe = if (options[["measure"]] == "oeRatio") options[["withinStudyVariation"]], model.cstat = if (options[["measure"]] == "cStatistic") options[["withinStudyVariation"]]) @@ -340,7 +324,7 @@ ClassicalPredictionPerformance <- function(jaspResults, dataset, options, stat fatFits <- modelsFat[["object"]] # switch the theta / theta.se location according to the link (poisson/log derives and stores the values at different place) - if (options[["withinStudyVariation"]] == "poisson/log" && options$method != "BAYES" && .metaAnalysisGetMethod(options) != "FE") { + if (options[["withinStudyVariation"]] == "poisson/log" && options$method != "BAYES" && .maGetMethodOptions(options) != "FE") { theta <- "theta.blup" theta.se <- "theta.se.blup" } else { diff --git a/R/selectionmodels.R b/R/selectionmodels.R index 776c4ca3..38ba3557 100644 --- a/R/selectionmodels.R +++ b/R/selectionmodels.R @@ -18,8 +18,7 @@ SelectionModels <- function(jaspResults, dataset, options, state = NULL) { if (.smCheckReady(options)) { - # get the data - dataset <- .smGetData(dataset, options) + # check the data dataset <- .smCheckData(jaspResults, dataset, options) # fit the models @@ -57,18 +56,6 @@ SelectionModels <- function(jaspResults, dataset, options, state = NULL) { return(options[["effectSize"]] != "" && options[["sampleSize"]] != "") } } -.smGetData <- function(dataset, options) { - if (!is.null(dataset)) { - return(dataset) - } else { - return(.readDataSetToEnd(columns.as.numeric = c( - options[["effectSize"]], - if (options[["effectSizeSe"]] != "") options[["effectSizeSe"]], - if (options[["sampleSize"]] != "") options[["sampleSize"]], - if (options[["pValue"]] != "") options[["pValue"]] - ))) - } -} .smCheckData <- function(jaspResults, dataset, options) { dataset_old <- dataset @@ -94,14 +81,14 @@ SelectionModels <- function(jaspResults, dataset, options, state = NULL) { if (options[["effectSizeSe"]] != "") .hasErrors(dataset = dataset, seCheck.target = options[["effectSizeSe"]], - custom = .metaAnalysisCheckSE, + custom = .maCheckStandardErrors, exitAnalysisIfErrors = TRUE) if (options[["sampleSize"]] != "") .hasErrors(dataset = dataset, seCheck.target = options[["sampleSize"]], - custom = .metaAnalysisCheckSE, + custom = .maCheckStandardErrors, exitAnalysisIfErrors = TRUE) diff --git a/R/waapwlspetpeese.R b/R/waapwlspetpeese.R index 282594d0..9a0e6fec 100644 --- a/R/waapwlspetpeese.R +++ b/R/waapwlspetpeese.R @@ -61,13 +61,13 @@ if (options[["effectSizeSe"]] != "") .hasErrors(dataset = dataset, seCheck.target = options[["effectSizeSe"]], - custom = .metaAnalysisCheckSE, + custom = .maCheckStandardErrors, exitAnalysisIfErrors = TRUE) if (options[["sampleSize"]] != "") .hasErrors(dataset = dataset, seCheck.target = options[["sampleSize"]], - custom = .metaAnalysisCheckSE, + custom = .maCheckStandardErrors, exitAnalysisIfErrors = TRUE) diff --git a/inst/Description.qml b/inst/Description.qml index 3fb4cb72..afd5173a 100644 --- a/inst/Description.qml +++ b/inst/Description.qml @@ -101,6 +101,7 @@ Description title: qsTr("Bayesian Meta-Analysis") func: "BayesianMetaAnalysis" requiresData: true + preloadData: false } Analysis @@ -109,6 +110,7 @@ Description title: qsTr("Bayesian Binomial Meta-Analysis") func: "BayesianBinomialMetaAnalysis" requiresData: true + preloadData: false } Analysis @@ -117,6 +119,7 @@ Description title: qsTr("Penalized Meta-Analysis") func: "PenalizedMetaAnalysis" requiresData: true + preloadData: false } Analysis @@ -125,6 +128,7 @@ Description title: qsTr("Bayesian Prediction Model Performance") func: "BayesianPredictionPerformance" requiresData: true + preloadData: false } Analysis @@ -132,5 +136,6 @@ Description title: qsTr("Robust Bayesian Meta-Analysis") func: "RobustBayesianMetaAnalysis" requiresData: false + preloadData: false } } diff --git a/inst/Upgrades.qml b/inst/Upgrades.qml index 73b83b3a..0f2009cd 100644 --- a/inst/Upgrades.qml +++ b/inst/Upgrades.qml @@ -651,9 +651,9 @@ Upgrades ChangeJS { - name: "inferenceOutputScale" jsFunction: function(options) { + name: "inferenceOutputScale" switch(options["inferenceOutputScale"]) { case "correlation": return "r"; @@ -662,4 +662,72 @@ Upgrades } } } + + Upgrade + { + functionName: "ClassicalPredictionPerformance" + fromVersion: "0.19.1" + toVersion: "0.19.2" + + ChangeJS + { + name: "withinStudyVariation" + jsFunction: function(options) + { + if (options[["measure"]] == "cStatistic") { + switch(options["withinStudyVariation"]) + { + case "normal/log": return "normal/logit"; + default: return options["withinStudyVariation"]; + } + } else { + return options["withinStudyVariation"] + } + } + } + + ChangeJS + { + name: "method" + jsFunction: function(options) + { + switch(options["withinStudyVariation"]) + { + case "Fixed Effects" : return "fixedEffects"; + case "Maximum Likelihood" : return "maximumLikelihood"; + case "Restricted ML" : return "restrictedML"; + case "DerSimonian-Laird" : return "derSimonianLaird"; + case "Hedges" : return "hedges"; + case "Hunter-Schmidt" : return "hunterSchmidt"; + case "Sidik-Jonkman" : return "sidikJonkman"; + case "Empirical Bayes" : return "empiricalBayes"; + case "Paule-Mandel" : return "pauleMandel"; + } + } + } + } + + Upgrade + { + functionName: "BayesianPredictionPerformance" + fromVersion: "0.19.1" + toVersion: "0.19.2" + + ChangeJS + { + name: "withinStudyVariation" + jsFunction: function(options) + { + if (options[["measure"]] == "cStatistic") { + switch(options["withinStudyVariation"]) + { + case "normal/log": return "normal/logit"; + default: return options["withinStudyVariation"]; + } + } else { + return options["withinStudyVariation"] + } + } + } + } } diff --git a/inst/qml/qml_components/PredictionPerformanceInference.qml b/inst/qml/qml_components/PredictionPerformanceInference.qml index 7a84505d..643b9c34 100644 --- a/inst/qml/qml_components/PredictionPerformanceInference.qml +++ b/inst/qml/qml_components/PredictionPerformanceInference.qml @@ -36,12 +36,26 @@ Section Group { - MA.ClassicalMetaAnalysisMethod + DropDown { - visible: analysisType == "classical" - id: method - } + name: "method" + label: qsTr("Method") + currentIndex: 2 + visible: analysisType == "classical" + values: [ + { label: qsTr("Fixed Effects") , value: "fixedEffects" }, + { label: qsTr("Maximum Likelihood") , value: "maximumLikelihood" }, + { label: qsTr("Restricted ML") , value: "restrictedML" }, + { label: qsTr("DerSimonian-Laird") , value: "derSimonianLaird" }, + { label: qsTr("Hedges") , value: "hedges" }, + { label: qsTr("Hunter-Schmidt") , value: "hunterSchmidt" }, + { label: qsTr("Sidik-Jonkman") , value: "sidikJonkman" }, + { label: qsTr("Empirical Bayes") , value: "empiricalBayes" }, + { label: qsTr("Paule-Mandel") , value: "pauleMandel" } + ] + } + DropDown { name: "withinStudyVariation" diff --git a/inst/qmldir b/inst/qmldir index 89c48869..245bcc2e 100644 --- a/inst/qmldir +++ b/inst/qmldir @@ -3,6 +3,3 @@ BayesianMetaAnalysisAdvanced 1.0 qml/qml_components/BayesianMetaAnalysisAdvanc BayesianMetaAnalysisInference 1.0 qml/qml_components/BayesianMetaAnalysisInference.qml BayesianMetaAnalysisPlots 1.0 qml/qml_components/BayesianMetaAnalysisPlots.qml BayesianMetaAnalysisPriors 1.0 qml/qml_components/BayesianMetaAnalysisPriors.qml -ClassicalMetaAnalysisDiagnostics 1.0 qml/qml_components/ClassicalMetaAnalysisDiagnostics.qml -ClassicalMetaAnalysisMethod 1.0 qml/qml_components/ClassicalMetaAnalysisMethod.qml -ClassicalMetaAnalysisStatistics 1.0 qml/qml_components/ClassicalMetaAnalysisStatistics.qml \ No newline at end of file From 6101f01bf09b40354f79722767683b9c4192d9cf Mon Sep 17 00:00:00 2001 From: FBartos Date: Fri, 22 Nov 2024 17:26:41 +0100 Subject: [PATCH 3/4] fix missing number of observations --- R/classicalmetaanalysiscommon.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/R/classicalmetaanalysiscommon.R b/R/classicalmetaanalysiscommon.R index d53b28ef..a0defd92 100644 --- a/R/classicalmetaanalysiscommon.R +++ b/R/classicalmetaanalysiscommon.R @@ -557,12 +557,13 @@ modelSummaryContainer[["fitMeasuresTable"]] <- fitMeasuresTable - fitMeasuresTable$addColumnInfo(name = "model", title = "", type = "string") - fitMeasuresTable$addColumnInfo(name = "ll", title = gettext("Log Lik."), type = "number") - fitMeasuresTable$addColumnInfo(name = "dev", title = gettext("Deviance"), type = "number") - fitMeasuresTable$addColumnInfo(name = "AIC", title = gettext("AIC"), type = "number") - fitMeasuresTable$addColumnInfo(name = "BIC", title = gettext("BIC"), type = "number") - fitMeasuresTable$addColumnInfo(name = "AICc", title = gettext("AICc"), type = "number") + fitMeasuresTable$addColumnInfo(name = "model", title = "", type = "string") + fitMeasuresTable$addColumnInfo(name = "observations", title = gettext("Observations"), type = "integer") + fitMeasuresTable$addColumnInfo(name = "ll", title = gettext("Log Lik."), type = "number") + fitMeasuresTable$addColumnInfo(name = "dev", title = gettext("Deviance"), type = "number") + fitMeasuresTable$addColumnInfo(name = "AIC", title = gettext("AIC"), type = "number") + fitMeasuresTable$addColumnInfo(name = "BIC", title = gettext("BIC"), type = "number") + fitMeasuresTable$addColumnInfo(name = "AICc", title = gettext("AICc"), type = "number") if (.maIsMetaregressionEffectSize(options) && !.maIsMultilevelMultivariate(options)) fitMeasuresTable$addColumnInfo(name = "R2", title = gettext("R\U00B2"), type = "number") @@ -571,7 +572,7 @@ if (is.null(fit) || jaspBase::isTryError(fit) || !is.null(.maCheckIsPossibleOptions(options))) return() - fitSummary <- cbind("model" = colnames(fit[["fit.stats"]]), data.frame(t(fit[["fit.stats"]]))) + fitSummary <- cbind("model" = colnames(fit[["fit.stats"]]), observations = fit[["k"]], data.frame(t(fit[["fit.stats"]]))) if (.maIsMetaregressionEffectSize(options) && !.maIsMultilevelMultivariate(options)) fitSummary$R2 <- fit[["R2"]] From a809426be5653479022e5ff18ddecb391f7fde66 Mon Sep 17 00:00:00 2001 From: FBartos Date: Wed, 4 Dec 2024 14:49:10 +0100 Subject: [PATCH 4/4] fix data loading --- R/petpeese.R | 3 +-- R/waapwls.R | 3 +-- R/waapwlspetpeese.R | 11 ----------- inst/Description.qml | 1 - 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/R/petpeese.R b/R/petpeese.R index c441bf06..3b0e40e0 100644 --- a/R/petpeese.R +++ b/R/petpeese.R @@ -18,8 +18,7 @@ PetPeese <- function(jaspResults, dataset, options, state = NULL) { if (.wwppCheckReady(options)) { - # get the data - dataset <- .wwppGetData(dataset, options) + # check the data dataset <- .wwppCheckData(jaspResults, dataset, options) # fit the models diff --git a/R/waapwls.R b/R/waapwls.R index 9137348b..491b748c 100644 --- a/R/waapwls.R +++ b/R/waapwls.R @@ -18,8 +18,7 @@ WaapWls <- function(jaspResults, dataset, options, state = NULL) { if (.wwppCheckReady(options)) { - # get the data - dataset <- .wwppGetData(dataset, options) + # check the data dataset <- .wwppCheckData(jaspResults, dataset, options) # fit the models diff --git a/R/waapwlspetpeese.R b/R/waapwlspetpeese.R index 9a0e6fec..d1b862c7 100644 --- a/R/waapwlspetpeese.R +++ b/R/waapwlspetpeese.R @@ -25,17 +25,6 @@ return(options[["effectSize"]] != "" && options[["sampleSize"]] != "") } } -.wwppGetData <- function(dataset, options) { - if (!is.null(dataset)) { - return(dataset) - } else { - return(.readDataSetToEnd(columns.as.numeric = c( - options[["effectSize"]], - if (options[["effectSizeSe"]] != "") options[["effectSizeSe"]], - if (options[["sampleSize"]] != "") options[["sampleSize"]] - ))) - } -} .wwppCheckData <- function(jaspResults, dataset, options) { dataset_old <- dataset diff --git a/inst/Description.qml b/inst/Description.qml index afd5173a..9a8bb8a9 100644 --- a/inst/Description.qml +++ b/inst/Description.qml @@ -128,7 +128,6 @@ Description title: qsTr("Bayesian Prediction Model Performance") func: "BayesianPredictionPerformance" requiresData: true - preloadData: false } Analysis