All exercises & code
Twenty worked R walkthroughs and seven downloadable projects
Each application exercise is a rendered R walkthrough: read it in the browser to see the code and its output together. Each one also ships inside a project bundle β an RStudio project with the data already in place, so you can open it and run the same code yourself.
- Read the rendered walkthrough in the browser to see where you are heading.
- Download the matching bundle and open the
.Rprojfile in RStudio. - Work through the
.Rmdyourself β the blanks (______) are for you to fill. - Compare against the solutions where they are provided.
2 Β· Data wrangling
| Exercise | What you practise | Bundle |
|---|---|---|
| π AE03-01 Import, clean, summarise, plot | Reading messy Excel and CSV files, cleaning names, first summaries and plots | π¦ ae03 |
3 Β· Describing data
| Exercise | What you practise | Bundle |
|---|---|---|
| π AE03-02 Plastic waste | Exploring distributions of plastic waste per capita | π¦ ae03 |
| π AE03-02 Plastic waste β solutions | Worked solutions to the exercise above | π¦ ae03 |
| π AE03-03 Correlation | Computing and interpreting correlations | π¦ ae03 |
| π AE03-04 Categorical data (homework) | Visualising categorical variables | π¦ ae03-hw |
4 Β· Simple regression
| Exercise | What you practise | Bundle |
|---|---|---|
π ae04-00-simple-regression-from-slides-HW.R |
Reproducing the whole simple-regression analysis from the slides in a plain R script | π¦ ae04 |
This one is a plain .R script rather than an R Markdown document, so there is no rendered page β open it from the bundle.
5 Β· Multiple regression
| Exercise | What you practise | Bundle |
|---|---|---|
| π AE04-01 Multiple linear regression | Fitting and reading a model with several predictors | π¦ ae04 |
| π AE04-02 Linearity | Residual plots, transformations, marginal effects | π¦ ae04 |
| π AE04-03 Hedonic land prices (homework) | A hedonic price model end to end | π¦ ae04 |
| π AE04-04 OVB from the slides (homework) | Reproducing the omitted-variable-bias examples | π¦ ae04 |
| π AE05-01 OVB and the wage equation | Omitted variable bias in a classic wage regression | π¦ ae05 |
| π AE05-02 OVB from the slides (homework) | More omitted-variable-bias practice | π¦ ae05 |
| π AE05-03 Hedonic prices & heteroscedasticity | A complete regression analysis including robust inference | π¦ ae05 |
| π AE06-01 Transformations & interactions toolbox | The full toolbox for transformed and interacted regressors | π¦ ae06 |
| π AE06-02 Interactions with continuous variables | Interpreting continuous-by-continuous interactions | π¦ ae06 |
| π AE06-03 Simpsonβs paradox | Unobserved heterogeneity reversing a relationship | π¦ ae06 |
6 Β· Panel regression
| Exercise | What you practise | Bundle |
|---|---|---|
| π AE08-01 Production function | Estimating a production function on panel data | π¦ ae08 |
| π AE11-01 Translog production function | A translog specification on Ghanaian firm data | π¦ ae11 |
7 Β· Instrumental variables
| Exercise | What you practise | Bundle |
|---|---|---|
| π AE12 Instrumental variable | Two-stage least squares on Angrist & Kruegerβs quarter-of-birth data | π¦ ae12 |
π ae12-iv-solutions.Rmd |
Worked solutions β in the bundle only, no rendered page | π¦ ae12 |
π ae12-iv-solutions-2.Rmd |
Further worked solutions β in the bundle only | π¦ ae12 |
Project bundles
Each bundle is an RStudio project: unzip it, open the .Rproj file, and every path in the exercises will resolve. Open a bundle page to see exactly which files and datasets are inside before you download.
ae03-data-wrangling
Four exercises on importing, cleaning, exploring and correlating data, with five datasets.
ae04-multiple-regression-part-1
Five exercises: simple regression recap, multiple regression, linearity, hedonic prices and OVB.
ae05-multiple-regression-part-2
Three exercises on omitted variable bias and heteroscedasticity.
ae06-multiple-regression-part-3
Three exercises on transformations, interaction terms and Simpson's paradox.