Practical Applications in R for Psychologists
Last updated 2023-09-03.
This Github repo contains all lesson files for Practical Applications
in R for Psychologists. The goal is to impart students with the basic
tools to process data, describe data (w/ summary statistics and plots),
and the foundations of building, evaluating and comparing statistical
models in R
, focusing on linear regression modeling (using both
frequentist and Bayesian approaches).
These topics were taught in the graduate-level course Advanced
Research Methods for Psychologists (Psych Dep., Ben-Gurion University
of the Negev), laying the foundation for the following topic-focused
courses:
Notes:
- This repo contains only materials relating to Practical Applications
in R. Though statistics are naturally discussed in many lessons, the
focus is generally on the application and not on the theory.
- Please note that some code does not work on purpose and without
warning, to force students to learn to debug.
Setup
You will need:
- A fresh installation of
R
(preferably version 4.1.1 or above).
- RStudio IDE
(optional, but recommended).
- The following packages, listed by lesson:
Lesson |
Packages |
01 intro |
|
02 data wrangling |
haven , tidyverse , readxl , dplyr , datawizard , summarytools , parameters , psych , finalfit , Hmisc , mice |
03 plotting |
dplyr , ggplot2 , ragg , tidyr |
04 hypothesis testing and power |
effectsize , correlation , BayesFactor , dplyr , pwr , ggplot2 |
05 regression 101 |
effectsize , parameters , performance , ggeffects , psychTools |
06 categorical predictors and model comparison |
dplyr , parameters , emmeans , ggeffects , bayestestR , performance |
07 moderation and curvilinear |
dplyr , datawizard , parameters , performance , bayestestR , emmeans , ggeffects , ggplot2 , modelbased |
08 generalized linear models |
dplyr , parameters , performance , ggeffects , emmeans , marginaleffects |
09 assumption checks and violations |
ggeffects , performance , see , bayesplot , qqplotr , datawizard , permuco , parameters , insight |
10 ANOVA |
afex , emmeans , effectsize , ggeffects , tidyr |
11 mediation |
mediation , tidySEM |
(Bold denotes the first lesson in which the package was
used.)
You can install all the packages used by running:
# in alphabetical order:
pkgs <- c(
"afex", "BayesFactor", "bayesplot", "bayestestR", "correlation",
"datawizard", "dplyr", "effectsize", "emmeans", "finalfit", "ggeffects",
"ggplot2", "haven", "Hmisc", "insight", "marginaleffects", "mediation",
"mice", "modelbased", "parameters", "performance", "permuco",
"psych", "psychTools", "pwr", "qqplotr", "ragg", "readxl", "see",
"summarytools", "tidyr", "tidySEM", "tidyverse"
)
install.packages(pkgs, repos = c("https://easystats.r-universe.dev", getOption("repos")))
Package Versions
Run on Windows 11 x64 (build 22621), with R version 4.3.1.
The packages used here:
- `afex` 1.3-0 (*CRAN*)
- `BayesFactor` 0.9.12-4.4 (*CRAN*)
- `bayesplot` 1.10.0 (*CRAN*)
- `bayestestR` 0.13.1.2 (*Local version*)
- `correlation` 0.8.4 (*CRAN*)
- `datawizard` 0.8.0.7 (*Local version*)
- `dplyr` 1.1.2 (*CRAN*)
- `effectsize` 0.8.5 (*Local version*)
- `emmeans` 1.8.7 (*CRAN*)
- `finalfit` 1.0.6 (*CRAN*)
- `ggeffects` 1.3.0.5 (*Github: strengejacke/ggeffects*)
- `ggplot2` 3.4.3 (*CRAN*)
- `haven` 2.5.3 (*CRAN*)
- `Hmisc` 5.1-0 (*CRAN*)
- `insight` 0.19.3.3 (*Github: easystats/insight*)
- `marginaleffects` 0.13.0 (*CRAN*)
- `mediation` 4.5.0 (*CRAN*)
- `mice` 3.16.0 (*CRAN*)
- `modelbased` 0.8.6 (*CRAN*)
- `parameters` 0.21.1 (*CRAN*)
- `performance` 0.10.4 (*CRAN*)
- `permuco` 1.1.2 (*CRAN*)
- `psych` 2.3.6 (*CRAN*)
- `psychTools` 2.3.6 (*CRAN*)
- `pwr` 1.3-0 (*CRAN*)
- `qqplotr` 0.0.6 (*CRAN*)
- `ragg` 1.2.5 (*CRAN*)
- `readxl` 1.4.3 (*CRAN*)
- `see` 0.8.0.2 (*Local version*)
- `summarytools` 1.0.1 (*CRAN*)
- `tidyr` 1.3.0 (*CRAN*)
- `tidySEM` 0.2.4 (*CRAN*)
- `tidyverse` 2.0.0 (*CRAN*)