Bayesian Applied Regression Modeling via Stan

Estimates previously compiled regression models using the 'rstan' package, which provides the R interface to the Stan C++ library for Bayesian estimation. Users specify models via the customary R syntax with a formula and data.frame plus some additional arguments for priors.


Wed December 20 2017 (2.17.2)

  1. Bug fixes
  • stan_polr() and stan_lm() handle the K = 1 case better
  1. Important user-facing changes
  • The prior_aux arguments now defaults to exponential rather than Cauchy
  • The Stan programs do not drop any constants and should now be safe to use with the bridgesampling package
  • hs() and hs_plus() priors have new defaults based on a new paper by Aki Vehtari and Juho Piironen
  • stan_gamm4() is now more closely based on mgcv::jagam(), which may affect some estimates but the options remain largely the same
  • The product_normal() prior permits df = 1, which is a product of ... one normal variate
  • The build system is more conventional now. It should require less RAM to build from source but it is slower unless you utilize parallel make and LTO
  1. New features
  • stan_jm() and stan_mvmer() contributed by Sam Brilleman
  • bayes_R2() method to calculate a quantity similar to R^2
  • stan_nlmer(), which is similar to lme4::nlmer but watch out for multimodal posterior distributions
  • stan_clogit(), which is similar to survival::clogit but accepts lme4-style group-specific terms
  • The mgcv::betar family is supported, allowing for beta regressions with lme4-style group terms and / or smooth nonlinear functions of predictors

Sat April 29 2017 (2.15.3)

  1. Bug fixes
  • Fix to stan_glmer() Bernoulli models with multiple group-specific intercept terms that would result in draws from the wrong posterior distribution
  • Fix bug with contrasts in stan_aov (thanks to Henrik Singmann)
  • Fix bug with na.action in stan_glmer (thanks to Henrik Singmann)

Wed April 19 2017 (2.15.1)

  1. Bug fixes
  • Only changes are to allow tests to pass on CRAN

Wed April 12 2017 (2.14.2)

  1. Bug fixes
  • Fix for intercept with identity or square root link functions for the auxiliary parameter of a beta regression
  • Fix for special case where only the intercepts vary by group and a non-default prior is specified for their standard deviation
  • Fix for off-by-one error in some lme4-style models with multiple grouping terms
  1. New features
  • Support for loo_linpred, loo_pit, loo_predict, and loo_predictive_interval from the loo package
  • Support for many more plotfuns in pp_check that are implemented in the bayesplot package
  • Option to compute latent residuals in stan_polr (Thanks to Nate Sanders)
  • The pairs plot now uses the ggplot2 package

Mon January 16 2017 (2.14.1)

  1. Bug fixes
  • VarCorr() could return duplicates in cases where a stan_{g}lmer model used grouping factors with spaces
  • The pairs() function now works with group-specific parameters
  • The stan_gamm4() function works better now
  • Fix a problem with factor levels after estimating a model via stan_lm
  1. New features
  • New model-fitting function(s) stan_betareg{.fit} that uses the same likelihoods as those supported by the betareg function in the betareg package
  • New choices for priors on coefficients: laplace, lasso, product_normal
  • The hs and hs_plus priors now have new global_df and global_scale arguments
  • stan_{g}lmer models that only have group-specific intercept shifts are considerably faster now
  • Models with Student t priors and low degrees of freedom (that are not 1, 2, or 4) may work better now due to Cornish-Fisher transformations
  • Many functions for priors have gained an autoscale argument that defaults to true and indicates that rstanarm should make internal changes to the prior based on the scales of the variables
  • The new compare_models function does more extensive checking that the models being compared are compatible
  1. Deprecated arguments
  • The prior_ops argument to various model fitting functions is deprecated and replaced by a the prior_aux argument for the prior on the auxiliary parameter of various GLM-like models

Sun November 20 2016 (2.13.1)

  1. Bug fixes
  • Fix bug in reloo() if data was not specified
  • Fix bug in pp_validate() that was only introduced on GitHub
  1. New features
  • Uses the new bayesplot and rstantools R packages
  • The new prior_summary() function can be used to figure out what priors were actually used
  • stan_gamm4() is better implemented, can be followed by plot_nonlinear(), posterior_predict (with newdata), etc.
  • Hyperparameters (i.e. covariance matrices in general) for lme4 style models are now returned by as.matrix()
  • pp_validate() can now be used if optimization or variational Bayesian inference was used to estimate the original model

