diff --git a/R/bayesfactor_restricted.R b/R/bayesfactor_restricted.R index 454d9adff..9fb97b7f4 100644 --- a/R/bayesfactor_restricted.R +++ b/R/bayesfactor_restricted.R @@ -136,7 +136,7 @@ bayesfactor_restricted.stanreg <- function(posterior, hypothesis, prior = NULL, component <- match.arg(component) samps <- .clean_priors_and_posteriors(posterior, prior, - effects, component, + effects = effects, component = component, verbose = verbose ) @@ -217,7 +217,7 @@ bayesfactor_restricted.data.frame <- function(posterior, hypothesis, prior = NUL posterior_l <- as.data.frame(lapply(p_hypothesis, .test_hypothesis, data = posterior)) prior_l <- as.data.frame(lapply(p_hypothesis, .test_hypothesis, data = prior)) - colnames(posterior_l) <- colnames(prior_l) <- if (!is.null(names(hypothesis))) names(hypothesis) else hypothesis + colnames(posterior_l) <- colnames(prior_l) <- if (is.null(names(hypothesis))) hypothesis else names(hypothesis) posterior_p <- sapply(posterior_l, mean) prior_p <- sapply(prior_l, mean) diff --git a/R/utils_bayesfactor.R b/R/utils_bayesfactor.R index ed58a6673..8bf6075ef 100644 --- a/R/utils_bayesfactor.R +++ b/R/utils_bayesfactor.R @@ -7,8 +7,6 @@ #' @keywords internal .clean_priors_and_posteriors.stanreg <- function(posterior, prior, - effects, component, - parameters = NULL, verbose = TRUE, ...) { # Get Priors @@ -30,8 +28,8 @@ insight::format_error(prior) } - prior <- insight::get_parameters(prior, effects = effects, component = component, ...) - posterior <- insight::get_parameters(posterior, effects = effects, component = component, ...) + prior <- insight::get_parameters(prior, ...) + posterior <- insight::get_parameters(posterior, ...) list( posterior = posterior, @@ -192,11 +190,10 @@ # Prior and post odds Modelnames <- BFGrid$Model - if (!is.null(priorOdds)) { - priorOdds <- c(1, priorOdds) - } else { - priorOdds <- rep(1, length(Modelnames)) + if (is.null(priorOdds)) { + priorOdds <- rep(1, length(Modelnames) - 1) } + priorOdds <- c(1, priorOdds) prior_logodds <- log(priorOdds) posterior_logodds <- prior_logodds + BFGrid$log_BF