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

Rejuvenation #625

Merged
merged 58 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6cd5d04
fix issues
strengejacke Sep 29, 2023
ebb93a9
tests
strengejacke Sep 29, 2023
4525392
fix tests
strengejacke Sep 30, 2023
87ecfdc
fix test
strengejacke Sep 30, 2023
8ab5e93
fix test
strengejacke Sep 30, 2023
8ab340d
fix tests
strengejacke Sep 30, 2023
47b6b6f
fix tests
strengejacke Sep 30, 2023
9442cb6
fix
strengejacke Sep 30, 2023
c532d69
fix test
strengejacke Sep 30, 2023
c598a17
fix tests
strengejacke Sep 30, 2023
b81dd92
fix test
strengejacke Sep 30, 2023
22f1e09
fix vignette
strengejacke Sep 30, 2023
8ba7600
fix issues
strengejacke Sep 30, 2023
55dfa5b
lintr
strengejacke Sep 30, 2023
0f2bd5b
lintr
strengejacke Sep 30, 2023
29dfe5f
fix test
strengejacke Sep 30, 2023
b30243b
fix example
strengejacke Sep 30, 2023
b89b3d9
separate internal from methods
DominiqueMakowski Sep 30, 2023
4540746
Merge branch 'fix_describe_posterior' of https://github.com/easystats…
DominiqueMakowski Sep 30, 2023
22bab9f
fix examples
strengejacke Sep 30, 2023
a2f029e
Merge branch 'fix_describe_posterior' of https://github.com/easystats…
strengejacke Sep 30, 2023
245e459
fix
strengejacke Sep 30, 2023
283556c
fix
strengejacke Sep 30, 2023
aa2b966
skip on oldrel
strengejacke Sep 30, 2023
2200807
fix?
strengejacke Sep 30, 2023
ebc39ea
fix examples
strengejacke Sep 30, 2023
b894715
replace plotting code in vignette
DominiqueMakowski Oct 1, 2023
fde822c
add p_significance.get_predicted
DominiqueMakowski Oct 1, 2023
0b07a79
update NAMESPACE
strengejacke Oct 1, 2023
80b715e
fix tests
strengejacke Oct 1, 2023
205b226
lintr
strengejacke Oct 1, 2023
d1e7649
lintr
strengejacke Oct 1, 2023
1110e91
docs
strengejacke Oct 1, 2023
e3ceb50
fix examples
strengejacke Oct 1, 2023
182a8ee
styler
strengejacke Oct 1, 2023
704d764
fix examples
strengejacke Oct 1, 2023
7706b87
fix issues
strengejacke Oct 1, 2023
9300580
lintr
strengejacke Oct 1, 2023
619a48a
fix
strengejacke Oct 1, 2023
5161a83
fix
strengejacke Oct 1, 2023
ac34535
fix examples
strengejacke Oct 1, 2023
ea13b35
fix examples
strengejacke Oct 2, 2023
7080574
make sure we have uniform get_predicted methods
strengejacke Oct 2, 2023
1aeec53
fix test
strengejacke Oct 2, 2023
cd81f07
fixes
strengejacke Oct 2, 2023
fe912b6
suppress Warnings
strengejacke Oct 2, 2023
6e9dfb1
Update test-bayesfactor_parameters.R
strengejacke Oct 2, 2023
ef7b1d4
Update test-different_models.R
strengejacke Oct 2, 2023
51279ad
Update test-describe_posterior.R
strengejacke Oct 2, 2023
4ae01b0
fix
strengejacke Oct 2, 2023
d12a16a
fix tests
strengejacke Oct 2, 2023
6fd95a9
fix
strengejacke Oct 2, 2023
399a257
generic only has one argument, #525
strengejacke Oct 2, 2023
145470a
news
strengejacke Oct 2, 2023
e5314bd
version
strengejacke Oct 2, 2023
654634c
#525
strengejacke Oct 2, 2023
c3afa44
correct URL for vignette images
IndrajeetPatil Oct 2, 2023
36f0a3e
lintr
strengejacke Oct 2, 2023
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
2 changes: 1 addition & 1 deletion 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.13.1.3
Version: 0.13.1.4
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ S3method(p_map,data.frame)
S3method(p_map,draws)
S3method(p_map,emmGrid)
S3method(p_map,emm_list)
S3method(p_map,get_predicted)
S3method(p_map,mcmc)
S3method(p_map,mcmc.list)
S3method(p_map,numeric)
Expand Down Expand Up @@ -357,6 +358,7 @@ S3method(p_significance,default)
S3method(p_significance,draws)
S3method(p_significance,emmGrid)
S3method(p_significance,emm_list)
S3method(p_significance,get_predicted)
S3method(p_significance,mcmc)
S3method(p_significance,mcmc.list)
S3method(p_significance,numeric)
Expand Down Expand Up @@ -469,6 +471,7 @@ S3method(rope,default)
S3method(rope,draws)
S3method(rope,emmGrid)
S3method(rope,emm_list)
S3method(rope,get_predicted)
S3method(rope,mcmc)
S3method(rope,mcmc.list)
S3method(rope,numeric)
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

## Breaking Changes

* `pd_to_p()` now returns 1 and a warning for pds smaller than 0.5.
* `pd_to_p()` now returns 1 and a warning for values smaller than 0.5.

* `map_estimate()`, `p_direction()`, `p_map()`, and `p_significance()` now
return a data-frame when the input is a numeric vector. (making the output
consistently a data frame for all inputs.)

* Argument `posteriors` was renamed into `posterior`. Before, there were a mix
of both spellings, now it is consistently `posterior`.

## Changes

* Retrieving models from the environment was improved.
Expand All @@ -19,6 +23,8 @@
* Fixed issue in `estimate_density()` for double vectors that also had other
class attributes.

* Fixed several minor issues and tests.

# bayestestR 0.13.1

## Changes
Expand Down
2 changes: 1 addition & 1 deletion R/area_under_curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' @seealso DescTools
#' @export
area_under_curve <- function(x, y, method = c("trapezoid", "step", "spline"), ...) {
# Stolen from DescTools: https://github.com/cran/DescTools/blob/master/R/StatsAndCIs.r
# From DescTools [GPL-3]: https://github.com/cran/DescTools/blob/master/R/StatsAndCIs.r

if (length(x) != length(y)) {
insight::format_error("Length of x must be equal to length of y.")
Expand All @@ -42,9 +42,9 @@
y <- y[idx]

switch(match.arg(arg = method, choices = c("trapezoid", "step", "spline")),
"trapezoid" = sum((rowMeans(cbind(y[-length(y)], y[-1]))) * (x[-1] - x[-length(x)])),

Check warning on line 45 in R/area_under_curve.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/area_under_curve.R,line=45,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).

Check warning on line 45 in R/area_under_curve.R

View workflow job for this annotation

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

file=R/area_under_curve.R,line=45,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"step" = sum(y[-length(y)] * (x[-1] - x[-length(x)])),

Check warning on line 46 in R/area_under_curve.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/area_under_curve.R,line=46,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).

Check warning on line 46 in R/area_under_curve.R

View workflow job for this annotation

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

file=R/area_under_curve.R,line=46,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"spline" = stats::integrate(stats::splinefun(x, y, method = "natural"), lower = min(x), upper = max(x))$value

Check warning on line 47 in R/area_under_curve.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/area_under_curve.R,line=47,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).

Check warning on line 47 in R/area_under_curve.R

View workflow job for this annotation

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

file=R/area_under_curve.R,line=47,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
)
}

