Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
Merge bd1f9ad into 0e7f772
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Oct 23, 2020
2 parents 0e7f772 + bd1f9ad commit 5319e96
Show file tree
Hide file tree
Showing 41 changed files with 993 additions and 394 deletions.
43 changes: 30 additions & 13 deletions .github/workflows/check-full.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: R-CMD-check
Expand All @@ -30,53 +32,68 @@ jobs:

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}

- uses: r-lib/actions/setup-pandoc@master

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2)
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check")
env:
_R_CHECK_CRAN_INCOMING_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
10 changes: 9 additions & 1 deletion .github/workflows/check-release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
on: [push, pull_request]
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: R-CMD-check

Expand Down
3 changes: 2 additions & 1 deletion API
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ bf_contingency_tab(data, x, y = NULL, counts = NULL, ratio = NULL, sampling.plan
bf_corr_test(data, x, y, bf.prior = 0.707, top.text = NULL, output = "dataframe", k = 2L, ...)
bf_expr(bf.object, k = 2L, conf.level = 0.95, conf.method = "hdi", centrality = "median", top.text = NULL, anova.design = FALSE, ...)
bf_extractor(bf.object, ...)
bf_meta(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2L, output = "dataframe", top.text = NULL, ...)
bf_meta(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2L, conf.level = 0.95, output = "dataframe", top.text = NULL, ...)
bf_meta_random(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2L, conf.level = 0.95, output = "dataframe", top.text = NULL, ...)
bf_oneway_anova(data, x, y, subject.id = NULL, bf.prior = 0.707, top.text = NULL, output = "dataframe", paired = FALSE, k = 2L, ...)
bf_ttest(data, x, y = NULL, subject.id = NULL, test.value = 0, paired = FALSE, bf.prior = 0.707, top.text = NULL, output = "dataframe", k = 2L, ...)
meta_data_check(data)
Expand Down
15 changes: 11 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ URL: https://indrajeetpatil.github.io/tidyBF/,
BugReports: https://github.com/IndrajeetPatil/tidyBF/issues
Remotes:
easystats/insight,
IndrajeetPatil/ipmisc
easystats/bayestestR,
easystats/parameters,
easystats/performance,
IndrajeetPatil/ipmisc,
richarddmorey/BayesFactor/pkg/BayesFactor
Encoding: UTF-8
Language: en-US
LazyData: true
Expand All @@ -32,12 +36,15 @@ RoxygenNote: 7.1.1
Depends:
R (>= 3.6.0)
Imports:
BayesFactor,
BayesFactor (>= 0.9.12-4.3),
bayestestR (>= 0.7.5),
dplyr,
insight (>= 0.9.6.1),
insight (>= 0.10.1),
ipmisc (>= 4.1.0),
lme4,
metaBMA,
parameters,
parameters (>= 0.8.6.1),
performance (>= 0.5.0),
rlang,
tidyr
Suggests:
Expand Down
11 changes: 8 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(bf_corr_test)
export(bf_expr)
export(bf_extractor)
export(bf_meta)
export(bf_meta_random)
export(bf_oneway_anova)
export(bf_ttest)
export(meta_data_check)
Expand All @@ -21,15 +22,16 @@ export(tibble)
importFrom(BayesFactor,anovaBF)
importFrom(BayesFactor,contingencyTableBF)
importFrom(BayesFactor,correlationBF)
importFrom(BayesFactor,extractBF)
importFrom(BayesFactor,logMeanExpLogs)
importFrom(BayesFactor,ttestBF)
importFrom(bayestestR,describe_prior)
importFrom(dplyr,bind_cols)
importFrom(dplyr,mutate)
importFrom(dplyr,pull)
importFrom(dplyr,recode)
importFrom(dplyr,rename)
importFrom(dplyr,rename_all)
importFrom(dplyr,rename_with)
importFrom(dplyr,select)
importFrom(dplyr,starts_with)
importFrom(dplyr,tibble)
importFrom(insight,standardize_names)
importFrom(ipmisc,"%$%")
Expand All @@ -42,9 +44,12 @@ importFrom(ipmisc,long_to_wide_converter)
importFrom(ipmisc,red)
importFrom(ipmisc,specify_decimal_p)
importFrom(ipmisc,tibble)
importFrom(lme4,findbars)
importFrom(lme4,nobars)
importFrom(metaBMA,meta_random)
importFrom(metaBMA,prior)
importFrom(parameters,model_parameters)
importFrom(performance,r2_bayes)
importFrom(rlang,"%|%")
importFrom(rlang,"%||%")
importFrom(rlang,":=")
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ BREAKING CHANGES

- The *t*-test and ANOVA tests get `subject.id` argument relevant for repeated
measures design.

- Renames `bf_meta` to `bf_meta_random`. The previous alias is retained for
now but will be retired in future releases.

MAJOR CHANGES

- Replaces the heavier `broomExtra` dependency with `parameters`.

- `bf_oneway_anova` now returns model-averaged R-squared posterior as a
measure of effect size.

# tidyBF 0.3.0

Expand Down
4 changes: 2 additions & 2 deletions R/bf_contingency_tab.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ bf_contingency_tab <- function(data,
# the final expression
if (is.null(top.text)) bf01_expr <- bf01_expr$expr

# return the text results or the dataframe with results
# return the expression or the dataframe
switch(
EXPR = output,
"dataframe" = dplyr::select(df, -dplyr::matches("error|time|code")),
"dataframe" = df,
bf01_expr
)
}
52 changes: 34 additions & 18 deletions R/bf_meta.R → R/bf_meta_random.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @title Bayes factor for random-effects meta-analysis
#' @name bf_meta
#' @name bf_meta_random
#'
#' @importFrom metaBMA meta_random prior
#'
Expand All @@ -10,7 +10,7 @@
#' @inheritParams bf_expr
#' @inheritParams bf_ttest
#' @inheritParams metaBMA::meta_random
#' @inheritDotParams metaBMA::meta_random -y -SE
#' @inheritDotParams metaBMA::meta_random -y -SE -ci
#'
#' @examples
#'
Expand Down Expand Up @@ -44,7 +44,7 @@
#' ))
#'
#' # to get dataframe
#' bf_meta(
#' bf_meta_random(
#' data = df,
#' k = 3,
#' iter = 1500,
Expand All @@ -57,13 +57,14 @@
#' @export

# function body
bf_meta <- function(data,
d = prior("norm", c(mean = 0, sd = 0.3)),
tau = prior("invgamma", c(shape = 1, scale = 0.15)),
k = 2L,
output = "dataframe",
top.text = NULL,
...) {
bf_meta_random <- function(data,
d = prior("norm", c(mean = 0, sd = 0.3)),
tau = prior("invgamma", c(shape = 1, scale = 0.15)),
k = 2L,
conf.level = 0.95,
output = "dataframe",
top.text = NULL,
...) {

# check the data contains needed column
meta_data_check(data)
Expand All @@ -77,6 +78,7 @@ bf_meta <- function(data,
SE = data$std.error,
d = d,
tau = tau,
ci = conf.level,
...
)

Expand All @@ -99,21 +101,27 @@ bf_meta <- function(data,
", ",
widehat(italic(delta))["mean"]^"posterior",
" = ",
d.pmean,
", CI"["95%"],
estimate,
", CI"[conf.level]^"HDI",
" [",
d.pmean.LB,
estimate.LB,
", ",
d.pmean.UB,
"]"
estimate.UB,
"]",
", ",
italic("r")["Cauchy"]^"JZS",
" = ",
bf.prior
)
),
env = list(
top.text = top.text,
bf = specify_decimal_p(x = -log(df$bf10[[1]]), k = k),
d.pmean = specify_decimal_p(x = df$mean[[1]], k = k),
d.pmean.LB = specify_decimal_p(x = df$hpd95_lower[[1]], k = k),
d.pmean.UB = specify_decimal_p(x = df$hpd95_upper[[1]], k = k)
conf.level = paste0(conf.level * 100, "%"),
estimate = specify_decimal_p(x = df$mean[[1]], k = k),
estimate.LB = specify_decimal_p(x = df$hpd95_lower[[1]], k = k),
estimate.UB = specify_decimal_p(x = df$hpd95_upper[[1]], k = k),
bf.prior = specify_decimal_p(x = mod$jzs$rscale_discrete[[1]], k = k)
)
)

Expand All @@ -127,3 +135,11 @@ bf_meta <- function(data,
bf01_expr
)
}

# aliases -----------------------------------------------------------------

#' @rdname bf_meta_random
#' @aliases bf_meta_random
#' @export

bf_meta <- bf_meta_random
1 change: 1 addition & 0 deletions R/bf_oneway_anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @importFrom dplyr mutate
#' @importFrom rlang new_formula enexpr expr
#' @importFrom ipmisc long_to_wide_converter
#' @importFrom lme4 nobars findbars
#'
#' @param data A dataframe (or a tibble) from which variables specified are to
#' be taken. A matrix or tables will **not** be accepted.
Expand Down
12 changes: 11 additions & 1 deletion R/global_vars.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# defining global variables and functions to appease R CMD Check

utils::globalVariables(
names = c(".", "bf10", "rowid"),
names = c(
".",
"bf10",
"rowid",
"bf.prior",
"component",
"estimate",
"estimate.LB",
"estimate.UB",
"term"
),
package = "tidyBF",
add = FALSE
)

0 comments on commit 5319e96

Please sign in to comment.