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

Fixed Fixes #261

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion R/bayesianmetaanalysiscommon.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
SE <- dataset[, options[["effectSizeSe"]]]
.hasErrors(dataset = dataset,
seCheck.target = options[["effectSizeSe"]],
custom = .metaAnalysisCheckSE,
custom = .maCheckStandardErrors,
exitAnalysisIfErrors = TRUE)
}

Expand Down
2 changes: 1 addition & 1 deletion R/bayesianpredictionperformance.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
15 changes: 8 additions & 7 deletions R/classicalmetaanalysiscommon.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"]]
Expand Down
28 changes: 6 additions & 22 deletions R/classicalpredictionperformance.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -76,39 +76,23 @@ 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",
exitAnalysisIfErrors = TRUE)

.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) {

Expand All @@ -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"]])
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 3 additions & 16 deletions R/selectionmodels.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions R/waapwlspetpeese.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
5 changes: 5 additions & 0 deletions inst/Description.qml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Description
title: qsTr("Bayesian Meta-Analysis")
func: "BayesianMetaAnalysis"
requiresData: true
preloadData: false
}

Analysis
Expand All @@ -109,6 +110,7 @@ Description
title: qsTr("Bayesian Binomial Meta-Analysis")
func: "BayesianBinomialMetaAnalysis"
requiresData: true
preloadData: false
}

Analysis
Expand All @@ -117,6 +119,7 @@ Description
title: qsTr("Penalized Meta-Analysis")
func: "PenalizedMetaAnalysis"
requiresData: true
preloadData: false
}

Analysis
Expand All @@ -125,12 +128,14 @@ Description
title: qsTr("Bayesian Prediction Model Performance")
func: "BayesianPredictionPerformance"
requiresData: true
preloadData: false
FBartos marked this conversation as resolved.
Show resolved Hide resolved
}

Analysis
{
title: qsTr("Robust Bayesian Meta-Analysis")
func: "RobustBayesianMetaAnalysis"
requiresData: false
preloadData: false
}
}
70 changes: 69 additions & 1 deletion inst/Upgrades.qml
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,9 @@ Upgrades

ChangeJS
{
name: "inferenceOutputScale"
jsFunction: function(options)
{
name: "inferenceOutputScale"
switch(options["inferenceOutputScale"])
{
case "correlation": return "r";
Expand All @@ -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"]
}
}
}
}
}
22 changes: 18 additions & 4 deletions inst/qml/qml_components/PredictionPerformanceInference.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions inst/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading