Hello all,
Very simple question on creating an intercept-only model: How do I do it? I would have thought my code below would work, but it is returning an error.
> InterceptModel <- stan_glm(
+ Accept_Reject ~ 1,
+ data = pubdata,
+ family = binomial(link = "logit"),
+ prior_intercept = NULL,
+ cores=3,
+ QR = FALSE,
+ chains = 3, iter = 50000,
+ diagnostic_file=file.path(tempdir(), "df.csv"))
bridge4<-bridge_sampler(InterceptModel)
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
no lines available in input
describe_posterior(InterceptModel)
Error in dat[, -1, drop = FALSE] : incorrect number of dimensions
I think stan_glm is working but bridge_sampler is returning an error, but I’m not sure why. Does file.path(tempdir(), "df.csv") exist and have values?
Not sure to be honest, as I don’t even understand that line of code. I got it from your suggestion actually, in this post I made a while ago. I’ve been sticking it in every model I’ve been running so that I can compare all the models with Bayes Factors later with performance::compare_performance() and bayestestR::bayesfactor_models()
So far I’ve copied and pasted that one same line into three other models in my RMarkdown file and all of them work fine; its just this 4th, intercept-only model that breaks.
Just ran that and no, I couldn’t repro it either.
After running your “post” model and my intercept model though, there does appear to be some differences in the model summaries, before you even look at the bridge sampler…
my model:
summary(InterceptModel)
Model Info:
function: stan_glm
family: binomial [logit]
formula: Accept_Reject ~ 1
algorithm: sampling
sample: 75000 (posterior sample size)
priors: see help('prior_summary')
observations: 610
predictors: 1
Estimates:
mean sd 10% 50% 90%
(Intercept) 0.0 0.0 0.0 0.0 0.0
Fit Diagnostics:
mean sd 10% 50% 90%
mean_PPD 0.0 0.0 0.0 0.0 0.0
The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).
MCMC diagnostics
mcse Rhat n_eff
(Intercept) NaN NaN NaN
mean_PPD NaN NaN NaN
log-posterior NaN NaN NaN
vs. your model…
summary(post)
Model Info:
function: stan_glm
family: binomial [logit]
formula: cbind(incidence, size - incidence) ~ 1
algorithm: sampling
sample: 4000 (posterior sample size)
priors: see help('prior_summary')
observations: 56
predictors: 1
Estimates:
mean sd 10% 50% 90%
(Intercept) -2.0 0.1 -2.2 -2.0 -1.9
Fit Diagnostics:
mean sd 10% 50% 90%
mean_PPD 1.8 0.2 1.5 1.8 2.1
The mean_ppd is the sample average posterior predictive distribution of the outcome variable (for details see help('summary.stanreg')).
MCMC diagnostics
mcse Rhat n_eff
(Intercept) 0.0 1.0 1537
mean_PPD 0.0 1.0 2285
log-posterior 0.0 1.0 975
Not sure what all those NaN’s mean in mine. Might they have something to do with it? Did mine not converge or something?
Before going deeper, did you run it with built in data, just as was posted.
I think the problem may be that you are running an intercept only model with no prior on the intercept (I made some random binomial data and did an intercept only model with prior=NULL and got the same strange output you have.