brms bayesian multilevel models using stan
play

brms: Bayesian Multilevel Models using Stan Paul Brkner 2018-04-09 - PowerPoint PPT Presentation

brms: Bayesian Multilevel Models using Stan Paul Brkner 2018-04-09 1 Why using Multilevel Models? 2 Example: Effects of Sleep Deprivation on Reaction Times data ("sleepstudy", package = "lme4") head (sleepstudy, 10)


  1. brms: Bayesian Multilevel Models using Stan Paul Bürkner 2018-04-09 1

  2. Why using Multilevel Models? 2

  3. Example: Effects of Sleep Deprivation on Reaction Times data ("sleepstudy", package = "lme4") head (sleepstudy, 10) Reaction Days Subject 249.5600 0 308 258.7047 1 308 250.8006 2 308 321.4398 3 308 356.8519 4 308 414.6901 5 308 382.2038 6 308 290.1486 7 308 430.5853 8 308 466.3535 9 308 3

  4. Linear Regression vs. Multilevel Regression 350 350 Reaction Reaction 300 300 250 250 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 Days Days 4

  5. Regression Lines for Specific Subjects 5

  6. Why going Bayesian? 6

  7. The Posterior Distribution b_Days sd_Subject__Days 4 8 12 16 5 10 15 7

  8. Why using Stan? 8

  9. Multilevel Models in Classical Statistics with lme4 fit <- lmer (Reaction ~ 1 + Days + (1 + Days | Subject), data = sleepstudy) 9

  10. Multilevel Models in Bayesian Statistics with brms fit <- brm (Reaction ~ 1 + Days + (1 + Days | Subject), data = sleepstudy) 10

  11. Post-Processing methods (class = "brmsfit") ## [1] add_ic add_loo add_waic as.array ## [5] as.data.frame as.matrix as.mcmc coef ## [9] control_params expose_functions family fitted ## [13] fixef formula hypothesis kfold ## [17] launch_shiny log_lik log_posterior logLik ## [21] loo LOO loo_linpred loo_predict ## [25] loo_predictive_interval marginal_effects marginal_smooths model.frame ## [29] neff_ratio ngrps nobs nsamples ## [33] nuts_params pairs parnames plot ## [37] posterior_predict posterior_samples pp_check pp_mixture ## [41] predict predictive_error print prior_samples ## [45] prior_summary ranef reloo residuals ## [49] rhat stancode standata stanplot ## [53] summary update VarCorr vcov ## [57] waic WAIC ## see '?methods' for accessing help and source code 11

  12. The idea of brms : Fitting all kinds of regression models within one framework 12

  13. Example: Censored Recurrance Times of Kidney Infections fitk <- brm (time | cens (censored) ~ age * sex + (1 | patient), data = kidney, family = weibull ()) marginal_effects (fitk, "age:sex") time | cens(censored) 600 sex 400 male female 200 0 20 40 60 13 age

  14. Example: Complex Non-Linear Relationships 1 0 y −1 −2 −2 −1 0 1 2 X Latent mean function Realized data 14

  15. Modeling Non-Linear Relationships with Gaussian Processes fitgp <- brm (y ~ gp (x), bdata) marginal_effects (fitgp, nsamples = 100, spaghetti = TRUE) 2 0 y −2 −4 −2 −1 0 1 2 x 15

  16. Modeling Non-Linear Relationships with Splines fits <- brm (y ~ s (x), bdata) marginal_effects (fits, nsamples = 100, spaghetti = TRUE) 2 0 y −2 −4 −2 −1 0 1 2 x 16

  17. Example: Number of Fish Caught at a Camping Place 100 count 50 0 0 5 10 15 20 25 nfish 17

  18. Modeling Zero-Inflation form <- bf (nfish ~ persons + child + camper, zi ~ child) fit_zinb <- brm (form, zinb, zero_inflated_poisson ()) marginal_effects (fit_zinb, effects = "child") 4 3 nfish 2 1 0 0 1 2 3 child 18

  19. Learn More about brms and Stan • Help within R: help("brms") • Overview of vignettes: vignette(package = "brms") • List of all methods: methods(class = "brmsfit") • Website of brms: https://github.com/paul-buerkner/brms • Website of Stan: http://mc-stan.org/ • Contact me: paul.buerkner@gmail.com • Twitter: @paulbuerkner 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend