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

Meta-Analysis 2.0 #248

Merged
merged 127 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
0f7d4c1
effect sizes draft
FBartos Jun 6, 2024
d975d7b
Update ClassicalMetaAnalysis.qml
FBartos Jun 6, 2024
ab148e6
update effect size calculation qml
FBartos Jun 8, 2024
d946820
Update EffectSizeComputation.qml
FBartos Jun 8, 2024
b1fcfa6
update
FBartos Jun 9, 2024
a3b8029
Update effectsizecomputation.R
FBartos Jun 10, 2024
8405e1a
Bruno's fixes
FBartos Jun 10, 2024
f18ec78
basic model fit
FBartos Jun 15, 2024
9e3ae04
coefficient estimates
FBartos Jun 15, 2024
1dab162
terms tests
FBartos Jun 15, 2024
6bad41e
updates
FBartos Jun 17, 2024
ead17ce
Update EffectSizeComputation.qml
FBartos Jun 17, 2024
d4698bb
updates
FBartos Jun 17, 2024
d843d1a
updates
FBartos Jun 17, 2024
ad88fb8
updates
FBartos Jun 17, 2024
3d0eb5c
updates
FBartos Jun 17, 2024
faa4d6e
restrict methods
FBartos Jun 17, 2024
44a67e8
finish fitting function
FBartos Jun 17, 2024
de44b45
Update ClassicalMetaAnalysis.qml
FBartos Jun 17, 2024
cb46d78
marginal means
FBartos Jun 18, 2024
e0286ec
Update classicalmetaanalysiscommon.R
FBartos Jun 18, 2024
db160d6
hotfix effect size calculation
FBartos Jun 19, 2024
28e95f0
add adjusted estimates
FBartos Jun 19, 2024
fa02612
forest plot
FBartos Jun 19, 2024
7ab00fc
update forest plot
FBartos Jun 19, 2024
753c909
forest plot progress
FBartos Jun 20, 2024
0211489
forest
FBartos Jun 21, 2024
fba4d33
update
FBartos Jun 21, 2024
f01f247
update forest plot
FBartos Jun 22, 2024
2690707
effect size computation
FBartos Jun 22, 2024
c418fb3
add bubble plot
FBartos Jun 22, 2024
352c300
finish bubble plot
FBartos Jun 23, 2024
3b516ee
add metafor R code display
FBartos Jun 23, 2024
4b9d35d
forest plot fixes
FBartos Jun 23, 2024
0898808
add VIF
FBartos Jun 23, 2024
9d0463e
fix sizing
FBartos Jun 23, 2024
77d764a
fixes
FBartos Jun 23, 2024
c882b40
add diagnostics
FBartos Jun 23, 2024
31bd849
Update classicalmetaanalysiscommon.R
FBartos Jun 23, 2024
043feb7
add profile likelihood plot
FBartos Jun 23, 2024
fceee8e
baujat plot
FBartos Jun 23, 2024
9ca78bc
fix forest plot
FBartos Jun 24, 2024
77ee844
fix baujat updating
FBartos Jun 24, 2024
a2e8251
compartmentalize classical meta-analysis
FBartos Jun 24, 2024
f21ee18
add multivariate
FBartos Jun 24, 2024
2ee88f2
random effect structure extraction
FBartos Jun 24, 2024
08a0730
some updates
FBartos Jun 25, 2024
ddd01dc
Update ClassicalMetaAnalysisStatistics.qml
FBartos Jun 25, 2024
9465ea0
updates
FBartos Jun 25, 2024
08f1a01
fix tables
FBartos Jun 26, 2024
bf3d0d1
updates
FBartos Jun 26, 2024
378cbde
fix NAs
FBartos Jun 26, 2024
03ebb57
Update classicalmetaanalysiscommon.R
FBartos Jun 26, 2024
4f6e917
update
FBartos Jun 27, 2024
7d0a7b4
Update classicalmetaanalysiscommon.R
FBartos Jul 1, 2024
363779c
finish bubble plot
FBartos Jul 1, 2024
15e7205
add residual funnel plot
FBartos Jul 2, 2024
5d971c4
Update classicalmetaanalysiscommon.R
FBartos Jul 3, 2024
7a067cf
Update classicalmetaanalysiscommon.R
FBartos Aug 22, 2024
1fbab34
add randomization test
FBartos Oct 10, 2024
9c691b5
Update classicalmetaanalysiscommon.R
FBartos Oct 10, 2024
71b9970
funnel plot updates
FBartos Oct 10, 2024
a6619cf
add funnel assymetry tests
FBartos Oct 11, 2024
bc6f557
remove debugging info
FBartos Oct 11, 2024
7c1dd2f
clean up
FBartos Oct 11, 2024
c725a42
fixes & cleanup
FBartos Oct 11, 2024
3b07faa
Update funnnelplot.R
FBartos Oct 13, 2024
d415e70
fixes
FBartos Oct 21, 2024
f056795
remove outdated files
FBartos Oct 21, 2024
2ce72fe
fix funnel plot: simultaneous mapping does not work
FBartos Oct 21, 2024
2a6cf2d
fix funnel plot: error handling
FBartos Oct 21, 2024
c06634d
fix funnel plot: error handling 2
FBartos Oct 21, 2024
708f1c6
fix funnel plot:: missing data handling
FBartos Oct 21, 2024
6ec21a1
fix funnel plot:: missing data handling
FBartos Oct 21, 2024
aff0ec4
fix effect size computation: add type (data loading still broken)
FBartos Oct 22, 2024
09baf3b
fix meta-analysis: omnibus test names
FBartos Oct 22, 2024
5582863
fix meta-analysis: forest plot xlab changes with transformation
FBartos Oct 22, 2024
444d940
fix funnel.R file name
FBartos Oct 22, 2024
a58af11
fix effect size computation: Step labels
FBartos Oct 22, 2024
fdc0609
fix effect size computation: remove flattening, subset & data read (v…
FBartos Oct 22, 2024
538cbb1
fix funnel plot: asymmetry typo
FBartos Oct 23, 2024
d4c4580
fix funnel plot: fitContainer -> fitState
FBartos Oct 23, 2024
fadaea6
fix funnel plot: add spaces
FBartos Oct 23, 2024
906b63b
fix funnel plot: add column type
FBartos Oct 23, 2024
a8a843e
fix funnel plot: error handling
FBartos Oct 23, 2024
18f08ee
meta-analysis fix: method option names transformation
FBartos Oct 23, 2024
49f799a
fix effect size computation: remove old code
FBartos Oct 24, 2024
d4f23a1
fix meta-analysis: permutation test code
FBartos Oct 24, 2024
58fa84c
fix effect size computation: fix subsetting
FBartos Oct 25, 2024
a7b6e26
fix meta-analysis: permutation dispatching code
FBartos Oct 25, 2024
96478a3
fix meta-analysis: forest plot variable types bugs & clustered hetero…
FBartos Oct 25, 2024
a1f3e38
fix meta-analysis: data loading & checking
FBartos Oct 25, 2024
cf58898
fix meta-analysis: handling diagnostics for clustered/location-scale …
FBartos Oct 25, 2024
d39b31f
ooops: remove saveRDS
FBartos Oct 25, 2024
07284dc
fix multivariate meta-analysis: diagnostics and options parsing
FBartos Oct 25, 2024
1f0f3eb
fix multivariate meta-analysis: random effects display & heterogeneit…
FBartos Oct 26, 2024
b9f4ac5
fix multivariate meta-analysis: prediction intervals in estimated mar…
FBartos Oct 26, 2024
b7f6ede
fix multivariate meta-analysis: forest plot CI/PI issues
FBartos Oct 26, 2024
79ffec2
fix multivariate meta-analysis: diagnostics table
FBartos Oct 27, 2024
7d5f897
fix multivariate meta-analysis: Baujat not available for rma.mv
FBartos Oct 27, 2024
1d8b26a
fix multivariate meta-analysis: profile likelihood plot
FBartos Oct 27, 2024
6e295d5
fix meta-analysis: weights and GENQ estimators
FBartos Oct 27, 2024
14a1247
fix meta-analysis: omnibus moderation test specification
FBartos Oct 27, 2024
e377126
fix multivariate meta-analysis: fix spatial random effects & known co…
FBartos Oct 27, 2024
5ce0170
add testing data sets
FBartos Oct 27, 2024
8c6d712
fix multivariate meta-analysis: add inclusion test for random effects
FBartos Oct 27, 2024
c382d64
hide confidence intervals for random effects option
FBartos Oct 27, 2024
2da8d27
fix multivariate meta-analysis: optimizer settings
FBartos Oct 27, 2024
30bbd76
add metafor code injection
FBartos Oct 28, 2024
26666a1
Apply suggestions from code review
FBartos Oct 30, 2024
046a9d3
typos
FBartos Oct 30, 2024
2104707
fixing .maExtendMetaforCallFromOptions
FBartos Oct 30, 2024
14b1066
make nicer error messages
FBartos Oct 30, 2024
609f302
fixing forest plot with heterogeneity test
FBartos Oct 30, 2024
fcae175
fixing pooled effect size estimates (under no moderation but heterosk…
FBartos Oct 30, 2024
d4cb595
fix empty weights
FBartos Oct 30, 2024
3d205f0
fix funnel plot: allow offsetting x-axis label position + larger default
FBartos Oct 31, 2024
1eef1bf
fix effect size computation: no errors on no input
FBartos Oct 31, 2024
8854086
fix effect size computation: better handling of observed effects
FBartos Oct 31, 2024
ff097d0
fix effect size computation: cronbachsAlpha -> coefficientAlpha
FBartos Oct 31, 2024
0a09a2e
fix effect size computation: fixing incorrect variance type
FBartos Oct 31, 2024
32fd0b1
fix meta-analysis: prevent issues with dropping the intercept
FBartos Oct 31, 2024
304d88a
Update effectsizecomputation.R
FBartos Nov 1, 2024
7a10472
computedcolumnsNamesEffectSize -> computedColumnsNamesEffectSize
FBartos Nov 1, 2024
f873fdb
add documentation (part 1/2)
FBartos Nov 1, 2024
9aa4550
add documentation (2/2)
FBartos Nov 6, 2024
26b26f6
update not possible
FBartos Nov 6, 2024
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: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
^tests/upgrades$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ Thumbs.db
# RStudio files
.Rproj.user
_processedLockFile.lock
renv/activate.R
.Rprofile
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ Imports:
RoBMA,
metamisc (>= 0.2.5),
ggmcmc,
pema
pema,
clubSandwich,
CompQuadForm,
sp,
dfoptim,
patchwork
Remotes:
jasp-stats/jaspBase,
jasp-stats/jaspGraphs
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import(jaspBase)
export(ClassicalMetaAnalysis)
export(ClassicalMetaAnalysisMultilevelMultivariate)
export(SelectionModels)
export(WaapWls)
export(PetPeese)
Expand All @@ -11,3 +12,5 @@ export(.ClassicalMetaAnalysisCommon)
export(.BayesianMetaAnalysisCommon)
export(PenalizedMetaAnalysis)
export(BayesianBinomialMetaAnalysis)
export(EffectSizeComputation)
export(FunnelPlot)
220 changes: 159 additions & 61 deletions R/classicalmetaanalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,83 +15,181 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This is a temporary fix
# TODO: remove it when R will solve this problem!
gettextf <- function(fmt, ..., domain = NULL) {
return(sprintf(gettext(fmt, domain = domain), ...))
}

ClassicalMetaAnalysis <- function(jaspResults, dataset = NULL, options, ...) {

options[["module"]] <- "metaAnalysis"

ready <- options$effectSize != "" && options$effectSizeSe != "" && (options$interceptTerm || length(options$modelTerms) > 0)
if(ready) {
dataset <- .metaAnalysisReadData(dataset, options)
.metaAnalysisCheckErrors(dataset, options)
if (.maReady(options)) {
dataset <- .maCheckData(dataset, options)
.maCheckErrors(dataset, options)
}

container <- .metaAnalysisGetOutputContainer(jaspResults)

.ClassicalMetaAnalysisCommon(container, dataset, ready, options)
.ClassicalMetaAnalysisCommon(jaspResults, dataset, options)

return()
}

.metaAnalysisGetOutputContainer <- function(jaspResults) {
if (!is.null(jaspResults[["modelContainer"]])) {
modelContainer <- jaspResults[["modelContainer"]]
} else {
modelContainer <- createJaspContainer()
modelContainer$dependOn(c("effectSize", "effectSizeSe", "method", "studyLabel", "covariates", "estimateTest",
"factors", "modelTerms", "interceptTerm", "coefficientCiLevel"))
jaspResults[["modelContainer"]] <- modelContainer
}
return(modelContainer)
}
.maDependencies <- c(
"effectSize", "effectSizeStandardError", "predictors", "predictors.types", "clustering", "method", "fixedEffectTest",
"effectSizeModelTerms", "effectSizeModelIncludeIntercept",
"clusteringUseClubSandwich", "clusteringSmallSampleCorrection",
"confidenceIntervalsLevel",
"fixParametersTau2", "fixParametersTau2Value",
"fixParametersWeights", "fixParametersWeightsVariable",
"weightedEstimation",
"diagnosticsCasewiseDiagnosticsRerunWithoutInfluentialCases",
# optimizer settings
"optimizerMethod", "optimizerInitialTau2", "optimizerInitialTau2Value",
"optimizerMinimumTau2", "optimizerMinimumTau2Value", "optimizerMaximumTau2", "optimizerMaximumTau2Value",
"optimizerMaximumIterations", "optimizerMaximumIterationsValue", "optimizerConvergenceTolerance", "optimizerConvergenceToleranceValue",
"optimizerConvergenceRelativeTolerance", "optimizerConvergenceRelativeToleranceValue", "optimizerStepAdjustment", "optimizerStepAdjustmentValue",
"optimizerMaximumEvaluations", "optimizerMaximumEvaluationsValue",
"optimizerInitialTrustRegionRadius", "optimizerInitialTrustRegionRadiusValue", "optimizerFinalTrustRegionRadius", "optimizerFinalTrustRegionRadiusValue",
"optimizerMaximumRestarts", "optimizerMaximumRestartsValue",
"advancedExtendMetaforCall", "advancedExtendMetaforCallCode",
# simple ma specific
"heterogeneityModelTerms", "heterogeneityModelIncludeIntercept", "heterogeneityModelLink",
"permutationTest", "permutationTestIteration", "permutationTestType", "setSeed", "seed",
# multilevel/multivariate specific
"randomEffects", "randomEffectsSpecification",
"computeCovarianceMatrix", "computeCovarianceMatrix"
)
.maForestPlotDependencies <- c(
.maDependencies, "transformEffectSize", "confidenceIntervalsLevel",
"forestPlotStudyInformation",
"forestPlotStudyInformationAllVariables",
"forestPlotStudyInformationSelectedVariables",
"forestPlotStudyInformationSelectedVariablesSettings",
"forestPlotStudyInformationPredictedEffects",
"forestPlotStudyInformationStudyWeights",
"forestPlotStudyInformationOrderBy",
"forestPlotStudyInformationOrderAscending",
"forestPlotEstimatedMarginalMeans",
"forestPlotEstimatedMarginalMeansModelVariables",
"forestPlotEstimatedMarginalMeansSelectedVariables",
"forestPlotEstimatedMarginalMeansTermTests",
"forestPlotEstimatedMarginalMeansCoefficientTests",
"forestPlotEstimatedMarginalMeansCoefficientTestsAgainst",
"forestPlotEstimatedMarginalMeansAdjustedEffectSizeEstimate",
"forestPlotModelInformation",
"forestPlotPooledEffectSizeEstimate",
"forestPlotPooledEffectSizeTest",
"forestPlotResidualHeterogeneityTest",
"forestPlotResidualHeterogeneityEstimate",
"forestPlotEffectSizeModerationTest",
"forestPlotHeterogeneityModerationTest",
"forestPlotPredictionIntervals",
"forestPlotEstimatesAndConfidenceIntervals",
"forestPlotTestsInRightPanel",
"forestPlotMappingColor",
"forestPlotMappingShape",
"forestPlotRelativeSizeEstimates",
"forestPlotRelativeSizeText",
"forestPlotRelativeSizeAxisLabels",
"forestPlotRelativeSizeRow",
"forestPlotRelativeSizeLeftPanel",
"forestPlotRelativeSizeMiddlePanel",
"forestPlotRelativeSizeRightPanel",
"forestPlotAuxiliaryAdjustWidthBasedOnText",
"forestPlotAuxiliaryDigits",
"forestPlotAuxiliaryTestsInformation",
"forestPlotAuxiliaryPlotColor",
"forestPlotAuxiliaryAddVerticalLine",
"forestPlotAuxiliaryAddVerticalLineValue",
"forestPlotAuxiliaryAddVerticalLine2",
"forestPlotAuxiliaryAddVerticalLineValue2",
"forestPlotAuxiliaryEffectLabel",
"forestPlotAuxiliarySetXAxisLimit",
"forestPlotAuxiliarySetXAxisLimitLower",
"forestPlotAuxiliarySetXAxisLimitUpper",
"forestPlotStudyInformationSecondaryConfidenceInterval",
"forestPlotStudyInformationSecondaryConfidenceIntervalLevel"
)
.maBubblePlotDependencies <- c(
.maDependencies, "transformEffectSize", "confidenceIntervalsLevel",
"bubblePlotSelectedVariable",
"bubblePlotSeparateLines",
"bubblePlotSeparatePlots",
"bubblePlotSdFactorCovariates",
"bubblePlotBubblesSize",
"bubblePlotBubblesRelativeSize",
"bubblePlotBubblesTransparency",
"bubblePlotBubblesJitter",
"bubblePlotConfidenceIntervals",
"bubblePlotConfidenceIntervalsTransparency",
"bubblePlotPredictionIntervals",
"bubblePlotPredictionIntervalsTransparency",
"colorPalette",
"bubblePlotTheme",
"bubblePlotLegendPosition",
"bubblePlotRelativeSizeText"
)
.maReady <- function(options) {

.metaAnalysisReadData <- function(dataset, options) {
if (!is.null(dataset))
return(dataset)
else {
effsizeName <- unlist(options$effectSize)
stderrName <- unlist(options$effectSizeSe)
covarNames <- if (length(options$covariates) > 0) unlist(options$covariates)
factNames <- if (length(options$factors) > 0) unlist(options$factors)

numeric.variables <- Filter(function(s) s != "", c(effsizeName, covarNames, stderrName))
factor.variables <- Filter(function(s) s != "", c(factNames, options$studyLabel))
return(.readDataSetToEnd(columns.as.factor = factor.variables,
columns.as.numeric = numeric.variables,
exclude.na.listwise = numeric.variables))
}
inputReady <- options[["effectSize"]] != "" && options[["effectSizeStandardError"]] != ""
termsEffectSizeReady <- length(options[["effectSizeModelTerms"]]) > 0 || options[["effectSizeModelIncludeIntercept"]]
termsHeterogeneityReady <- length(options[["heterogeneityModelTerms"]]) > 0 || options[["heterogeneityModelIncludeIntercept"]]

return(inputReady && termsEffectSizeReady && termsHeterogeneityReady)
}
.maCheckData <- function(dataset, options) {

# model data
predictorsNominal <- options[["predictors"]][options[["predictors.types"]] == "nominal"]
predictorsScale <- options[["predictors"]][options[["predictors.types"]] == "scale"]

.metaAnalysisCheckErrors <- function(dataset, options){
effsizeName <- unlist(options$effectSize)
stderrName <- unlist(options$effectSizeSe)
covarNames <- if (length(options$covariates) > 0) unlist(options$covariates)
numeric.variables <- Filter(function(s) s != "", c(effsizeName, covarNames, stderrName))
.hasErrors(dataset = dataset,
type = c("infinity", "observations", "variance"),
all.target = numeric.variables,
observations.amount = "< 2",
exitAnalysisIfErrors = TRUE)
.hasErrors(dataset = dataset,
type = c("modelInteractions"),
modelInteractions.modelTerms = options$modelTerms,
exitAnalysisIfErrors = TRUE)
.hasErrors(dataset = dataset,
seCheck.target = options[["effectSizeSe"]],
custom = .metaAnalysisCheckSE,
exitAnalysisIfErrors = TRUE)
# omit NAs
omitOnVariables <- c(
options[["effectSize"]],
options[["effectSizeStandardError"]],
if (options[["clustering"]] != "") options[["clustering"]],
if (length(predictorsNominal) > 0) predictorsNominal,
if (length(predictorsScale) > 0) predictorsScale
)
anyNaByRows <- apply(dataset[,omitOnVariables], 1, function(x) anyNA(x))
dataset <- dataset[!anyNaByRows,]
attr(dataset, "NAs") <- sum(anyNaByRows)

return(dataset)
}
.maCheckErrors <- function(dataset, options) {

.hasErrors(
dataset = dataset,
type = c("infinity", "observations", "variance"),
all.target = c(
options[["effectSize"]],
options[["effectSizeStandardError"]],
options[["predictors"]][options[["predictors.types"]] == "scale"]
),
observations.amount = "< 2",
exitAnalysisIfErrors = TRUE)

if (length(options[["effectSizeModelTerms"]]) > 0)
.hasErrors(
dataset = dataset,
type = c("modelInteractions"),
modelInteractions.modelTerms = options[["effectSizeModelTerms"]],
exitAnalysisIfErrors = TRUE)

.metaAnalysisCheckSE <- list(
seCheck = function(dataset, target) {
nonPositive <- !all(na.omit(dataset[,target]) > 0)
if (length(options[["heterogeneityModelTerms"]]) > 0)
.hasErrors(
dataset = dataset,
type = c("modelInteractions"),
modelInteractions.modelTerms = options[["heterogeneityModelTerms"]],
exitAnalysisIfErrors = TRUE)

.hasErrors(
dataset = dataset,
seCheck.target = options[["effectSizeStandardError"]],
custom = .maCheckStandardErrors,
exitAnalysisIfErrors = TRUE)
}
.maCheckStandardErrors <- list(seCheck = function(dataset, target) {
nonPositive <- !all(dataset[,target] > 0)
if (nonPositive) {
return(gettext("All standard errors/sample sizes must be positive."))
return(gettext("All standard errors must be positive."))
}
}
)
})
Loading
Loading