rstan: RStan - R interface to Stan

Description Other R packages from the Stan Development Team Author(s) See Also Examples

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 <[email protected]>
Ben Goodrich <[email protected]>
Jonah Gabry <[email protected]>
Maintainer: Ben Goodrich <[email protected]>

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## 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)

rstan documentation built on Jan. 20, 2018, 7:10 p.m.