3.8. Running simulations and power analysis in R
Explore experiments before running them: learn simulations in R.
About these materials
Welcome! This workshop is intended to introduce the principles and practical use of simulations in research using R. Learners will first get familiar with what simulations are and why they are widely used in scientific research, including how they help researchers explore statistical behavior, test assumptions, and design studies before collecting real data. The workshop will also introduce power analysis, explaining how simulations can be used to estimate the probability of detecting true effects and determine appropriate sample sizes for experiments. Through this guided, hands-on tutorial, participants will work through the full simulation workflow in R, including generating random data, repeating simulations, and analyzing results.
Who are these materials for?
The target audience of this workshop is twofold:
Self-learners with basic R and statistical skills, who are interested in developing their skills on the topic. You can follow the materials by chronologically going through the slides and following along the practical exercises. You go at your own pace and within your own timeframe. Presenter notes will help you to understand and reflect on the content of the materials. Note: Group exercises are not possible in this asynchronous setting.
Instructors in higher education (e.g., universities, colleges) aiming to convey the content of these materials to their learners in a synchronous (in-person, virtual or hybrid) class-room setting. The slides can be directly presented in full screen below, with presenter and instructor notes providing detailed information about the content of the materials and valuable pedagogical tips how to convey the materials to your learners. You can also download the PowerPoint corresponding to the materials below and adapt the materials to your learners. Make sure to give appropriate credit to the original authors.
Prerequisites
| Prerequisite | Description | Link/Where to find it |
|---|---|---|
| R and RStudio installed | Latest R version: ‘4.4.0+’ and RStudio version: ‘2026.01.0+392’ | Installation Link |
| R basics | e.g., how to select a value in a data frame, how to create a vector | Tutorial Link |
| Familiarity with basic statistical concepts | e.g., hypothesis testing, descriptive statistics, data analysis | Cheatsheet Link |
Learning objectives
- Understand the concept of simulations
- Explain the purpose of simulations in research
- Summarize how simulations support hypothesis testing and experimentation
- Perform the simulation process in the context of a fictional experiment
- Understand the concept of power analysis
- Explain the purpose of power analysis in research
- Summarize how power analysis supports hypothesis testing and experimentation
- Successfully perform a simulation in R
Materials
Click here to see the materials in full Screen
Download files
Practical exercises - solutions
Download the solutions for the practical exercises here:
Helpfiles
Download the csv file for the example data:
Export slides
You can export these slides as PowerPoint by pressing the button below. Note that basic formatting will be applied. MAKE powerpoint template to use for export.
Contributors and licence details
Creator: Sharma, Tejaswini (
0009-0000-0305-9751)
Reviewer: Von Grebmer zu Wolfsthurn, Sarah (
0000-0002-6413-3895)
Consultant: Ihle, Malika (
0000-0002-3242-5981)
This work was originally created by Malika Ihle based on materials from Joel Pick, Hadley Wickham, and Kevin Hallgren, with contributions from James Smith. This current work by Tejaswini Sharma, Sarah von Grebmer zu Wolfsthurn and Malika Ihle is licensed under a CC-BY-SA 4.0 Creative Commons Attribution 4.0 International SA License. It permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited. If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.