Expand Down
49 changes: 22 additions & 27 deletions R/bayesfactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,30 @@
#'
#' @note There is also a [`plot()`-method](https://easystats.github.io/see/articles/bayestestR.html) implemented in the \href{https://easystats.github.io/see/}{\pkg{see}-package}.
#'
#' @examples
#' @examplesIf require("rstanarm") && require("logspline")
#' library(bayestestR)
#'
#' if (require("logspline")) {
#' prior <- distribution_normal(1000, mean = 0, sd = 1)
#' posterior <- distribution_normal(1000, mean = .5, sd = .3)
#' prior <- distribution_normal(1000, mean = 0, sd = 1)
#' posterior <- distribution_normal(1000, mean = .5, sd = .3)
#'
#' bayesfactor(posterior, prior = prior, verbose = FALSE)
#'
#' bayesfactor(posterior, prior = prior, verbose = FALSE)
#' }
#' \donttest{
#' # rstanarm models
#' # ---------------
#' if (require("rstanarm")) {
#' model <- stan_lmer(extra ~ group + (1 | ID), data = sleep)
#' bayesfactor(model, verbose = FALSE)
#' }
#' }
#' model <- suppressWarnings(rstanarm::stan_lmer(extra ~ group + (1 | ID), data = sleep))
#' bayesfactor(model, verbose = FALSE)
#'
#' if (require("logspline")) {
#' # Frequentist models
#' # ---------------
#' m0 <- lm(extra ~ 1, data = sleep)
#' m1 <- lm(extra ~ group, data = sleep)
#' m2 <- lm(extra ~ group + ID, data = sleep)
#' # Frequentist models
#' # ---------------
#' m0 <- lm(extra ~ 1, data = sleep)
#' m1 <- lm(extra ~ group, data = sleep)
#' m2 <- lm(extra ~ group + ID, data = sleep)
#'
#' comparison <- bayesfactor(m0, m1, m2)
#' comparison
#' comparison <- bayesfactor(m0, m1, m2)
#' comparison
#'
#' bayesfactor(comparison)
#' bayesfactor(comparison)
#' }
#' @export
bayesfactor <- function(...,
Expand All @@ -75,13 +70,7 @@ bayesfactor <- function(...,
} else {
bayesfactor_models(...)
}
} else if (!is.null(hypothesis)) {
bayesfactor_restricted(...,
prior = prior,
verbose = verbose,
effects = effects
)
} else {
} else if (is.null(hypothesis)) {
bayesfactor_parameters(
...,
prior = prior,
Expand All @@ -90,5 +79,11 @@ bayesfactor <- function(...,
effects = effects,
verbose = verbose
)
} else {
bayesfactor_restricted(...,
prior = prior,
verbose = verbose,
effects = effects
)
}
}
7 changes: 2 additions & 5 deletions R/bayesfactor_inclusion.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#'
#' @seealso [weighted_posteriors()] for Bayesian parameter averaging.
#'
#' @examples
#' @examplesIf require("BayesFactor")
#' library(bayestestR)
#'
#' # Using bayesfactor_models:
Expand All @@ -55,10 +55,7 @@
#' \donttest{
#' # BayesFactor
#' # -------------------------------
#' library(BayesFactor)
#'
#' BF <- generalTestBF(len ~ supp * dose, ToothGrowth, progress = FALSE)
#'
#' BF <- BayesFactor::generalTestBF(len ~ supp * dose, ToothGrowth, progress = FALSE)
#' bayesfactor_inclusion(BF)
#'
#' # compare only matched models:
Expand Down Expand Up @@ -110,7 +107,7 @@
df.interaction <- data.frame(effnames, stringsAsFactors = FALSE)

