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

Prepare CRAN submission #691

Merged
merged 6 commits into from
Jan 17, 2025
Merged
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
7 changes: 3 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: bayestestR
Title: Understand and Describe Bayesian Models and Posterior Distributions
Version: 0.15.0.4
Version: 0.15.1
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down Expand Up @@ -67,7 +67,7 @@ Depends:
R (>= 3.6)
Imports:
insight (>= 1.0.0),
datawizard (>= 0.13.0),
datawizard (>= 1.0.0),
graphics,
methods,
stats,
Expand Down Expand Up @@ -95,7 +95,7 @@ Suggests:
lavaan,
lme4,
logspline (>= 2.1.21),
marginaleffects (>= 0.24.0.6),
marginaleffects (>= 0.24.0),
MASS,
mclust,
mediation,
Expand Down Expand Up @@ -128,4 +128,3 @@ Config/testthat/parallel: true
Config/rcmdcheck/ignore-inconsequential-notes: true
Config/Needs/website: easystats/easystatstemplate
Config/Needs/check: stan-dev/cmdstanr
Remotes: easystats/datawizard, vincentarelbundock/marginaleffects
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# bayestestR 0.15.0.4
# bayestestR 0.15.1

## Changes

* Several minor changes to deal with recent changes in other packages.

## Bug fixes

* Fix to `emmeans` / `marginaleffects` / `data.frame(<rvar>)` methods when using multiple credible levels (#688).


# bayestestR 0.15.0

## Changes
Expand Down
1 change: 0 additions & 1 deletion R/bayesfactor_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@
#' to match the `posterior`-type input:
#'
#' - **A numeric vector** - `prior` should also be a _numeric vector_, representing the prior-estimate.
#' - **A data frame** - `prior` should also be a _data frame_, representing the prior-estimates, in matching column order.

Check warning on line 92 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_parameters.R,line=92,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 122 characters.

Check warning on line 92 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bayesfactor_parameters.R,line=92,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 122 characters.
#' - If `rvar_col` is specified, `prior` should be _the name of an `rvar` column_ that represents the prior-estimates.
#' - **Supported Bayesian model (`stanreg`, `brmsfit`, etc.)**
#' - `prior` should be _a model an equivalent model with MCMC samples from the priors **only**_. See [unupdate()].
#' - If `prior` is set to `NULL`, [unupdate()] is called internally (not supported for `brmsfit_multiple` model).
#' - **Output from a `{marginaleffects}` function** - `prior` should also be _an equivalent output_ from a `{marginaleffects}` function based on a prior-model

Check warning on line 97 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_parameters.R,line=97,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 158 characters.

Check warning on line 97 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bayesfactor_parameters.R,line=97,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 158 characters.
#' (See [unupdate()]).
#' - **Output from an `{emmeans}` function**
#' - `prior` should also be _an equivalent output_ from an `{emmeans}` function based on a prior-model (See [unupdate()]).

Check warning on line 100 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_parameters.R,line=100,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 124 characters.

Check warning on line 100 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bayesfactor_parameters.R,line=100,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 124 characters.
#' - `prior` can also be _the original (posterior) model_, in which case the function
#' will try to "unupdate" the estimates (not supported if the estimates have undergone
#' any transformations -- `"log"`, `"response"`, etc. -- or any `regrid`ing).
Expand Down Expand Up @@ -264,7 +264,7 @@
prior <- posterior
if (verbose) {
insight::format_warning(
"Prior not specified! Please specify a prior (in the form 'prior = distribution_normal(1000, 0, 1)') to get meaningful results."

Check warning on line 267 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_parameters.R,line=267,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 136 characters.

Check warning on line 267 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bayesfactor_parameters.R,line=267,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 136 characters.
)
}
}
Expand All @@ -290,7 +290,7 @@
direction = "two-sided",
null = 0,
effects = c("fixed", "random", "all"),
component = c("conditional", "location", "smooth_terms", "sigma", "zi", "zero_inflated", "all"),

Check warning on line 293 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_parameters.R,line=293,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 139 characters.

Check warning on line 293 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bayesfactor_parameters.R,line=293,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 139 characters.
parameters = NULL,
...,
verbose = TRUE) {
Expand Down Expand Up @@ -323,7 +323,6 @@
}



