Skip to content

Commit

Permalink
CRAN: Windows UCRT patch + BayesTools version check
Browse files Browse the repository at this point in the history
  • Loading branch information
FBartos committed Jan 13, 2022
1 parent 8a77434 commit 8fe4e89
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 16 deletions.
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.1.1
Version: 2.1.2
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.1.2
### Fixes
- adding Windows ucrt patch (thanks to Tomas Kalibera)
- adding BayesTools version check

## version 2.1.1
### Fixes
- incorrectly formatted citations in vignettes and capitalization
Expand Down
45 changes: 45 additions & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,48 @@ assign("options", RoBMA.private$defaultoptions, envir = RoBMA.private)
assign("RoBMA_version", "notset", envir = RoBMA.private)
assign("min_jags_major", 4, envir = RoBMA.private)
assign("max_jags_major", 4, envir = RoBMA.private)


# check proper BayesTools package version
.check_BayesTools <- function(){

RoBMA.version <- try(utils::packageVersion("RoBMA"))
BayesTools.version <- try(utils::packageVersion("BayesTools"))

if(inherits(RoBMA.version, "try-error") | inherits(BayesTools.version, "try-error")){
return(invisible(FALSE))
}

if(is.null(RoBMA.version) | is.null(BayesTools.version)){
return(invisible(FALSE))
}

BayesTools_min <- switch(
paste0(RoBMA.version, collapse = "."),
"2.1.1" = "0.1.3",
"2.1.2" = "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",
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))

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)
return(invisible(FALSE))
}
}

4 changes: 3 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
}
}

.check_BayesTools()

}

.onAttach <- function(libname, pkgname){

packageStartupMessage("This is a 2.1 version of the RoBMA package (see NEWS for detailed overview of the changes).")
# packageStartupMessage("This is a 2.1 version of the RoBMA package (see NEWS for detailed overview of the changes).")

}

Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ We also prepared multiple vignettes that illustrate functionality of the package

