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

Add metafor progress bar #266

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
35 changes: 28 additions & 7 deletions R/classicalmetaanalysiscommon.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@
fitPermutation <- try(metafor::permutest(
fit,
exact = options[["permutationTestType"]] == "exact",
iter = options[["permutationTestIteration"]]
iter = options[["permutationTestIteration"]],
code1 = "jaspBase::startProgressbar(X.iter, label = 'Permutation test')",
code2 = "jaspBase::progressbarTick()",
))
fit <- .maFitAddPermutationPValues(fit, fitPermutation, options)
} else {
Expand Down Expand Up @@ -1116,15 +1118,15 @@

if (.maIsMultilevelMultivariate(options)) {
# only a subset of diagnostics is available for rma.mv
influenceResultsDfbs <- data.frame(dfbetas(fit))
influenceResultsDfbs <- data.frame(dfbetas(fit, code1 = "jaspBase::startProgressbar(x$k, label = 'Casewise diagnostics: DFBETAS')", code2 = "jaspBase::progressbarTick()"))
influenceResultsInf <- data.frame(
rstudent = rstudent(fit)[["resid"]],
cook.d = cooks.distance(fit),
rstudent = rstudent(fit, code1 = "jaspBase::startProgressbar(x$k, label = 'Casewise diagnostics: Studentized residuals')", code2 = "jaspBase::progressbarTick()")[["resid"]],
cook.d = cooks.distance(fit, code1 = "jaspBase::startProgressbar(x$k, label = 'Casewise diagnostics: Cooks distance')", code2 = "jaspBase::progressbarTick()"),
hat = hatvalues(fit)
)
} else {
# the complete suite of influence diagnostics is only available for rma.uni
influenceResults <- influence(fit)
influenceResults <- influence(fit, code1 = "jaspBase::startProgressbar(x$k, label = 'Casewise diagnostics')", code2 = "jaspBase::progressbarTick()")
influenceResultsDfbs <- data.frame(influenceResults$dfbs)
influenceResultsInf <- data.frame(influenceResults$inf)
influenceResultsInf$tau.del <- sqrt(influenceResultsInf$tau2.del)
Expand Down Expand Up @@ -1287,13 +1289,32 @@

if (.maIsMultilevelMultivariate(options)) {
# use the defaults (too many possible parameter combinations to control)
dfProfile <- try(metafor::profile.rma.mv(fit, plot = FALSE, progbar = FALSE))
dfProfile <- try(metafor::profile.rma.mv(
fit,
plot = FALSE,
progbar = FALSE,
code1 = "jaspBase::startProgressbar(length(vcs), label = 'Profile likelihood')",
code2 = "jaspBase::progressbarTick()"
))

# deal with a single component (not a list)
if (dfProfile[["comps"]] == 1) {
dfProfile <- list(dfProfile)
dfProfile[["comps"]] <- 1
}

jaspResults[["diagnosticsResults"]]$object <- dfProfile
} else {
# proceed with some nice formatting for rma.uni (too difficult to implement for rma.mv)
xTicks <- jaspGraphs::getPrettyAxisBreaks(c(0, max(0.1, 2*fit[["tau2"]])))
dfProfile <- try(profile(fit, xlim = range(xTicks), plot = FALSE, progbar = FALSE))
dfProfile <- try(profile(
fit,
xlim = range(xTicks),
plot = FALSE,
progbar = FALSE,
code1 = "jaspBase::startProgressbar(length(vcs), label = 'Profile likelihood')",
code2 = "jaspBase::progressbarTick()"
))
attr(dfProfile, "xTicks") <- xTicks

jaspResults[["diagnosticsResults"]]$object <- dfProfile
Expand Down
1 change: 1 addition & 0 deletions jaspMetaAnalysis.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 925655aa-6877-4a5a-a8d2-32fc5296d549

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
Loading
Loading