How to learn coding for economists

As an empirical economist you will have to implement statistical techniques. There are many different programmes that can support you in this. Some of these (like STATA) are very specialised to economics. Two very popular programming languages that are used in this field are R and Python.

Learning any programming language can only be done by doing. Here we are not exposing you to a bottom-up introduction of R, but we are immediately exposing you to the exciting possibilities of R and the beauty and excitement of working with real-life data. As we do so we expose you to the basic tools of working with data in R and help you to learn these.

However, you have to accept from the outset that this is going to be a bumby raod! The most crucial skill you will have to embrace and develop is that of finding solutions to problems. You will, as any programmer, yes, even the most experienced ones, search the internet for solutions to your problem. Don’t think that you can remember all the important commands from the top of your mind.

Whenever we introduce a new R functionality we will briefly explain it, but importantly we will also give you links to further resources where you can find more usage examples and details. Also do not forget to use the build-in help function in R (type ?FUNCTIONNAME into the Console and press Enter). This is important as it is the help that will be available offline as well.

Basic techniques

In the following a few basic data techniques are introduced. Where you need to download csv files you will be guided to a github page from where you can download the respective csv file.

Topic Workthrough Data used
Installing R and RStudio Video none
First Steps Workthrough in R, Video STATS19_GM_AccData.csv
Using Packages/Libraries Workthrough in R none
Loading Data Workthrough in R mroz.csv, mroz.xlsx
Basic Data Analysis Workthrough in R mroz.csv
Basic Data Analysis (Tidyverse) Workthrough in R mlb1.csv
Basic Data Visualisation (ggplot) Workthrough in R mlb1.csv
Loops Workthrough in R in code upload
Law of Large Numbers and Central Limit Theorem Workthrough in R in code simulated data

Large Data / Data Science techniques

Topic Workthrough Data used
Regression Model Selection Workthrough in R in code upload
Ridge and LASSO Regression Workthrough in R PSIDsmall.txt
Post Double Selection LASSO Workthrough in R in code upload
Cross-Validation Workthrough in R in code upload

Dealing with Time-Series variables

Topic Workthrough Data used
Basic TS modeling Workthrough in R EUROSTATtimeseries.csv
GARCH modeling Workthrough in R in code data download

Examples

On the Examples section of this page we collate empirical examples which can be used to help students understand a range of statistical and econometric techniques. This page benefits from a range of empirical examples which have been implemented in a range of books.

The examples from these books and others have been amended or re-written such that students can either use them directly or to facilitate adoption by lecturers.

You can find further resources here.