• Easy Bayes
  • Introduction
    • Overview
      • Goals
      • Prerequisites
  • Part I: Getting Started
  • Basic Bayesian Analysis
  • Advantages
  • Stan and the Stan ecosystem
    • Stan
    • rstan
    • rstanarm
    • brms
    • More Stan
  • Part II: rstanarm
  • Getting Started with rstanarm
  • Basic GLM
    • Traditional GLM
    • rstanarm: GLM
      • Adding more options
    • rstanarm: Mixed Model
    • rstanarm: Other Models
  • Priors
    • Default priors
    • Getting priors
    • Setting priors
      • Example
  • Part III: brms
  • Installing brms
  • Comparison to rstanarm
  • Models
    • Methods for brmsfit objects
    • Models in brms
    • brms: Mixed Model
    • brms: Mixed Model Extensions
    • brms: Mo’ models!
  • Part IV: Model Criticism
  • Model Criticism in rstanarm and brms
  • Model Exploration
    • Linear models
    • Marginal effects
    • Hypothesis tests
    • Extracting results
      • Tidy methods for data extraction
      • tidybayes
  • Model Diagnostics
    • shinystan
    • Posterior Predictive Checks
    • Observation Level
  • Model Performance
    • Prediction
    • Model Comparison
    • Model Averaging
  • Part V: Conclusion
  • Summary
  • Exercise
  • References
  • MC logo

Easy Bayes with rstanarm and brms

brms: Mo’ models!

  • GAM
  • Distributional response (e.g. model the variance as well as the mean)
  • Gaussian Processes
  • ZIP
  • Multivariate
  • Missing data imputation from a Bayesian approach
  • Measurement error
# additional distributions
model = brm(y ~ x + z, family = skew_normal,
                                student,
                                shifted_lognormal,
                                weibull,
                                frechet,
                                gen_extreme_value,
                                exgaussian,
                                wiener,
                                Beta,
                                von_mises,
                                asym_laplace,
                                hurdle_poisson,_negbinomial,_gamma,_lognormal,
                                zero_inflated_poisson,_negbinomial,_beta,_binomial; zero_one_inflated_beta,
                                categorical,
                                ordinal: cumulative, sratio, cratio, acat)

# model the variance as well as the mean
fit1 <- brm(bf(y ~ x + z, sigma ~ x), 
            data = dat1, 
            family = gaussian)

# missing values
bform <- 
  bf(bmi | mi() ~ age * mi(chl)) +
  bf(chl | mi() ~ age) + set_rescor(FALSE)

fit <- brm(bform, data = nhanes)

# non-linear model with known form
nlform <- bf(cum ~ ult * (1 - exp(-(dev / theta)^omega)),
             ult ~ 1 + (1 | AY), 
             omega ~ 1, 
             theta ~ 1, 
             nl = TRUE)

# measurement error
fit1 <- brm(y ~ me(x1, sdx) + me(x2, sdx), 
            data = dat, 
            save_mevars = TRUE)