#' @rdname bayesfactor_parameters
#' @export
bayesfactor_parameters.brmsfit <- bayesfactor_parameters.stanreg
Expand Down Expand Up @@ -472,7 +471,7 @@
class(bf_val)
))

attr(bf_val, "hypothesis") <- null # don't change the name of this attribute - it is used only internally for "see" and printing

Check warning on line 474 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_parameters.R,line=474,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 130 characters.

Check warning on line 474 in R/bayesfactor_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bayesfactor_parameters.R,line=474,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 130 characters.
attr(bf_val, "direction") <- direction
attr(bf_val, "plot_data") <- .make_BF_plot_data(posterior, prior, direction, null, ...)

Expand Down
11 changes: 0 additions & 11 deletions R/bci.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
bcai <- bci



#' @rdname bci
#' @export
bci.numeric <- function(x, ci = 0.95, verbose = TRUE, ...) {
Expand All @@ -40,7 +39,6 @@
}



#' @rdname bci
#' @inheritParams p_direction
#' @export
Expand All @@ -66,7 +64,6 @@
}



#' @export
bci.draws <- function(x, ci = 0.95, verbose = TRUE, ...) {
dat <- .compute_interval_dataframe(x = .posterior_draws_to_df(x), ci = ci, verbose = verbose, fun = "bci")
Expand All @@ -89,7 +86,6 @@
}



#' @export
bci.mcmc <- function(x, ci = 0.95, verbose = TRUE, ...) {
d <- as.data.frame(x)
Expand All @@ -99,7 +95,6 @@
}



#' @export
bci.bamlss <- function(x,
ci = 0.95,
Expand All @@ -114,7 +109,6 @@
}



