Main content

Home

Menu

Loading wiki pages...

View
Wiki Version:
### **Hello everyone!** This is the Open Science Framework repository for our stats workshop at the "Workshop: Methodological Advances in Prosody Research". Feel free to watch this 7 minute welcome video that also gives some explanation of the workshop: [https://appliedstatisticsforlinguists.org/korea_welcome_video.mp4](https://appliedstatisticsforlinguists.org/korea_welcome_video.mp4) In this workshop, we will learn how to build, interpret, and visualize Bayesian models using the `brms` package. The workshop will be part introduction to Bayesian modeling and part introduction to the linear mixed effects model framework. There will be a strong hands-on component which also teaches you how to use the `tidyverse` effectively for data wrangling. <br><br> ### **Learning goals:** - write clean code with reproducibility in mind - learn about the `tidyverse` - make gorgeous plots with `ggplot2` - fit Bayesian mixed models with `brms` - reason about appropriate random effects structures - understand the basics of the generalized linear model framework - interpret the output of a Bayesian analysis - implement weakly informative priors - report the results of a Bayesian analysis in written and graphical format - evaluate your models, especially via posterior predictive checks We'll have time to fit a whole range of pretty cool models. First we'll fit some simple linear regression models, with continuous and categorical predictors, with interactions, and later with some generalized linear models (logistic regression, Poisson regression, negative binomial regression). We finish by fitting some rather complex mixed models. <br><br> ### **Preparing for the hands-on sessions** The hands-on sessions are an integral part of this course. You need to have four things ready by the start of the course. 1. R 2. RStudio 3. R packages (see below) 4. The materials folder Each will be explained below. If you are an experienced R User, it may still be good to re-install R, RStudio, and the specified R packages to make sure that we're all working with the most up-to-date version. That said, if you have a working `brms` installation, perhaps keep it as is so as to not mess up things just before the course. As will be discussed below, installing `brms` can be a bit tricky sometimes! <br><br> ### **Materials folder** The materials folder is not ready yet. It will be ready at least a day prior to the workshop. <br><br> ### **R installation** If you haven't installed R yet, you can do so [here](https://cran.rstudio.com/). For this workshop, it is recommended to have some knowledge of base R, but just in case you don't, you'll still be able to benefit from the workshop. If you're new to R, the following videos on [how to install R on a Mac](https://www.youtube.com/watch?v=Icawuhf0Yqo&feature=youtu.be) and [how to install R on PC](https://www.youtube.com/watch?v=mfGFv-iB724&feature=youtu.be) may be useful to you. <br><br> ### **RStudio installation** To install the free version of RStudio, go [here](https://rstudio.com/products/rstudio/download/). <br><br> ### **R knowledge required** Minimal knowledge of base R is helpful to participate in this workshop. If you are new to R or want a refresher, you can use the `swirl` package for learning R interactively within R. Install the `swirl` package ... install.packages('swirl') ... and then load the package and start swirl. library(swirl) swirl() The base R introduction sections 1-8 would be useful to complete. Don't do any of the modules after that (it will be useless because we'll do those tasks with the tidyverse anyway). The one skill that I will definitely require during the workshop is to load in datasets from outside R. So, make sure you know how to set your working directory and how to load in files. If you need a refresher, please [watch this video](https://appliedstatisticsforlinguists.org/data_loading.mp4) — perhaps best after completing the first few swirl modules. <br><br> ### **R packages installation** Open up RStudio and copy and paste the following lines of code into the console to install the corresponding packages. install.packages('tidyverse') install.packages('rstan') install.packages('brms') install.packages('shinystan') install.packages('tidybayes') install.packages('modelr') **Windows users** have to download and install RTools (outside of R) prior to installing **rstan** and **brms**: [https://cran.r-project.org/bin/windows/Rtools/](https://cran.r-project.org/bin/windows/Rtools/) The `tidyverse` package is essential for the data wrangling sections of the class. Check whether installation worked by copying and pasting this into the console: library(tidyverse) It should look something [like this screenshot](http://appliedstatisticsforlinguists.org/tidyverse_ok.png) (details like the package version numbers may vary, that's OK). The `brms` package is essential for the Bayesian parts of the workshop. It will be required for the majority of the hands-on sessions. library(brms) brm(y ~ 1, data = data.frame(y = rnorm(50))) The latter command should take quite a while, depending on how good your machine is. If it works, you'll see [this](https://appliedstatisticsforlinguists.org/compilation_sampling.png) first. Then [this](https://appliedstatisticsforlinguists.org/model.png). (The values of the model may be slightly different — that's OK) See below what to do if it *doesn't* work. <br><br> ### **Boooo, it doesn't work!** First of all, **don't panic.** Installing `brms` can be quite tricky and quite discouraging, especially to newcomers — rest assured that everybody occasionally has problems with it, as the whole thing depends on your operation system, R versions, C support on your computer, yada yada yada. This stuff is tricky, and if it doesn't work out, that's ok. First, let me assure you: If all else fails, I will have prepared for you 1) markdowns that include input and output, as well as 2) compiled models. So, in case you *don't* get `brms` to work before the workshop, you'll still be able to participate. That said, the workshop will be much more fun if you can fit your own models, and eventually you'd want to do this anyways. So, if you want this to work (recommended, at least for experienced users) I expect you to do a bit of tinkering prior to the workshop. The first thing to do is: Google the error message. You will likely be directed to the Stan forums. Try out several of the solutions suggested there. You may have to delete `rstan` and `brms` using the `remove.packages()` function, then delete RStudio and R. Then make sure that as a Windows user, you install RTools after installing R and before installing `rstan` and `brms`. I recently had an error message that I could only fix by deinstalling rstan/brms/R/RStudio, reinstalling everything and installing the `brms` version that's not on CRAN with this command: remotes::install_github('paul-buerkner/brms') Alternatively, check this set of [installation instructions](https://learnb4ss.github.io/learnB4SS/articles/install-brms.html) from another workshop. *Once you have tried tinkering with this*, I am willing to try to help you out via email. But please make sure to try finding a solution yourself first. And if nothing works, we can try to fix things during the workshop, although I cannot guarantee to have time during that. Either way, remember that you'll be able to participate regardless, so not all is lost if the installation fails. ### **Suggestion by Philipp** Check your R version by typing in `R.Version()` in R. [https://blog.mc-stan.org/2022/04/26/stan-r-4-2-on-windows/](https://blog.mc-stan.org/2022/04/26/stan-r-4-2-on-windows/) <br><br> ### **Readings & Further study** Other than following the above instructions, there is no need to prepare with readings etc. At the end of the workshop, I will give you reading recommendations and ideas for further study. The slides will be made available *after* the workshop.
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

Start managing your projects on the OSF today.

Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.