Fri September 9 2016 (2.12.1)

  1. Bug fixes
  • Fix for bad bug in posterior_predict() when factor labels have spaces in lme4-style models
  • Fix when weights are used in Poisson models
  1. New features
  • posterior_linpred() gains an XZ argument to output the design matrix

Fri July 29 2016 (2.11.1)

  1. Bug fixes
  • Requiring manually specifying offsets when model has an offset and newdata is not NULL
  1. New features
  • stan_biglm function that somewhat supports biglm::biglm
  • as.array method for stanreg objects

Fri June 24 2016 (2.10.1)

  1. Bug fixes
  • Works with devtools now
  1. New features
  • k_threshold argument to loo() and kfold() for enhanced model comparison
  • Ability to use sparse X matrices (slowly) for many models

Tue May 24 2016 (2.9.0-4)

  1. Serious bug fixes
  • posterior_predict with newdata was wrong for ordinal models
  • stan_lm() was wrong if there was no intercept
  • would permit models with duplicative group-specific terms but these are usually a mistake on the user's part
  1. Bug fixes
  • posterior_predict with lme4-style models would fail if there were spaces or colons in the levels of the grouping variables
  • posterior_predict with ordinal models would output an integer matrix instead of a character matrix
  1. New features
  • pp_validate() function based on the BayesValidate package by Sam Cook
  • posterior_vs_prior() function to visualize the effect of conditioning on the data
  • Works (again) with R versions back to 3.0.2 (untested though)

Sat Feb 13 2016 (2.9.0-3)

  1. Serious bug fixes
  • Fix problem with models that had group-specific coefficients, which were mislabled. Although the parameters were estimated correctly, users of previous versions of rstanarm should run such models again to obtain correct summaries and posterior predictions. Thanks to someone named Luke for pointing this problem out on stan-users.
  1. Bug fixes
  • Vignettes now view correctly on the CRAN webiste thanks to Yihui Xie
  • Fix problem with models without intercepts thanks to Paul-Christian Buerkner
  • Fix problem with specifying binomial 'size' for posterior_predict using newdata
  • Fix problem with lme4-style formulas that use the same grouping factor multiple times
  • Fix conclusion in rstanarm vignette thanks to someone named Michael
  1. Features
  • Group-specific design matrices are kept sparse throughout to reduce memory consumption
  • The log_lik() function now has a newdata argument
  • New vignette on hierarchical partial pooling

Sat Jan 09 2016 (2.9.0-1) Initial CRAN release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.17.4 by Ben Goodrich, 2 months ago,,

Report a bug at

Browse source code at

Authors: Jonah Gabry [aut], Imad Ali [ctb], Sam Brilleman [ctb], Jacqueline Buros Novik [ctb] (R/stan_jm.R), AstraZeneca [ctb] (R/stan_jm.R), Trustees of Columbia University [cph], Simon Wood [cph] (R/stan_gamm4.R), R Core Deveopment Team [cph] (R/stan_aov.R), Douglas Bates [cph] (R/pp_data.R), Martin Maechler [cph] (R/pp_data.R), Ben Bolker [cph] (R/pp_data.R), Steve Walker [cph] (R/pp_data.R), Brian Ripley [cph] (R/stan_aov.R, R/stan_polr.R), William Venables [cph] (R/stan_polr.R), Paul-Christian Burkner [cph] (R/misc.R), Ben Goodrich [cre, aut]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports bayesplot, ggplot2, lme4, loo, Matrix, nlme, rstan, rstantools, shinystan, stats, survival, utils

Depends on Rcpp, methods

Suggests betareg, data.table, digest, gridExtra, HSAUR3, knitr, MASS, mgcv, rmarkdown, roxygen2, testthat

Linking to StanHeaders, rstan, BH, Rcpp, RcppEigen

System requirements: GNU make, pandoc (>= 1.12.3), pandoc-citeproc

Imported by glmmfields, projpred, psycho, tidyposterior.

Depended on by evidence.

Suggested by RBesT, bayesplot, bridgesampling, broom, jtools, loo, lsmeans, merTools, rstantools, shinystan, sjPlot, sjstats.

Enhanced by emmeans.

See at CRAN