#' @export
bci.bcplm <- function(x, ci = 0.95, verbose = TRUE, ...) {
d <- insight::get_parameters(x)
Expand All @@ -137,7 +131,6 @@
bci.BGGM <- bci.bcplm



#' @rdname bci
#' @export
bci.sim.merMod <- function(x,
Expand All @@ -161,7 +154,6 @@
}



#' @rdname bci
#' @export
bci.sim <- function(x, ci = 0.95, parameters = NULL, verbose = TRUE, ...) {
Expand All @@ -178,7 +170,6 @@
}



#' @rdname bci
#' @export
bci.emmGrid <- function(x, ci = 0.95, verbose = TRUE, ...) {
Expand Down Expand Up @@ -213,7 +204,7 @@
bci.stanreg <- function(x,
ci = 0.95,
effects = c("fixed", "random", "all"),
component = c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary"),

Check warning on line 207 in R/bci.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bci.R,line=207,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 128 characters.

Check warning on line 207 in R/bci.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/bci.R,line=207,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 128 characters.
parameters = NULL,
verbose = TRUE,
...) {
Expand Down Expand Up @@ -249,7 +240,6 @@
bci.blavaan <- bci.stanreg



#' @rdname bci
#' @export
bci.brmsfit <- function(x, ci = 0.95, effects = c("fixed", "random", "all"),
Expand Down Expand Up @@ -279,7 +269,6 @@
}



#' @rdname bci
#' @export
bci.BFBayesFactor <- function(x, ci = 0.95, verbose = TRUE, ...) {
Expand Down
3 changes: 0 additions & 3 deletions R/check_prior.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
}





#' @export
check_prior.brmsfit <- function(model,
method = "gelman",
Expand Down Expand Up @@ -189,9 +186,9 @@
}

if (method == "gelman") {
result <- mapply(.gelman, priors, posteriors)

Check warning on line 189 in R/check_prior.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_prior.R,line=189,col=15,[undesirable_function_linter] Avoid undesirable function "mapply".

Check warning on line 189 in R/check_prior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/check_prior.R,line=189,col=15,[undesirable_function_linter] Avoid undesirable function "mapply".
} else if (method == "lakeland") {
result <- mapply(.lakeland, priors, posteriors)

Check warning on line 191 in R/check_prior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/check_prior.R,line=191,col=15,[undesirable_function_linter] Avoid undesirable function "mapply".
} else {
insight::format_error("method should be 'gelman' or 'lakeland'.")
}
Expand Down
1 change: 0 additions & 1 deletion R/contr.equalprior.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ contr.equalprior_deviations <- function(n, contrasts = TRUE, sparse = FALSE) {
}



# OLD ------------------------------

#' @export
Expand Down
1 change: 0 additions & 1 deletion R/convert_pd_to_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ p_to_pd <- function(p, direction = "two-sided", ...) {
}



#' @rdname pd_to_p
#' @export
convert_p_to_pd <- p_to_pd
Expand Down
22 changes: 5 additions & 17 deletions R/describe_posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#' `"SPI"` (see [`spi()`]), or `"SI"` (see [`si()`]).
#' @param test The indices of effect existence to compute. Character (vector) or
#' list with one or more of these options: `"p_direction"` (or `"pd"`),
#' `"rope"`, `"p_map"`, `"equivalence_test"` (or `"equitest"`),
#' `"bayesfactor"` (or `"bf"`) or `"all"` to compute all tests. For each
#' "test", the corresponding \pkg{bayestestR} function is called (e.g.
#' [`rope()`] or [`p_direction()`]) and its results included in the summary
#' output.
#' `"rope"`, `"p_map"`, `"p_significance"` (or `"ps"`), `"p_rope"`,
#' `"equivalence_test"` (or `"equitest"`), `"bayesfactor"` (or `"bf"`) or
#' `"all"` to compute all tests. For each "test", the corresponding
#' \pkg{bayestestR} function is called (e.g. [`rope()`] or [`p_direction()`])
#' and its results included in the summary output.
#' @param rope_range ROPE's lower and higher bounds. Should be a vector of two
#' values (e.g., `c(-0.1, 0.1)`), `"default"` or a list of numeric vectors of
#' the same length as numbers of parameters. If `"default"`, the bounds are
Expand Down Expand Up @@ -46,7 +46,7 @@
#' - Makowski, D., Ben-Shachar, M. S., Chen, S. H. A., and Lüdecke, D. (2019).
#' *Indices of Effect Existence and Significance in the Bayesian Framework*.
#' Frontiers in Psychology 2019;10:2767. \doi{10.3389/fpsyg.2019.02767}
#' - [Region of Practical Equivalence (ROPE)](https://easystats.github.io/bayestestR/articles/region_of_practical_equivalence.html)

Check warning on line 49 in R/describe_posterior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/describe_posterior.R,line=49,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 131 characters.
#' - [Bayes factors](https://easystats.github.io/bayestestR/articles/bayes_factors.html)
#'
#' @examples
Expand Down Expand Up @@ -528,8 +528,6 @@
}




# Models based on simple data frame of posterior ---------------------


Expand Down Expand Up @@ -728,7 +726,6 @@
describe_posterior.rvar <- describe_posterior.draws



# easystats methods ------------------------


Expand Down Expand Up @@ -825,8 +822,6 @@
}




# emmeans ---------------------------


Expand Down Expand Up @@ -1221,8 +1216,6 @@
describe_posterior.blavaan <- describe_posterior.stanfit




# other models --------------------------------


Expand Down Expand Up @@ -1345,8 +1338,6 @@
}




# BayesFactor --------------------


Expand Down Expand Up @@ -1431,9 +1422,6 @@
}





# Helpers -----------------------------------------------------------------


