as.matrix.geostan_fit | R Documentation |
Extract samples from the joint posterior distribution of parameters.
## S3 method for class 'geostan_fit'
as.matrix(x, ...)
## S3 method for class 'geostan_fit'
as.data.frame(x, ...)
## S3 method for class 'geostan_fit'
as.array(x, ...)
x |
A fitted model object of class |
... |
Further arguments passed to |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.