# NOT RUN {
roaches$roach100 <- roaches$roach1 / 100
fit <- stan_glm(
y ~ roach100 + treatment + senior,
offset = log(exposure2),
data = roaches,
family = poisson(link = "log"),
prior = normal(0, 2.5),
prior_intercept = normal(0, 10),
iter = 500, # just to speed up example,
refresh = 0
)
ll <- log_lik(fit)
dim(ll)
all.equal(ncol(ll), nobs(fit))
# using newdata argument
nd <- roaches[1:2, ]
nd$treatment[1:2] <- c(0, 1)
ll2 <- log_lik(fit, newdata = nd, offset = c(0, 0))
head(ll2)
dim(ll2)
all.equal(ncol(ll2), nrow(nd))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab