Skip to content

Commit

Permalink
Merge pull request #2 from FBartos/BayesTools-rewrite
Browse files Browse the repository at this point in the history
CRAN eddits
  • Loading branch information
FBartos committed Sep 20, 2022
2 parents 9914b0c + a2ad6df commit 3bcbe1b
Show file tree
Hide file tree
Showing 25 changed files with 141 additions and 80 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/R-CMD-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ on:
- master
- pre-release

name: R-CMD-tests
name: R-CMD-test

jobs:
R-CMD-check:
R-CMD-test:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})
Expand All @@ -26,6 +26,7 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {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:
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Authors@R: c(
)
Description: An implementation of Bayesian model-averaged t-test that allows
users to draw inference about the presence vs absence of the effect,
heterogeneity of variances, and outliers. The RoBTT packages estimates model
heterogeneity of variances, and outliers. The 'RoBTT' packages estimates model
ensembles of models created as a combination of the competing hypotheses and uses
Bayesian model-averaging to combine the models using posterior model probabilities.
Users can obtain the model-averaged posterior distributions and inclusion Bayes
factors which account for the uncertainty in the data generating process
(Maier et al. forthcomming).
(Maier et al., 2022, <doi:10.31234/osf.io/d5zwc>).
Users can define a wide range of informative priors for all parameters
of interest. The package provides convenient functions for summary, visualizations,
and fit diagnostics.
Expand All @@ -26,7 +26,7 @@ Encoding: UTF-8
LazyData: true
SystemRequirements: GNU make
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.0
RoxygenNote: 7.2.1
NeedsCompilation: yes
ByteCompile: true
LinkingTo:
Expand Down
1 change: 0 additions & 1 deletion R/RoBTT-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
##' RoBTT: Bayesian model-averaged t-test extends the Bayesian t-test by
##' incorporating inference about heterogeneity of variances and outliers.
##'
##'
##' @name RoBTT-package
##' @author František Bartoš \email{f.bartos96@@gmail.com}
##' @keywords package
Expand Down
6 changes: 6 additions & 0 deletions R/check-input-and-settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ set_control <- function(adapt_delta = 0.80, max_treedepth = 15, brid
BayesTools::check_bool(silent, "silent", call = call)
BayesTools::check_int(seed, "seed", allow_NULL = TRUE, call = call)

if(!parallel){
cores <- 1
}else if(cores > RoBTT.get_option("max_cores")){
cores <- RoBTT.get_option("max_cores")
}

if(is.null(control[["adapt_delta"]])){
control[["adapt_delta"]] <- 0.80
}else{
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@
#' @return \code{RoBTT} returns an object of \link[base]{class} \code{"RoBTT"}.
#'
#' @examples
#' # using the example data from Anderson et al. 2010 and fitting the default model
#' # using the example data from Darwin
#' data("fertilization", package = "RoBTT")
#' fit <- RoBTT(
#' x1 = fertilization$Self,
#' x2 = fertilization$Crossed,
#' prior_delta = prior("cauchy", list(0, 1/sqrt(2))),
#' prior_rho = prior("beta", list(3, 3)),
#' likelihood = "normal",
#' seed = 1,
#' seed = 1,
#' chains = 1,
#' warmup = 1000,
#' iter = 2000,
#' control = set_control(adapt_delta = 0.95)
#' )
#'
Expand Down Expand Up @@ -152,7 +155,7 @@ RoBTT <- function(
parallel::stopCluster(cl)

}

# deal with non-converged the converged models
object$add_info$converged <- .get_model_convergence(object)

Expand Down
9 changes: 6 additions & 3 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' @title Plots a fitted RoBTT object
#' @title Plots a fitted 'RoBTT' object
#'
#' @description \code{plot.RoBTT} allows to visualize
#' different \code{"RoBTT"} object parameters in various
#' ways. See \code{type} for the different model types.
#'
#' @param x a fitted RoBTT object
#' @param x a fitted 'RoBTT' object
#' @param parameter a parameter to be plotted. Defaults to
#' \code{"delta"} (for the effect size). The additional options
#' are \code{"rho"} (for the heterogeneity),
Expand Down Expand Up @@ -39,7 +39,10 @@
#' prior_delta = prior("cauchy", list(0, 1/sqrt(2))),
#' prior_rho = prior("beta", list(3, 3)),
#' likelihood = "normal",
#' seed = 1,
#' seed = 1,
#' chains = 1,
#' warmup = 1000,
#' iter = 2000,
#' control = set_control(adapt_delta = 0.95)
#' )
#'
Expand Down
29 changes: 16 additions & 13 deletions R/summary.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @title Prints a fitted RoBTT object
#' @title Prints a fitted 'RoBTT' object
#'
#' @param x a fitted RoBTT object.
#' @param x a fitted 'RoBTT' object.
#' @param ... additional arguments.
#'
#'
Expand All @@ -16,13 +16,13 @@ print.RoBTT <- function(x, ...){
}


#' @title Summarize fitted RoBTT object
#' @title Summarize fitted 'RoBTT' object
#'
#' @description \code{summary.RoBTT} creates summary tables for a
#' RoBTT object.
#'
#' @param object a fitted RoBTT object
#' @param type whether to show the overall RoBTT results (\code{"ensemble"}),
#' @param object a fitted 'RoBTT' object
#' @param type whether to show the overall 'RoBTT' results (\code{"ensemble"}),
#' an overview of the individual models (\code{"models"}), an overview of
#' the individual models MCMC diagnostics (\code{"diagnostics"}), or a detailed summary
#' of the individual models (\code{"individual"}). Can be abbreviated to first letters.
Expand All @@ -42,15 +42,18 @@ print.RoBTT <- function(x, ...){
#' @param ... additional arguments
#'
#' @examples
#' # using the example data from Anderson et al. 2010 and fitting the default model
#' # using the example data from Darwin
#' data("fertilization", package = "RoBTT")
#' fit <- RoBTT(
#' x1 = fertilization$Self,
#' x2 = fertilization$Crossed,
#' prior_delta = prior("cauchy", list(0, 1/sqrt(2))),
#' prior_rho = prior("beta", list(3, 3)),
#' likelihood = "normal",
#' seed = 1,
#' seed = 1,
#' chains = 1,
#' warmup = 1000,
#' iter = 2000,
#' control = set_control(adapt_delta = 0.95)
#' )
#'
Expand All @@ -70,7 +73,6 @@ print.RoBTT <- function(x, ...){
#'
#' # summary of individual models and their parameters can be further obtained by
#' summary(fit, type = "individual")
#' }
#'
#'
#' @return \code{summary.RoBTT} returns a list of tables of class 'BayesTools_table'.
Expand Down Expand Up @@ -271,9 +273,9 @@ summary.RoBTT <- function(object, type = "ensemble", conditional = FALSE,
}


#' @title Prints summary object for RoBTT method
#' @title Prints summary object for 'RoBTT' method
#'
#' @param x a summary of a RoBTT object
#' @param x a summary of a 'RoBTT' object
#' @param ... additional arguments
#'
#'
Expand Down Expand Up @@ -342,7 +344,7 @@ print.summary.RoBTT <- function(x, ...){
}


#' @title Reports whether x is a RoBTT object
#' @title Reports whether x is a 'RoBTT' object
#'
#' @param x an object to test
#'
Expand All @@ -355,10 +357,11 @@ is.RoBTT <- function(x){
}


#' @title Interprets results of a RoBTT model.

#' @title Interprets results of a 'RoBTT' model.
#'
#' @description \code{interpret} creates a brief textual summary
#' of a fitted RoBTT object.
#' of a fitted 'RoBTT' object.
#'
#' @inheritParams summary.RoBTT
#'
Expand Down
6 changes: 3 additions & 3 deletions R/tools.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' @title Check fitted RoBTT object for errors and warnings
#' @title Check fitted 'RoBTT' object for errors and warnings
#'
#' @description Checks fitted RoBTT object
#' @description Checks fitted 'RoBTT' object
#' for warnings and errors and prints them to the
#' console.
#'
#' @param fit a fitted RoBTT object.
#' @param fit a fitted 'RoBTT' object.
#'
#'
#' @return \code{check_RoBTT} returns a vector of error and
Expand Down
6 changes: 3 additions & 3 deletions R/utilities.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' @title Options for the RoBTT package
#' @title Options for the 'RoBTT' package
#'
#' @description A placeholder object and functions for the RoBTT package.
#' @description A placeholder object and functions for the 'RoBTT' package.
#' (adapted from the runjags R package).
#'
#' @param name the name of the option to get the current value of - for a list of
#' available options, see details below.
#' @param ... named option(s) to change - for a list of available options, see
#' details below.
#'
#' @return The current value of all available RoBTT options (after applying any
#' @return The current value of all available 'RoBTT' options (after applying any
#' changes specified) is returned invisibly as a named list.
#'
#' @export RoBTT.options
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ install.packages("RoBTT")
and the development version of the package can be installed from GitHub:

``` r
devtools::install_github("fbartos/RoBTT")
devtools::install_github("FBartos/RoBTT")
```


Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define a wide range of informative priors for all parameters of
interest. The package provides convenient functions for summary,
visualizations, and fit diagnostics.

See our pre-print Maier et al. (forthcoming) introducing the method.
See our pre-print Maier et al. (2022) introducing the method.

We also prepared a vignette that illustrate functionality of the
package:
Expand All @@ -47,7 +47,7 @@ install.packages("RoBTT")
and the development version of the package can be installed from GitHub:

``` r
devtools::install_github("fbartos/RoBTT")
devtools::install_github("FBartos/RoBTT")
```

### References
Expand All @@ -58,8 +58,8 @@ line-spacing="2">
<div id="ref-maier2022bayesian" class="csl-entry">

Maier, M., Bartoš, F., Quintana, D. S., Bergh, D. van den, Marsman, M.,
Ly, A., & Wagenmakers, E.-J. (forthcoming). Bayesian model-averaged
t-tests. In *PsyArxiv*.
Ly, A., & Wagenmakers, E.-J. (2022). *Model-averaged Bayesian t-tests*.
<https://doi.org/10.31234/osf.io/d5zwc>

</div>

Expand Down
8 changes: 4 additions & 4 deletions inst/REFERENCES.bib
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@unpublished{maier2022bayesian,
title = {Bayesian model-averaged t-tests},
title = {Model-averaged {B}ayesian t-tests},
author = {Maier, Maximilian and Barto{\v{s}}, Franti{\v{s}}ek and Quintana, Daniel S and van den Bergh, Don and Marsman, Maarten and Ly, Alexander and Wagenmakers, Eric-Jan},
year = {forthcoming},
journal = {PsyArxiv},
note = {(will be preprinted shorty)}
year = {2022},
note = {PsyArxiv Preprint},
doi = {10.31234/osf.io/d5zwc}
}

@book{fisher1937design,
Expand Down
23 changes: 19 additions & 4 deletions man/RoBTT.Rd

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

6 changes: 3 additions & 3 deletions man/RoBTT_options.Rd

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

6 changes: 3 additions & 3 deletions man/check_RoBTT.Rd

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

2 changes: 1 addition & 1 deletion man/fertilization.Rd

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

Loading

0 comments on commit 3bcbe1b

Please sign in to comment.