for (eff in effnames) {
df.interaction[, eff] <- sapply(effnames, .includes_interaction, effnames = eff)

Check warning on line 110 in R/bayesfactor_inclusion.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_inclusion.R,line=110,col=32,[undesirable_function_linter] Function "sapply" is undesirable.

Check warning on line 110 in R/bayesfactor_inclusion.R

View workflow job for this annotation

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

file=R/bayesfactor_inclusion.R,line=110,col=32,[undesirable_function_linter] Function "sapply" is undesirable.
}
rownames(df.interaction) <- effnames
df.interaction <- as.matrix(df.interaction[, -1])
Expand Down
98 changes: 47 additions & 51 deletions R/bayesfactor_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#' random effects) and their `log(BF)`s (Use `as.numeric()` to extract the
#' non-log Bayes factors; see examples), that prints nicely.
#'
#' @examples
#' @examplesIf require("lme4") && require("BayesFactor") && require("rstanarm") && require("brms")
#' # With lm objects:
#' # ----------------
#' lm1 <- lm(mpg ~ 1, data = mtcars)
Expand All @@ -66,81 +66,72 @@
#' # bayesfactor_models(lm2, lm3, lm4, denominator = lm1) # same result
#' # bayesfactor_models(lm1, lm2, lm3, lm4, denominator = lm1) # same result
#'
#'
#' update(BFM, reference = "bottom")
#' as.matrix(BFM)
#' as.numeric(BFM)
#'
#'
#' lm2b <- lm(sqrt(mpg) ~ hp, data = mtcars)
#' # Set check_response = TRUE for transformed responses
#' bayesfactor_models(lm2b, denominator = lm2, check_response = TRUE)
#'
#' \donttest{
#' # With lmerMod objects:
#' # ---------------------
#' if (require("lme4")) {
#' lmer1 <- lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
#' lmer2 <- lmer(Sepal.Length ~ Petal.Length + (Petal.Length | Species), data = iris)
#' lmer3 <- lmer(Sepal.Length ~ Petal.Length + (Petal.Length | Species) + (1 | Petal.Width),
#' data = iris
#' )
#' bayesfactor_models(lmer1, lmer2, lmer3,
#' denominator = 1,
#' estimator = "REML"
#' )
#' }
#' lmer1 <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
#' lmer2 <- lme4::lmer(Sepal.Length ~ Petal.Length + (Petal.Length | Species), data = iris)
#' lmer3 <- lme4::lmer(
#' Sepal.Length ~ Petal.Length + (Petal.Length | Species) + (1 | Petal.Width),
#' data = iris
#' )
#' bayesfactor_models(lmer1, lmer2, lmer3,
#' denominator = 1,
#' estimator = "REML"
#' )
#'
#' # rstanarm models
#' # ---------------------
#' # (note that a unique diagnostic_file MUST be specified in order to work)
#' if (require("rstanarm")) {
#' stan_m0 <- stan_glm(Sepal.Length ~ 1,
#' data = iris,
#' family = gaussian(),
#' diagnostic_file = file.path(tempdir(), "df0.csv")
#' )
#' stan_m1 <- stan_glm(Sepal.Length ~ Species,
#' data = iris,
#' family = gaussian(),
#' diagnostic_file = file.path(tempdir(), "df1.csv")
#' )
#' stan_m2 <- stan_glm(Sepal.Length ~ Species + Petal.Length,
#' data = iris,
#' family = gaussian(),
#' diagnostic_file = file.path(tempdir(), "df2.csv")
#' )
#' bayesfactor_models(stan_m1, stan_m2, denominator = stan_m0, verbose = FALSE)
#' }
#' stan_m0 <- suppressWarnings(rstanarm::stan_glm(Sepal.Length ~ 1,
#' data = iris,
#' family = gaussian(),
#' diagnostic_file = file.path(tempdir(), "df0.csv")
#' ))
#' stan_m1 <- suppressWarnings(rstanarm::stan_glm(Sepal.Length ~ Species,
#' data = iris,
#' family = gaussian(),
#' diagnostic_file = file.path(tempdir(), "df1.csv")
#' ))
#' stan_m2 <- suppressWarnings(rstanarm::stan_glm(Sepal.Length ~ Species + Petal.Length,
#' data = iris,
#' family = gaussian(),
#' diagnostic_file = file.path(tempdir(), "df2.csv")
#' ))
#' bayesfactor_models(stan_m1, stan_m2, denominator = stan_m0, verbose = FALSE)
#'
#'
#' # brms models
#' # --------------------
#' # (note the save_pars MUST be set to save_pars(all = TRUE) in order to work)
#' if (require("brms")) {
#' brm1 <- brm(Sepal.Length ~ 1, data = iris, save_pars = save_pars(all = TRUE))
#' brm2 <- brm(Sepal.Length ~ Species, data = iris, save_pars = save_pars(all = TRUE))
#' brm3 <- brm(
#' Sepal.Length ~ Species + Petal.Length,
#' data = iris,
#' save_pars = save_pars(all = TRUE)
#' )
#' brm1 <- brms::brm(Sepal.Length ~ 1, data = iris, save_pars = save_pars(all = TRUE))
#' brm2 <- brms::brm(Sepal.Length ~ Species, data = iris, save_pars = save_pars(all = TRUE))
#' brm3 <- brms::brm(
#' Sepal.Length ~ Species + Petal.Length,
#' data = iris,
#' save_pars = save_pars(all = TRUE)
#' )
#'
#' bayesfactor_models(brm1, brm2, brm3, denominator = 1, verbose = FALSE)
#' }
#' bayesfactor_models(brm1, brm2, brm3, denominator = 1, verbose = FALSE)
#'
#'
#' # BayesFactor
#' # ---------------------------
#' if (require("BayesFactor")) {
#' data(puzzles)
#' BF <- anovaBF(RT ~ shape * color + ID,
#' data = puzzles,
#' whichRandom = "ID", progress = FALSE
#' )
#' BF
#' bayesfactor_models(BF) # basically the same
#' }
#' data(puzzles)
#' BF <- BayesFactor::anovaBF(RT ~ shape * color + ID,
#' data = puzzles,
#' whichRandom = "ID", progress = FALSE
#' )
#' BF
#' bayesfactor_models(BF) # basically the same
#' }
#'
#' @references
Expand Down Expand Up @@ -169,6 +160,7 @@
#' @export
bf_models <- bayesfactor_models


