| rstan-package {rstan} | R Documentation |
RStan is the R interface to the Stan C++ package. RStan provides
full Bayesian inference using the No-U-Turn sampler (NUTS), a variant of Hamiltonian Monte Carlo (HMC)
approximate Bayesian inference using automatic differentiation variational inference (ADVI)
penalized maximum likelihood estimation using L-BFGS optimization
For more information about Stan visit http://mc-stan.org/.
| Package: | rstan |
| Version: | 2.10.0 |
| Date: | June 20, 2016 |
| License: | GPL-3 |
For more information on Stan and its modeling language, see the Stan Modeling Language User's Guide and Reference Manual available at http://mc-stan.org/.
| Authors: | Jiqiang Guo <guojq28@gmail.com> |
| Ben Goodrich <benjamin.goodrich@columbia.edu> | |
| Jonah Gabry >jsg2201@columbia.edu> | |
| Maintainer: | Ben Goodrich <benjamin.goodrich@columbia.edu> |
Stan Development Team Stan Modeling Language User's Guide and Reference Manual. http://mc-stan.org/.
The stan function for details on fitting models and
stanfit for information on the fitted model objects.
Several related R packages are also available from the Stan Development Team: loo (loo-package) offers model comparison on estimated out-of-sample predictive performance, shinystan (shinystan-package) provides the ShinyStan GUI for exploring fitted Bayesian models, and rstanarm is an appendage to rstan providing an R formula interface for Bayesian regression modeling.
## Not run:
stanmodelcode <- "
data {
int<lower=0> N;
real y[N];
}
parameters {
real mu;
}
model {
target += normal_lpdf(mu | 0, 10);
target += normal_lpdf(y | mu, 1);
}
"
y <- rnorm(20)
dat <- list(N = 20, y = y);
fit <- stan(model_code = stanmodelcode, model_name = "example",
data = dat, iter = 2012, chains = 3, sample_file = 'norm.csv',
verbose = TRUE)
print(fit)
traceplot(fit)
# extract samples
e <- extract(fit, permuted = TRUE) # return a list of arrays
mu <- e$mu
m <- extract(fit, permuted = FALSE, inc_warmup = FALSE) # return an array
print(dimnames(m))
# using as.array directly on stanfit objects
m2 <- as.array(fit)
## End(Not run)