This book is under construction.
Welcome to coding for economists, a guide for economists on what programming is, why it’s useful, and how to do it.
The book aims to give you the skills you need to code for economics, while also giving you bits and pieces of information about programming more generally that might be useful to you. It’s suitable for complete beginners who have never written any code before. Some of the later chapters are suitable for people who have coded before too.
Naturally, at times, we have made choices regarding what to include, what to omit, and what to recommend. We have given recommendations based on what will serve you best in the long-run. Very occasionally, like the Karate Kid painting Mr Miyagi’s fence, you will wonder why such and such a thing is useful for coding in an economics context. But, also like the Karate Kid, you will find that you weren’t just learning to paint a fence, you were becoming a karate (coding) master.
What is coding?#
Computer programming, or coding, is the process of issuing a series of commands that a computer can understand and execute in order to perform a task. Today, almost all research with some quantitative aspect involves coding.
Imagine a computer as being like a particularly mischievous genie; if your instructions aren’t completely unambiguous, the computer won’t do what you asked for. So we write out our code, our list of instructions for the computer, very explicitly to make sure we can check we wrote what we meant, and that the computer will do it in the way we anticipate. Like a genie though, if you can get the instructions just so, you can create magical things.
Why should economists learn to code?#
Given so much of economics is quantitative, coding is an essential skill for many economists. Many of the tools and packages that have been developed will help you to do better work more productively. It’s Pareto improving.
As a skill, programming is enormously valuable beyond economics too because it’s used across a wide range of domains (this is especially true for general purpose programming languages). Code is widely used across industry, academia, and the public sector in everything from computer games to websites, data science to software applications. And learning basic programming concepts in any language is useful for almost any other programming language. So learning to code is good for your human capital.
Coding is like a superpower; it’s both fun and powerful!
You can read this book in any order depending on your experience and need. If you want to start getting to grips with using code, the first four sections are designed to help you get started quickly while also giving you a solid foundation.
The rest of the book is split into sections that present topics but differentiate between the level at which they address them; for example, there’s “Essential Coding” and “Coding”. The idea of these demarcations is to help guide you as to what is accessible and essential versus what is useful but ultimately not strictly necessary. It also points to a possible order for you to arrange your learning by. Of course, the needs of people reading this book will be very heterogeneous, so you should absolutely dip into whatever chapter is most useful to you; likewise use whatever order makes sense to you. Do also note that just because a chapter doesn’t appear in an “essential” section, doesn’t it mean it’s not useful! Although not in an “essential” section, having made use of the concept of a reproducible analytical pipeline (in Reproducible Analysis) in anger in research, we cannot now imagine any other way of working with code in economics.