Expand Down
1 change: 0 additions & 1 deletion R/describe_prior.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe_prior.brmsfit <- function(model,
# Internal ----------------------------------------------------------------



#' @keywords internal
.describe_prior <- function(model, parameters = NULL, ...) {
priors <- insight::get_priors(model, ...)
Expand Down
7 changes: 0 additions & 7 deletions R/distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ distribution_custom <- function(n, type = "norm", ..., random = FALSE) {
}






#' @rdname distribution
#' @inheritParams stats::rbeta
#' @export
Expand Down Expand Up @@ -99,7 +95,6 @@ distribution_binomial <- function(n, size = 1, prob = 0.5, random = FALSE, ...)
distribution_binom <- distribution_binomial



#' @rdname distribution
#' @inheritParams stats::rcauchy
#' @export
Expand Down Expand Up @@ -127,7 +122,6 @@ distribution_chisquared <- function(n, df, ncp = 0, random = FALSE, ...) {
distribution_chisq <- distribution_chisquared



#' @rdname distribution
#' @inheritParams stats::rgamma
#' @param shape Shape parameter.
Expand Down Expand Up @@ -267,7 +261,6 @@ distribution_uniform <- function(n, min = 0, max = 1, random = FALSE, ...) {
}



#' @rdname distribution
#' @inheritParams stats::rnorm
#' @export
Expand Down
5 changes: 0 additions & 5 deletions R/equivalence_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ equivalence_test.numeric <- function(x, range = "default", ci = 0.95, verbose =
}



#' @rdname equivalence_test
#' @inheritParams p_direction
#' @export
Expand Down Expand Up @@ -256,8 +255,6 @@ equivalence_test.BFBayesFactor <- function(x, range = "default", ci = 0.95, verb
}




#' @keywords internal
.equivalence_test_models <- function(x,
range = "default",
Expand Down Expand Up @@ -354,7 +351,6 @@ equivalence_test.brmsfit <- function(x,
}



#' @export
equivalence_test.sim.merMod <- function(x,
range = "default",
Expand Down Expand Up @@ -433,7 +429,6 @@ equivalence_test.mcmc.list <- equivalence_test.bcplm
equivalence_test.bayesQR <- equivalence_test.bcplm



#' @export
equivalence_test.bamlss <- function(x,
range = "default",
Expand Down
4 changes: 0 additions & 4 deletions R/estimate_density.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ estimate_density.default <- function(x, ...) {
}



# Methods -----------------------------------------------------------------

#' @export
Expand Down Expand Up @@ -589,7 +588,6 @@ estimate_density.bamlss <- function(x,
}



#' Coerce to a Data Frame
#'
#' @inheritParams base::as.data.frame
Expand Down Expand Up @@ -644,8 +642,6 @@ as.data.frame.density <- function(x, ...) {
}




#' Density Probability at a Given Value
#'
#' Compute the density value at a given point of a distribution (i.e.,
Expand Down
7 changes: 0 additions & 7 deletions R/eti.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ eti.numeric <- function(x, ci = 0.95, verbose = TRUE, ...) {
}



#' @export
#' @rdname eti
#' @inheritParams p_direction
Expand All @@ -91,7 +90,6 @@ eti.data.frame <- function(x, ci = 0.95, rvar_col = NULL, verbose = TRUE, ...) {
}



#' @export
eti.draws <- function(x, ci = 0.95, verbose = TRUE, ...) {
dat <- .compute_interval_dataframe(x = .posterior_draws_to_df(x), ci = ci, verbose = verbose, fun = "eti")
Expand All @@ -103,7 +101,6 @@ eti.draws <- function(x, ci = 0.95, verbose = TRUE, ...) {
eti.rvar <- eti.draws



#' @export
eti.MCMCglmm <- function(x, ci = 0.95, verbose = TRUE, ...) {
nF <- x$Fixed$nfl
Expand All @@ -114,7 +111,6 @@ eti.MCMCglmm <- function(x, ci = 0.95, verbose = TRUE, ...) {
}



#' @export
eti.mcmc <- function(x, ci = 0.95, verbose = TRUE, ...) {
d <- as.data.frame(x)
Expand All @@ -124,7 +120,6 @@ eti.mcmc <- function(x, ci = 0.95, verbose = TRUE, ...) {
}



#' @export
eti.bamlss <- function(x, ci = 0.95, component = c("all", "conditional", "location"), verbose = TRUE, ...) {
component <- match.arg(component)
Expand All @@ -135,7 +130,6 @@ eti.bamlss <- function(x, ci = 0.95, component = c("all", "conditional", "locati
}



#' @export
eti.bcplm <- function(x, ci = 0.95, verbose = TRUE, ...) {
d <- insight::get_parameters(x)
Expand Down Expand Up @@ -248,7 +242,6 @@ eti.stanfit <- eti.stanreg
eti.blavaan <- eti.stanreg



#' @rdname eti
#' @export
eti.brmsfit <- function(x, ci = 0.95, effects = c("fixed", "random", "all"),
Expand Down
Loading
Loading