# Brms model selection ：I can't calculate the result of bf

In particular, I want to calculate the Bayes factor of the two models, but I can’t make it by BayesFactor and get the following error.I would like to ask you what went wrong, why can’t I calculate the Bayes factor?
Firstly, I tried bayes_factor directly.

Secondly, I tried bridge_sample which could caculate the marginal likelihood

``````lmm_test <- lmer(value ~ y1+y2+y3+y4+y5+y6+y7+y8+y9+y10+y11+y12+y13+y14+y15+y16
+ (1 | industry)
+ (1 | firm:industry)
+ (1 | ceo:firm:industry)
+(1 | chair:firm:industry)
, data = preference)
summary(lmm_test)

prior_ = prior(inv_gamma(2,1), class = sd)
# 3.bayes
#
fit_h0 <- brm(
bf(value ~ 1
+ (0+dummy(indicator,'1') | industry) + (0+dummy(indicator,'0') | industry)
+ (0+dummy(indicator,'1')  | firm:industry)+ (0+dummy(indicator,'0')  | firm:industry)
+ (0+dummy(indicator,'1')  | ceo:firm:industry) + (0+dummy(indicator,'0')  | ceo:firm:industry)
+(0+dummy(indicator,'1') | chair:firm:industry)+(0+dummy(indicator,'0') | chair:firm:industry)),
data = preference,
prior = prior_,
save_pars = save_pars(all = TRUE)
)
##
summary(fit_h0)

prior_ = prior(inv_gamma(2,1), class = sd)

#
fit_h1 <- brm(
bf(value ~ indicator+y1+y2+y3+y4+y5+y6+y7+y8+y9+y10+y11+y12+y13+y14+y15+y16
+ (0+dummy(indicator,'1') | industry) + (0+dummy(indicator,'0') | industry)
+ (0+dummy(indicator,'1')  | firm:industry)+ (0+dummy(indicator,'0')  | firm:industry)
+ (1 | ceo:firm:industry)
+(0+dummy(indicator,'1') | chair:firm:industry)+(0+dummy(indicator,'0') | chair:firm:industry)),
data = preference,
prior = prior_,
save_pars = save_pars(all = TRUE)
# save_pars=save_pars(group=FALSE)
)
summary(fit_h1)

#firstly,
bayes_factor(fit_h0,fit_h1)
#secondly,
bridge_sampler(fit_h1)
``````
• Operating System: mac os 13.2.1 – 8 GB
• brms Version: 2.20.3

Thx!