Let fit
be stanfit
object. Then I can extract estimates of parameter AAA
by the following manner:
Expected A Posterior
EAP <- as.data.frame(summary(fit)[[1]])["AAA","mean"]
95% Credible Interval
lower.CI <- as.data.frame(summary(fit)[[1]])["AAA","2.5%"]
upper.CI <- as.data.frame(summary(fit)[[1]])["AAA","97.5%"]
But I am not sure, this is a canonical method ? If there is some more simpler code, then let me know.
Memorandum of Understanding
EAP
EAP <- get_posterior_mean(fit,par=c("AAA"))
For a mean, the get_posterior_mean
function is perhaps a bit more canonical. For quantiles, I would just do something like quantile(extract(fit, pars = "AAA")[[1]], probs = c(0.1, 0.9))
. However, the endpoints of 95% credible intervals are not estimated very precisely with the default settings for Stan.