- [Reproducing Bayesian model-averaged meta-analysis (BMA)](https://fbartos.github.io/RoBMA/articles/ReproducingBMA.html)
- [Fitting custom meta-analytic ensembles](https://fbartos.github.io/RoBMA/articles/CustomEnsembles.html)
- [Informed Bayesian model-averaged meta-analysis in medicine](https://fbartos.github.io/RoBMA/articles/MedicineBMA.html)


## Updates
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ heterogeneity, and publication bias components (including selection,
PET, and PEESE style models). The package provides convenient functions
for summary, visualizations, and fit diagnostics.

See our new pre-print Bartoš et al. (2021)
See our new pre-print Bartoš, Maier, Wagenmakers, et al. (2021)
(<https://doi.org/10.31234/osf.io/kvsp7>) for the description of the
newest version, RoBMA-PSMA, or our previous paper introducing the method
Maier et al. (in press) (<https://doi.org/10.31234/osf.io/u4cns>). The
previous version of the methods is also implemented within the the
user-friendly graphical user interface of JASP (JASP Team, 2020) and
accompanied by a tutorial paper with more examples (Bartoš et al., 2020)
(<https://doi.org/10.31234/osf.io/75bqn>).
accompanied by a tutorial paper with more examples (Bartoš, Maier,
Quintana, et al., 2021) (<https://doi.org/10.31234/osf.io/75bqn>).

We also prepared multiple vignettes that illustrate functionality of the
package:
Expand All @@ -41,12 +41,15 @@ package:
(BMA)](https://fbartos.github.io/RoBMA/articles/ReproducingBMA.html)
- [Fitting custom meta-analytic
ensembles](https://fbartos.github.io/RoBMA/articles/CustomEnsembles.html)
- [Informed Bayesian model-averaged meta-analysis in
medicine](https://fbartos.github.io/RoBMA/articles/MedicineBMA.html)

## Updates

The package was updated to version 2.0 to provides Bayesian
model-averaging across selection models and PET-PEESE (as described in
Bartoš et al. (2021) at <https://doi.org/10.31234/osf.io/kvsp7>).
Bartoš, Maier, Wagenmakers, et al. (2021) at
<https://doi.org/10.31234/osf.io/kvsp7>).

### Backwards Compatibility

Expand Down Expand Up @@ -81,7 +84,7 @@ The 2.0 version brings several updates to the package:
`prior_PEESE(distribution = "Cauchy", parameters = ...)`),
- new default prior distribution specification for the publication
bias adjustment part of the models (corresponding to the RoBMA-PSMA
model from Bartoš et al. (2021)),
model from Bartoš, Maier, Wagenmakers, et al. (2021)),
- new `model_type` argument allowing to specify different “pre-canned”
models (`"PSMA"` = RoBMA-PSMA, `"PP"` = RoBMA-PP, `"2w"` =
corresponding to Maier et al. (in press)),
Expand Down Expand Up @@ -117,12 +120,12 @@ devtools::install_github("fbartos/RoBMA")
## Example

To illustrate the functionality of the package, we fit the RoBMA-PSMA
model from the example in Bartoš et al. (2021) to adjust for publication
bias in the infamous Bem (2011) “Feeling the future” pre-cognition
study. The RoBMA-PSMA model combines six selection models and PET-PEESE
to adjust for publication bias. As in the pre-print, we analyze the data
as described by Bem et al. (2011) in his reply to methodological
critiques.
model from the example in Bartoš, Maier, Wagenmakers, et al. (2021) to
adjust for publication bias in the infamous Bem (2011) “Feeling the
future” pre-cognition study. The RoBMA-PSMA model combines six selection
models and PET-PEESE to adjust for publication bias. As in the
pre-print, we analyze the data as described by Bem et al. (2011) in his
reply to methodological critiques.

First, we load the package and the data set included in the package.

Expand Down Expand Up @@ -330,9 +333,10 @@ line-spacing="2">

<div id="ref-bartos2020adjusting" class="csl-entry">

Bartoš, F., Maier, M., & Wagenmakers, E.-J. (2020). Adjusting for
publication bias in JASP — selection models and robust Bayesian
meta-analysis. In *PsyArXiv*. <https://doi.org/10.31234/osf.io/75bqn>
Bartoš, F., Maier, M., Quintana, D. S., & Wagenmakers, E.-J. (2021).
Adjusting for publication bias in JASP & R – selection models,
PET-PEESE, and robust Bayesian meta-analysis. In *PsyArXiv*.
<https://doi.org/10.31234/osf.io/75bqn>

</div>

Expand Down
90 changes: 90 additions & 0 deletions src/Makevars.ucrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
######################################################################################################
### This file is based on file in the runjags package (version 2.0)
### The previous version of the file is Copyright (C) Matthew Denwood, licensed under GPL-2.
###
### The previous file is based on that in the rjags package (version 3-10)
### Original file is Copyright (C) Martyn Plummer, licensed under GPL-2
###
### Note: This windows makefile requires the JAGS_ROOT variable to be set
###
### This file allows compilation with JAGS 4 (or later) without modifying RoBMA.
### To force the package to compile assuming a given JAGS version is installed, use the
### JAGS_MAJOR_FORCED environmental variable. This might be necessary on windows if you have
### JAGS installed in a non-standard location.
###
######################################################################################################

## Conditionally set the JAGS_ROOT variable (if it is not already set) to a location specified by the CRAN team:
JAGS_ROOT ?= /c/progra~1/JAGS/JAGS-4.3.0

## Use the old ABI to match JAGS 4.x compilation on Windows:
#PKG_CXXFLAGS = -D_GLIBCXX_USE_CXX11_ABI=0
PKG_CXXFLAGS=
## Note: this behaviour will be changed (and RoBMA updated) before JAGS 5 is released
## If you are trying to compile this version of RoBMA against JAGS 5 you may need to remove this PKG_CXXFLAGS line

###############
### Flags
### The installed major version of JAGS is needed at this stage - we try to guess this from JAGS_ROOT
### If you have a non-standard JAGS install (and therefore JAGS_ROOT variable), then see the README file
###############

# We need to introduce spaces so that we can fool word into splitting the $(JAGS_ROOT) path:
space :=
space +=

# First check to see if JAGS_MAJOR_VERSION is defined in the environment and pass that as JAGS_MAJOR_FORCED to -D
ifneq ($(strip $(JAGS_MAJOR_VERSION)),)
JAGS_MAJOR = $(strip $(JAGS_MAJOR_VERSION))
JAGS_MAJOR_ASSUMED = $(strip 0)
else

# Check if the JAGS_ROOT is standard i.e. we can extract a major version:
JAGS_VERSION_PRESENT = $(findstring JAGS-,$(JAGS_ROOT))

# If we can detect and extract a JAGS major version:
ifneq ($(strip $(JAGS_VERSION_PRESENT)),)
# First substitute / for space:
JAGS_ROOT_SUB = $(subst /,$(space),$(JAGS_ROOT))
# Then isolate the JAGS-x.x.x part:
JAGS_FULL_VERS = $(word $(words $(JAGS_ROOT_SUB)),$(JAGS_ROOT_SUB))
# Then substitute / for space and extract the major version
JAGS_MAJOR_ASSUMED = $(strip $(word 2,$(subst .,$(space),$(subst -,$(space),$(JAGS_FULL_VERS)))))
else
# Otherwise make an assumption about JAGS_MAJOR and give a warning:
JAGS_MAJOR_ASSUMED = $(strip 4)
$(warning The major version of JAGS could not be determined from $(JAGS_ROOT) - assuming version $(JAGS_MAJOR_ASSUMED) (otherwise the Makevars.win file may need to be modified))
endif

JAGS_MAJOR = $(strip $(JAGS_MAJOR_ASSUMED))

endif

# Set the CPPFLAGS accordingly
# Prepending 0 to JAGS_MAJOR_VERSION prevents it being set as blank (the C++ code requires a number)
JAGS_MAJOR_ASSUMED := 4
PKG_CPPFLAGS=-I"$(JAGS_ROOT)/include" -D JAGS_MAJOR_ASSUMED=$(JAGS_MAJOR_ASSUMED) -D JAGS_MAJOR_FORCED=0$(JAGS_MAJOR_VERSION)

PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-$(JAGS_MAJOR) -ljrmath-0


###############
### Objects to be compiled
### NB: the objects in distributions/jags are only necessary for JAGS <=3, and are excluded by the sources when compiling against JAGS >= 4
###############

OBJECTS = distributions/DWN1.o distributions/DWN2.o distributions/DWT1.o distributions/DWT2.o transformations/z.o transformations/r.o transformations/d.o transformations/logOR.o transformations/transformations_common.o init.o RoBMA.o testRoBMA.o

###############



###############
#### If you still have compilation problems (after reading README) then you can use the following code instead. Deleting everything above this line and uncomment the two relevant lines below.
###############

# PKG_CPPFLAGS=-I"$(JAGS_ROOT)/include"
# PKG_LIBS=-L"$(JAGS_ROOT)/${R_ARCH}/bin" -ljags-4
# OBJECTS = distributions/DWN1.o distributions/DWN2.o distributions/DWT1.o distributions/DWT2.o transformations/z.o transformations/r.o transformations/d.o transformations/logOR.o transformations/transformations_common.o init.o RoBMA.o testRoBMA.o

###############

0 comments on commit 8fe4e89

Please sign in to comment.