rstan-package {rstan}R Documentation

RStan — R interface to Stan

Description

mc-stan.org Stan Development Team

RStan is the R interface to the Stan C++ package. RStan provides

For documentation on the Stan modeling language see the Stan Modeling Language User's Guide and Reference Manual.

Other R packages from the Stan Development Team

Various related R packages are also available from the Stan Development Team:

Package Description Link
bayesplot ggplot-based plotting library for graphing parameter estimates, MCMC diagnostics, and posterior predictive checks. bayesplot-package
shinystan Interactive visual summaries and advanced posterior analysis of MCMC output. shinystan-package
loo Out-of-sample predictive performance estimates and model comparison. loo-package
rstanarm R formula interface for Bayesian applied regression modeling. rstanarm-package
rstantools Tools for developers of R packages interfacing with Stan. rstantools-package

Author(s)

Authors: Jiqiang Guo <guojq28@gmail.com>
Ben Goodrich <benjamin.goodrich@columbia.edu>
Jonah Gabry <jsg2201@columbia.edu>
Maintainer: Ben Goodrich <benjamin.goodrich@columbia.edu>

See Also

Examples

## 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)

[Package rstan version 2.15.1 Index]