#' @export
#' @rdname bayesfactor_models
bayesfactor_models.default <- function(..., denominator = 1, verbose = TRUE) {
Expand All @@ -185,7 +177,7 @@
cl$...$estimator <- cl$...$check_response <- NULL


names(mods) <- sapply(cl$`...`, insight::safe_deparse)

Check warning on line 180 in R/bayesfactor_models.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_models.R,line=180,col=18,[undesirable_function_linter] Function "sapply" is undesirable.

Check warning on line 180 in R/bayesfactor_models.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_models.R,line=180,col=28,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.

Check warning on line 180 in R/bayesfactor_models.R

View workflow job for this annotation

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

file=R/bayesfactor_models.R,line=180,col=18,[undesirable_function_linter] Function "sapply" is undesirable.

Check warning on line 180 in R/bayesfactor_models.R

View workflow job for this annotation

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

file=R/bayesfactor_models.R,line=180,col=28,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
names(denominator) <- insight::safe_deparse(cl$denominator)

mods <- .cleanup_BF_models(mods, denominator, cl)
Expand All @@ -196,9 +188,9 @@
# supported models
supported_models <- vapply(mods, insight::is_model_supported, TRUE)
if (all(supported_models)) {
temp_forms <- sapply(mods, .find_full_formula)

Check warning on line 191 in R/bayesfactor_models.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_models.R,line=191,col=19,[undesirable_function_linter] Function "sapply" is undesirable.

Check warning on line 191 in R/bayesfactor_models.R

View workflow job for this annotation

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

file=R/bayesfactor_models.R,line=191,col=19,[undesirable_function_linter] Function "sapply" is undesirable.

has_terms <- sapply(temp_forms, nchar) > 0

Check warning on line 193 in R/bayesfactor_models.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_models.R,line=193,col=18,[undesirable_function_linter] Function "sapply" is undesirable.

Check warning on line 193 in R/bayesfactor_models.R

View workflow job for this annotation

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

file=R/bayesfactor_models.R,line=193,col=18,[undesirable_function_linter] Function "sapply" is undesirable.

mforms[has_terms] <- temp_forms[has_terms]
supported_models[!has_terms] <- FALSE
Expand All @@ -217,7 +209,7 @@

# Get BIC
if (were_checked && estimator == "REML" &&
any(vapply(mods, insight::is_mixed_model, TRUE)) &&

Check warning on line 212 in R/bayesfactor_models.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_models.R,line=212,col=6,[indentation_linter] Indentation should be 10 spaces but is 6 spaces.
!isTRUE(attr(objects, "same_fixef")) &&
verbose) {
insight::format_warning(paste(
Expand All @@ -230,7 +222,7 @@
insight::format_alert("Unable to validate that all models were fit with the same data.")
}

mBIC <- tryCatch(sapply(mods, function(m) {

Check warning on line 225 in R/bayesfactor_models.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/bayesfactor_models.R,line=225,col=20,[undesirable_function_linter] Function "sapply" is undesirable.

Check warning on line 225 in R/bayesfactor_models.R

View workflow job for this annotation

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

file=R/bayesfactor_models.R,line=225,col=20,[undesirable_function_linter] Function "sapply" is undesirable.
LL <- insight::get_loglikelihood(
m,
estimator = estimator, check_response = check_response
Expand All @@ -238,7 +230,7 @@
stats::BIC(LL)
}), error = function(...) NULL)

if (is.null(mBIC)) mBIC <- sapply(mods, stats::BIC)

Check warning on line 233 in R/bayesfactor_models.R

View workflow job for this annotation

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

file=R/bayesfactor_models.R,line=233,col=30,[undesirable_function_linter] Function "sapply" is undesirable.

# Get BF
mBFs <- bic_to_bf(mBIC, denominator = mBIC[denominator], log = TRUE)
Expand Down Expand Up @@ -289,6 +281,7 @@
)
}


#' @keywords internal
.bayesfactor_models_stan_REG <- function(mods, denominator, verbose = TRUE) {
insight::check_if_installed("bridgesampling")
Expand Down Expand Up @@ -356,6 +349,7 @@
.bayesfactor_models_stan(mods, denominator = denominator, verbose = verbose)
}


#' @export
bayesfactor_models.brmsfit <- function(..., denominator = 1, verbose = TRUE) {
insight::check_if_installed("brms")
Expand All @@ -374,6 +368,7 @@
.bayesfactor_models_stan(mods, denominator = denominator, verbose = verbose)
}


#' @export
bayesfactor_models.blavaan <- function(..., denominator = 1, verbose = TRUE) {
insight::check_if_installed("blavaan")
Expand All @@ -392,6 +387,7 @@
.bayesfactor_models_stan(mods, denominator = denominator, verbose = verbose)
}


#' @export
bayesfactor_models.BFBayesFactor <- function(..., verbose = TRUE) {
models <- c(...)
Expand Down
15 changes: 10 additions & 5 deletions R/bci.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,19 @@ bci.BFBayesFactor <- function(x, ci = 0.95, verbose = TRUE, ...) {
}


#' @rdname bci
#' @export
bci.get_predicted <- function(x, ...) {
if ("iterations" %in% names(attributes(x))) {
out <- bci(as.data.frame(t(attributes(x)$iterations)), ...)
bci.get_predicted <- function(x, ci = 0.95, use_iterations = FALSE, verbose = TRUE, ...) {
if (isTRUE(use_iterations)) {
if ("iterations" %in% names(attributes(x))) {
out <- bci(as.data.frame(t(attributes(x)$iterations)), ci = ci, verbose = verbose, ...)
} else {
insight::format_error("No iterations present in the output.")
}
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x))
} else {
insight::format_error("No iterations present in the output.")
out <- bci(as.numeric(x), ci = ci, verbose = verbose, ...)
}
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x))
out
}

Expand Down
Loading
Loading