This work was originally created by Malika Ihle based on materials from Joel Pick, Hadley Wickham, Kevin Hallgren, and with contributions from James Smith.
It is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
-
Fork and clone this repository (here is a reminder on how to fork and clone and what it means)
-
Read Hallgren A. K. 2013. Conducting simulation studies in the R programming environment. Tutor Quant Methods Psychol. ; 9(2): 43–60. and answer the following 3 questions in your local copy of the reading sheet:
- describe 6 steps common to all simulations
- describe 3 types of simulations use
- describe 4 limitations of simulations
The workshop will alternate presentation of concepts and simple exercices for you to try to apply them in R. Each time you see written YOUR TURN, switch to your local copy of the exercice script, review the examples if needed, complete the exercice, and check out the proposed answer (which often contain additional tips).
It is necessary that you work through the sections in order. Please read the blurbs of each sections below to get an overview of what is coming before starting.
- Definition - what are simulations?
- Purpose - what can we use simulations for?
- Basic Principles - what do we need to create a simulation?
- Random Number Generators - how to generate random numbers in R?
- Repeat - how to repeat the generation of random numbers multiple times?
- Setting the seed - how can you generate the same random numbers?
- Sample size
n
- how many values should you generate within a simulation? - Sample size
nrep
- how many repeats of simulations should you run? - Dry rule - how to write your own functions?
- Simulate - write your first simulation!
- General structure - what is the general structure of a simulation?
- Limitations - what are the limitations to simulations?
- Real-life example - what are real life examples of simulations?
- Additional resources - what resource can help you write your own simulation?
In your local repository, write your own simulation in R to help you prepare the data analyses of your current or next study. When you require help, first push your current work on your GitHub remote (for a reminder on how to do this, see here) for us to be able to access it easily and possibly review and edit your code!