Skip to content

Pipeline for Linear Mixed Effects Models in R

reubenthomas edited this page Nov 10, 2025 · 15 revisions

Description

This workshop will describe and demo a pipeline in R to implement all aspects of dealing with data from repeated measures experimental designs - from specifying the design and model assumptions, to testing these assumptions, identifying outlier observations and outlier groups of repeated measures, sample-size or power calculations to help design follow-up experiments and finally deriving and visualizing estimates of interest. This workshop is a followup to the Introduction to Linear Mixed Effects Models workshop.

We will go over an R package, RMeDPower2 that our core developed. This is the website describing the tool. The package can be installed using the instructions provided on the the README page of the github repo linked to above. RMeDPower2 is a package that provides complete functionality to analyze data coming from repeated measures experiments, i.e., where one has repeated measures from the same biological/independent units or samples. RMeDPower2 helps test the modeling assumptions one makes, identify outlier observations, outlier units at different levels of the design, estimates statistical power or performs sample size calculations, estimate parameters of interest and also to visualize the association being tested. The functionality is limited to testing associations of one predictor (continuous or categorical, e.g., disease status or brain pathology) along with one another covariate (e.g., gender status) with possible interaction between the two variable in the context of hierarchical or crossed experimental designs. Please feel free to use this package in your own work and give us feedback, ask questions etc.

Pre-workshop Instructions

Before the workshop, please ensure that R and RStudio are installed, and all required packages are set up. Completing these steps will ensure a smooth experience during the hands-on sessions.

  1. Install R and RStudio
    (latest stable versions recommended).

  2. Install the following packages in RStudio:

    devtools::install_github('gladstone-institutes/RMeDPower2')
    # Verify installations
    library(RMeDPower2)
    packageVersion("RMeDPower2")
    
  3. Download and open the shiny app materials

    • Download here
    • Unzip the folder and open README.html in a web browser.
    • Follow the instructions in the Installing Required Packages section in this html file to install the necessary packages to be able to run the shiny app
  4. Download all the workshop materials here

    • Download here
    • Unzip the folder
    • This folder contains the slides we will start the workshop with, a data folder with the data sets we will analyze, a Rmarkdown (Rmd) file with code we will use to analyze these data sets, a html knitted version of this markdown with code output and plots and the same shiny app folder mentioned above

Troubleshooting Installation

If you encounter GitHub authentication issues:

# Set up Git configuration
install.packages("usethis")
usethis::use_git_config(user.name = "YourName", user.email = "[email protected]")

# Generate GitHub token (opens browser)
usethis::create_github_token()

# Set the token (paste when prompted)
credentials::set_github_pat()

# Try installation again
devtools::install_github("gladstone-institutes/RMeDPower2")

For permission or dependency issues:

# Install with dependencies
devtools::install_github("gladstone-institutes/RMeDPower2", dependencies = TRUE)

Clone this wiki locally