This function computes Bayes Factors (BF) for each dataset in a fash object. The BF is calculated as the ratio of likelihood under the alternative hypothesis to the likelihood under the null hypothesis.

BF_compute(fash)

Arguments

fash

A fash object containing the fitted model and likelihood matrix.

Value

A numeric vector of Bayes Factors, where each entry corresponds to a dataset.

Examples

set.seed(1)
data_list <- list(
  data.frame(y = rpois(5, lambda = 5), x = 1:5, offset = 0),
  data.frame(y = rpois(5, lambda = 5), x = 1:5, offset = 0)
)
grid <- seq(0, 2, length.out = 10)
fash_obj <- fash(data_list = data_list, Y = "y", smooth_var = "x", grid = grid, likelihood = "poisson", verbose = TRUE)
#> Starting data setup...
#> Completed data setup in 0.00 seconds.
#> Starting likelihood computation...
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%
#> Completed likelihood computation in 0.18 seconds.
#> Starting empirical Bayes estimation...
#> Completed empirical Bayes estimation in 0.00 seconds.
#> fash object created successfully.

# Compute Bayes Factors
BF_values <- BF_compute(fash_obj)
print(BF_values)
#> [1] NaN NaN