R for econometrics
Learn econometrics by actually doing it in R
A free, hands-on companion to your econometrics course. Every topic comes with runnable R code, real data and plots you can reproduce line by line. The focus is less on the math behind the methods and more on getting them to work.
New here? Three steps to your first regression
-
1
Set up R and RStudio
Install both, learn what the four panes are for and how to keep a workspace tidy.
Install R -
2
Get data into shape
Import data sets, reshape them with dplyr and plot what you find with ggplot2.
Wrangle data -
3
Run your first regression
Estimate an OLS model, read the summary output and test whether it holds up.
Estimate OLS
Topics
R(eal) Basics
Installation, the structure of the program, importing data, dplyr and ggplot2 — everything you need before the econometrics starts.
7 articles CoreEconometric Methods
OLS, hypothesis testing and heteroskedasticity-robust standard errors, worked through with examples from Wooldridge's textbook.
4 articles AdvancedTime Series Topics
Stationarity and unit roots, VAR and VEC models, and a long series on Bayesian estimation of macroeconomic time series models.
12 articles R packagebvartools
Guides to the author's own R package for the Bayesian estimation of vector autoregressive models, from a simple BVAR upwards.
Guides AppliedNetwork Analysis
Turn relational data into graphs with igraph, compute the usual summary statistics and visualise the result with ggraph.
3 articles PapersReproduction Projects
Published papers and textbook chapters re-estimated in R, from Cincera (1997) to the Bayesian Econometric Methods exercises.
25 articlesIntroduction to R — the short version
An under-30-page introduction that walks through one realistic workflow and the packages dplyr, ggplot2 and openxlsx. Free PDF, no sign-up.
From the blog All posts →
-
Decomposing Inflation for EA Countries
Decomposing inflation into four main components for euro area countries using data from Eurostat.
-
An Introduction to Network Analysis in R
An introduction to network analysis in R using the igraph package for the calculation of metrics and ggraph for visualisation.
-
An Exercise in Growth Accounting
The discipline of growth accounting tries to assess the relative contribution of labour, capital and technology to the economic growth of a country. This post …
About this site
r-econometrics is written and maintained by Franz X. Mohr. It grew out of the notes taken while learning to use the free statistical software R for econometric work, and it is meant to give you an intuition for the structure of the program and for the statistical functions needed to pass an introductory or intermediate course in econometrics.
It is not a replacement for a good textbook. The math behind the methods is kept short on purpose, so that you can get to a working example quickly and then look up the theory wherever your course expects you to. Everything here is free to read, and the code on every page can be copied straight into your own R session.