Skip to content

Commit

Permalink
fix and de-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Feb 6, 2024
1 parent 85dbf30 commit df3fcb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions R/bayesfactor_restricted.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bayesfactor_restricted.stanreg <- function(posterior, hypothesis, prior = NULL,

samps <- .clean_priors_and_posteriors(posterior, prior,
effects = effects, component = component,
parameters = parameters, verbose = verbose
verbose = verbose
)

# Get savage-dickey BFs
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions R/utils_bayesfactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,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
Expand Down

0 comments on commit df3fcb7

Please sign in to comment.