Extract samples from the joint posterior distribution of parameters.
# S3 method for geostan_fit
as.matrix(x, ...)
# S3 method for geostan_fit
as.data.frame(x, ...)
# S3 method for geostan_fit
as.array(x, ...)
A fitted model object of class geostan_fit
.
Further arguments passed to rstan
methods for for as.data.frame
, as.matrix
, or as.array
A matrix, data frame, or array of MCMC samples is returned.
data(georgia)
A <- shape2mat(georgia, "B")
fit <- stan_glm(deaths.male ~ offset(log(pop.at.risk.male)),
C = A,
data = georgia,
family = poisson(),
chains = 1, iter = 600) # for speed only
s <- as.matrix(fit)
dim(s)
a <- as.matrix(fit, pars = "intercept")
dim(a)
# Or extract the stanfit object
S <- fit$stanfit
print(S, pars = "intercept")
samples <- as.matrix(S)
dim(samples)