1 Introduction
This is a book to learn Econometrics by programming. The core idea is that the methods developed in Econometrics are best understood by writing code to implement them. This book is written in the style of literate programming, which means that the code and the text are interwoven. This is a powerful way to learn, because it allows you to see the code and the explanation of the code side by side. See Knuth (1984) for additional discussion of literate programming.
1.1 Why Julia?
The language of this book is Julia. Julia is a high-level, high-performance programming language for technical computing. It is designed to be easy to learn and use, and it is designed to be fast. Julia is a great language for learning Econometrics, because it is easy to write and read, and it is fast enough to handle the large datasets that are common in Econometrics.
In contrast to languages like R and Python, Julia handle of matrices and vectors is more natural, which makes it easier to write code that closely resembles the mathematical notation used in Econometrics. Moreover, Julia use of Unicode characters makes it easy to write mathematical notation in code that closely resembles the notation used in the theory. This makes it easier to connect the theory to the code.
The following, while looking almost copied verbatim from an Econometrics theoretical derivation, is a valid line of code in Julia.
= (X'X)^(-1)*(X'Y) β
Julia interprets the transpose operator '
as the mathematical transpose, and the Greek letter β
can be typed directly using Unicode. This means you can write code that looks almost identical to the mathematical formulas found in textbooks.
1.2 Data
Sources of data for the exercises in the book are included in the Ecdat package.
1.3 Quarto
The book is written using Quarto, an open-source scientific and technical publishing system. Quarto allows us to write code and text side by side, and it allows you to run the code and see the output in the book. This makes it easy to learn by doing.