Resources

Software, packages, and references

1 R and RStudio

All work in this course uses R and RStudio Desktop.

Software Download
R (≥ 4.3.0) cran.r-project.org
RStudio Desktop posit.co/download/rstudio-desktop
Quarto (for assignments) quarto.org

2 Required Packages

Install all required packages in one go:

pkgs <- c(
  # Data manipulation & visualisation
  "tidyverse",    # dplyr, ggplot2, tidyr, purrr, readr, stringr
  "patchwork",    # combine ggplot panels
  "GGally",       # ggpairs and correlation plots

  # Econometric modelling
  "broom",        # tidy model output (tidy, glance, augment)
  "modelsummary", # publication-quality regression tables
  "car",          # linearHypothesis, vif, Anova
  "lmtest",       # bptest, dwtest, bgtest, coeftest
  "sandwich",     # vcovHC, vcovHAC (robust variance-covariance)
  "estimatr",     # lm_robust (one-step robust estimation)

  # Datasets
  "wooldridge",   # Wooldridge textbook datasets
  "gapminder",    # Gapminder global development data
  "AER",          # Applied Econometrics with R datasets

  # Time series
  "tseries",      # adf.test, kpss.test
  "dynlm",        # dynamic linear models with lm() syntax
  "zoo",          # irregular time series
  "tsibble",      # tidy time series structures
  "feasts",       # time series features and ACF/PACF plots
  "fabletools"    # tidy forecasting framework
)

install.packages(pkgs)

3 Package Reference

3.1 Core Workflow

Package Key Functions Use
dplyr filter, select, mutate, summarise, group_by Data wrangling
ggplot2 ggplot, aes, geom_*, labs, theme_* Visualisation
broom tidy(), glance(), augment() Tidy model output
modelsummary modelsummary(), datasummary() Regression tables

3.2 Inference and Diagnostics

Package Key Functions Use
car linearHypothesis(), vif() Joint tests, multicollinearity
lmtest coeftest(), bptest(), dwtest(), bgtest() Coefficient tests, diagnostics
sandwich vcovHC(), vcovHAC(), NeweyWest() Robust variance estimators
estimatr lm_robust() Robust regression in one call

3.3 Datasets

Package Key Datasets Topic
wooldridge wage1, hprice1, vote1, phillips, hseinv Core examples
gapminder gapminder International development
AER CPS1985, Fertility Labour economics
datasets cars, longley Base R examples

3.4 Time Series

Package Key Functions Use
dynlm dynlm() Dynamic regression with lag operators
tseries adf.test(), kpss.test() Unit root tests
zoo zoo(), rollmean() Time series objects
feasts ACF(), PACF(), autoplot() Tidy ACF/PACF

4 Starter Script

Copy this block at the top of every R session or Quarto document:

library(tidyverse)
library(broom)
library(modelsummary)
library(lmtest)
library(sandwich)
library(estimatr)
library(car)
library(wooldridge)

# Consistent ggplot theme
theme_set(theme_minimal(base_size = 13))
options(digits = 4, scipen = 999)

5 Cheat Sheets


6 Textbooks

Book Authors Notes
Introductory Econometrics (6th ed.) Wooldridge Primary text. Datasets in the wooldridge R package.
Introduction to Econometrics (4th ed.) Stock & Watson Alternative reference. Emphasises inference.
Principles of Econometrics (4th ed.) Hill, Griffiths & Lim Applied focus with R/EViews coverage.
Using R for Introductory Econometrics (2nd ed.) Heiss Free online at urfie.net. R code for Wooldridge examples.

7 Getting Help

  • R documentation: Type ?function_name in the console, e.g. ?lm
  • Package vignettes: vignette("modelsummary") or browseVignettes("broom")
  • Stack Overflow: tag your question [r]
  • Posit Community: community.rstudio.com