Skip to content

Commit

Permalink
effect size information messages + BayesTools 0.2.3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
FBartos committed Mar 30, 2022
1 parent 54b44f9 commit c72c119
Show file tree
Hide file tree
Showing 51 changed files with 283 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
# - {os: macOS-11.6.2, r: 'release'} # the release C++ version does not compile properly

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_version("BayesTools", "0.1.3")
remotes::install_version("BayesTools", "0.2.3")
shell: Rscript {0}

- name: Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_version("BayesTools", "0.1.3")
remotes::install_version("BayesTools", "0.2.3")
install.packages("devtools")
install.packages("testthat")
install.packages("vdiffr")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown")
remotes::install_version("BayesTools", "0.1.3")
remotes::install_version("BayesTools", "0.2.3")
shell: Rscript {0}

- name: Install package
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
remotes::install_version("BayesTools", "0.1.3")
remotes::install_version("BayesTools", "0.2.3")
shell: Rscript {0}

- name: Test coverage
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RoBMA
Title: Robust Bayesian Meta-Analyses
Version: 2.2.0
Version: 2.2.1
Maintainer: František Bartoš <[email protected]>
Authors@R: c(
person("František", "Bartoš", role = c("aut", "cre"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## version 2.2.1
### Changes
- message about the effect size scale of parameter estimates is always shown
- compatibility with BayesTools 0.2.0+

## version 2.2
### Features
- three-level meta-analysis by specifying `study_ids` argument in `RoBMA`. However, note that this is (1) an experimental feature and (2) the computational expense of fitting selection models with clustering is extreme. As of now, it is almost impossible to have more than 2-3 estimates clustered within a single study).
Expand Down
20 changes: 10 additions & 10 deletions R/fit-and-marglik.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,21 @@

}else{

fit_data <- .fit_data(object[["data"]], priors, add_info[["effect_direction"]], add_info[["prior_scale"]])
converged <- TRUE
has_posterior <- FALSE
fit <- list()
class(fit) <- "null_model"
marglik <- list()
marglik$logml <- sum(stats::dnorm(fit_data[["y"]], priors$mu$parameters[["location"]], fit_data[["se"]], log = TRUE))
class(marglik) <- "bridge"
fit_data <- .fit_data(object[["data"]], priors, add_info[["effect_direction"]], add_info[["prior_scale"]])
converged <- TRUE
has_posterior <- FALSE
fit <- list()
attr(fit, "prior_list") <- priors
class(fit) <- "null_model"
marglik <- list()
marglik$logml <- sum(stats::dnorm(fit_data[["y"]], priors$mu$parameters[["location"]], fit_data[["se"]], log = TRUE))
class(marglik) <- "bridge"

}

# add model summaries
if(has_posterior){
fit_summary <- BayesTools::runjags_estimates_table(fit = fit, prior_list = priors, warnings = warnings)
fit_summary <- BayesTools::runjags_estimates_table(fit = fit, warnings = warnings)
if(add_info[["prior_scale"]] != "y"){
fit_summaries <- .runjags_summary_list(fit, priors, add_info[["prior_scale"]], warnings)
}else{
Expand Down Expand Up @@ -602,7 +603,6 @@

summary_list[[measure]] <- BayesTools::runjags_estimates_table(
fit = fit,
prior_list = priors,
transformations = transformations,
warnings = warnings,
footnotes = .scale_note(priors_scale, measure),
Expand Down
9 changes: 4 additions & 5 deletions R/transformations.R
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,10 @@ scale_logOR2d <- function(logOR) .scale_logOR2d$fun(logOR)
}

.scale_note <- function(prior_scale, output_scale){
if(prior_scale == output_scale){
return(NULL)
}else{
return(paste0("The estimates are summarized on the ", .transformation_names(output_scale)," scale (priors were specified on the ", .transformation_names(prior_scale), " scale)."))
}
return(sprintf(
"The estimates are summarized on the %1$s scale (priors were specified on the %2$s scale).",
.transformation_names(output_scale),
.transformation_names(prior_scale)))
}


Expand Down
26 changes: 10 additions & 16 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,27 @@ assign("max_cores", parallel::detectCores(logical = TRUE) - 1, envir = Ro
return(invisible(FALSE))
}

BayesTools_min <- switch(
BayesTools_required <- switch(
paste0(RoBMA.version, collapse = "."),
"2.1.1" = "0.1.3",
"2.1.2" = "0.1.3",
"2.2.0" = "0.1.3",
stop("New RoBMA version needs to be defined in '.check_BayesTools' function!")
)
BayesTools_max <- switch(
paste0(RoBMA.version, collapse = "."),
"2.1.1" = "0.1.3",
"2.1.2" = "0.1.3",
"2.2.0" = "0.1.3",
"2.1.1" = c("0.1.3", "0.1.3"),
"2.1.2" = c("0.1.3", "0.1.3"),
"2.2.0" = c("0.1.3", "0.1.3"),
"2.2.1" = c("0.2.3", "0.2.999"),
stop("New RoBMA version needs to be defined in '.check_BayesTools' function!")
)

min_OK <- all(as.integer(strsplit(BayesTools_min, ".", fixed = TRUE)[[1]]) <= unlist(BayesTools.version))
max_OK <- all(as.integer(strsplit(BayesTools_max, ".", fixed = TRUE)[[1]]) >= unlist(BayesTools.version))
min_OK <- all(as.integer(strsplit(BayesTools_required[1], ".", fixed = TRUE)[[1]]) <= unlist(BayesTools.version))
max_OK <- all(as.integer(strsplit(BayesTools_required[2], ".", fixed = TRUE)[[1]]) >= unlist(BayesTools.version))

if(min_OK && max_OK){
return(invisible(TRUE))
}else{
warning(sprintf(
"RoBMA version %1$s requires BayesTools version higher or equal %2$s and lower or equal %3$s.",
paste0(RoBMA.version, collapse = "."),
BayesTools_min,
BayesTools_max
), call.=FALSE)
BayesTools_required[1],
BayesTools_required[2]
), call.= FALSE)
return(invisible(FALSE))
}
}
Expand Down
2 changes: 1 addition & 1 deletion man/prior_informed.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified tests/results/fits/fit_1.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_10.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_11.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_12.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_13.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_2.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_3.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_4.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_5.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_6.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_7.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_8.RDS
Binary file not shown.
Binary file modified tests/results/fits/fit_9.RDS
Binary file not shown.
Loading

0 comments on commit c72c119

Please sign in to comment.