The log_lik
function does not seem to work if the Bernoulli model is created with data that only has one data point. This is the case even if I only sample the prior. Is this expected?
The use case is I would actually like to fit the model with a single data point, but then get the posterior likelihood for new theoretical data. Is there a way to specify the levels of the Bernoulli response without having all present in the data?
library(brms)
# this works
dat <- data.frame(x = 0:1, y = 0:1)
priors = c(
prior(normal(0,1), class = "Intercept"),
prior(normal(0,1), class = "b")
)
model <- brm(
y ~ x,
family = bernoulli(),
data = dat,
prior = priors,
sample_prior = "only"
)
model
new_dat <- data.frame(x = 0:1, y = 0:1)
ll <- log_lik(model, newdata = new_dat)
# this doesn't
dat <- data.frame(x = 1, y = 1)
model <- brm(
y ~ x,
family = bernoulli(),
data = dat,
prior = priors,
sample_prior = "only"
)
model
new_dat <- data.frame(x = 0:1, y = 0:1)
ll <- log_lik(model, newdata = new_dat)
- Operating System: Ubuntu 20.04.4
- brms Version: 2.16.3