“Regressions and Causal Inference”
Welcome to the site for the course PS9591: “Regressions and Causal Inference” at Western University, taught by Sebastián Vallejo Vera. Each week, you will find the lecture slides, lecture code, tutorial exercises, and tutorial code for the corresponding topic.
The class is divided into lectures and tutorials. We will go through the lectures and tutorials simultaneously. Thus, I have arranged the website in a way that shows the suggested order in which each lecture or tutorial should be carried out.
Before you start, don’t forget to read the Syllabus and check Perusall for the course readings. This site will be corrected and updated throughout the semester.
0.1 Assignments
This is a list of assignments for the course. All assignments must be handed in as PDF documents using R Markdown.
| Chapter | Exercises | Due Date |
|---|---|---|
| Chapter 2 | a) Problems 1, 4, and 6 b) Computer exercises: C2, C4, and C7 |
Feb. 18 |
| Chapter 3 | a) Problems 1, 3, 5, and 7 b) Computer exercises: C2, C6, and C9 |
Feb. 25 |
| Chapter 4 | a) Problems 1, 2, 5, and 9 b) Computer exercises: C1, C5, and C6 |
March 17 |
| Chapter 6 | a) Problems 3 and 7 b) Computer exercises: C2 |
March 24 |
| Chapter 7 | a) Problems 1, 2 and 3 b) Computer exercises: C2 and C3 |
March 31 |
Additionally, throughout the semester, and after every other lecture, I will post an exercise aimed at challenging you and helping you apply a key concept from class. You must submit solutions to three exercises by March 27.
0.2 Final Exam
The final exam will require students to replicate the findings from selected papers and interpret the results. For the final exam, I will post the required datasets for the analyses and replication exercises here: https://github.com/svallejovera/regression_ci/tree/main/Sample_data.
0.3 About Tutorials
The tutorials are interactive R documents that you can also run on your very own computer. This allows you to practice concepts and experiment with different approaches at your own pace. Here’s how to get started.
0.3.1 Prerequisites
Before running the tutorials, make sure you have:
- R installed on your computer (version 4.0.0 or higher)
- RStudio installed (any recent version)
- The following R packages installed. You can install them by running these commands in R:
# Install required packages
install.packages("learnr")
install.packages("wooldridge")
install.packages("tidyverse")
install.packages("tidylog")
install.packages(sjPlot) # to plot some models
install.packages(readstata13) # to load .dta files0.3.2 Running a Tutorial
There are two ways to run a tutorial locally:
0.3.3 Tips for Success
When working with tutorials locally:
- Make sure all required packages are loaded in the tutorial’s setup chunk
- If you modify the tutorial code, save the file before running
- To clear the tutorial cache and start fresh, just click on the “Start Over” button on the bottom left corner.
0.3.4 Troubleshooting Common Issues
If you encounter problems:
- Tutorial won’t knit: Check that all required packages are installed
- Exercise chunks don’t run: Verify that learnr is properly loaded
- Previous answers persist: Clear the cache using the code provided above
-
Package not found: Run
install.packages()for the missing package
0.3.5 Getting Help
If you need assistance:
- Check the tutorial error messages for specific package requirements
- Review the setup chunk for any missing dependencies
- Consult the learnr documentation
- Ask questions during office hours or send me an e-mail
- Ask ChatGPT (?)
0.3.6 Next Steps
After getting the tutorials running locally, you can:
- Experiment with modifying the code
- Create your own practice exercises
- Try different approaches to the analysis tasks
- Save your work for future reference
Remember that these tutorials are learning tools. Feel free to experiment and try different approaches – that’s how we learn best!
0.4 Acknowledgments
The organization of this course is based on the great textbook ‘The Effect: An Introduction to Research Design and Causality’ by Nick Huntington-Klein, freely available at here. The code used throughout for the main lectures is a patchwork of my own code, but my own code borrows heavily from the internet (but that’s true for all code). I try my best to give credit to the original authors of the code (when and if possible). The code for the labs was created and revised by two amazing doctoral students1 at Western University, Hugo Machado and John Santos (and are posted here with their permission).