July 31, 2023

Goals for Today

  1. Understand what is computation and how it relates to Economics.
  2. Learn the basics of Julia.

What is computation in Economics?

Any time you do math on a computer, you are computing!

Some computation you might have already done before:

  • Create new variables in data set.
  • Analyze data with built in functions.

Other kinds of computation:

  • Optimize a function (find maximum or minimum).
  • Approximate an equation without closed form solution.
  • Solve dynamic systems of equations.

Why do we need computation in Econ?

  1. Enlarges the set of questions that we can tackle.
  2. Improves the quality of our answers.

If you don’t do any computation, you can use theory and proofs.

  • Even then, computation can guide and motivate your theory.

If you only know how to use Stata, you can work with data.

  • Working with data requires some (or a lot of) computation.
  • What if you want to build a structural model?
  • What if the function or package you need doesn’t exist?

In both cases, your research will be limited without strong computational skills.

What does this mean for you?

Computation will be an important part of your job:

  • In your own work.
  • Dealing with co-authors and colleagues.
  • Reading and evaluating the work of others.

So you should learn how to do computation well now!

If you are second year, your goal is to:

  1. Figure out what questions you are interested in.
  2. Acquire the tools you need to answer these questions.

This process probably will continue after the second year.

How do you do computation well?

Your code should be:

1. Fast

  • How long does it take to write your code?
  • When will my code finish running?

2. Readable

  • Can other people understand your code?
  • Can the future version of you understand your code?

3. Reproducible

  • Does your code give the correct answers?
  • How easy would it be to change or extend your code?

How do you do computation well?

These things are all related.

  1. If your code is not readable: it is harder to find mistakes, so it is not reproducible.

  2. If your code is not reproducible: it is difficult to make iterative progress, so it is not fast.

  3. If your code takes 10 years to finish running (not fast), then no need to read it or reproduce it (useless).

Luckily, there is good software available to make this easier.

  • Julia and Visual Studio Code for programming.
  • Git and Github for version control.

Why Julia?

Pros:

  • Faster run-time than basic Matlab, Python, R, Stata.
  • Easier to learn and work in than C++ and Fortran.
  • More readable than optimized Matlab or Python code.
  • Open source unlike Matlab.

Cons:

  • C++ and Fortran have faster run-times sometimes.
  • You might already know other languages.
  • Julia is relatively new, so less packages and legacy code.

My Advice

1. You should learn either Stata, R, or Python well.

  • For data cleaning and basic analyses.
  • Use large library of packages and legacy code.
  • Stick with what you already know best.

2. You should learn Julia well.

  • For high performance computing needs.
  • This camp and 899 class will help with this.

3. Learn and use other coding languages as needed.

  • Each new language is easier to learn than the last.