- Course: Computational Economics for PhDs
- Teacher: Florian Oswald, florian.oswald@sciencespo.fr
- Class Times: Bi-weekly Friday 14:45-16:45 starting 29 of January, ending 8 of April.
- Chatroom:
- Class Locations:
- 29/01/2016: Salle 31, 27 Rue Saint-Guillaume.
- 12/02/2016: Salle 26, 27 Rue Saint-Guillaume.
- 26/02/2016: Salle 34, 27 Rue Saint-Guillaume.
- 11/03/2016: Salle 105, 56 Rue des Saints-Pères.
- 25/03/2016: Salle 31, 27 Rue Saint-Guillaume.
- 08/04/2016: Salle 31, 27 Rue Saint-Guillaume.
This is a course for PhD students at the Department of Economics at Sciences Po in Computational Economics.
In this course you will learn about some commonly used methods in Computational Economics. These methods are being used in all fields of Economics. The course has a clear focus on applying what you learn. We will cover the theoretical concepts that underlie each topic, but you should expect a fair amount of hands on action required on your behalf. In the words of the great Che-Lin Su:
Doing Computation is the only way to learn Computation. Doing Computation is the only way to learn Computation. Doing Computation is the only way to learn Computation.
True to that motto, there will be a homework associated to each session. There will also be a term paper. It will be helpful to bring a laptop to the sessions if you have one.
Topics will be demonstrated through live-code examples/slides, available at ScPo-CompEcon.github.io/slides.
- No previous programming experience is required.
- You will have to write working computer code, however, so you will have to learn how to program. [This is good news.]
- We will be using Julia
- It would be helpful if you could come with julia installed on your computer. Download here.
- Additional to that, please follow instructions here to install 2 packages that we will use often, PyPlot and IJulia.
- A very good place to start with Julia is the quant-econ.net website
- There are more tutorials listed below in subsection Julia tutorials
- There are countless good programming tutorials on the web, particularly for Python. If you have no programming experiences whatsoever, it may be useful to go through one of those. Once you know a bit of Python,
Julia
will be very close. - Some experience with the Unix Shell and the verion control system Git would be very useful - for this course, and for the rest of your life as a scientist. I do therefore recommend that you spend some time (2h total max) with the following excellent tutorials:
- Software Carpentry: The Unix Shell
- If you are on MacOS/Unix, just open the terminal application and you're good to go.
- On Windows, you need to make up for the fact that you are not Unix. I recommend Gnu on Windows (GOW)
- What is Version Control? 5 minute video.
- Try Git on codeschool.org: This is a 15 minute intro to Git. So cool!
- Software Carpentry: The Unix Shell
Each session is accompagnied by a homework. They will be listed within the Course Outline.
The aim of the following setup is to put a system in place by which we can easily look at your solutions to a problem, you can easily look at my solutions (next to yours), and we can also look at the solutions of your peers in order to have a better learning experience. Writing code is a activity with tremendous returns from collaboration, and we will try and foster that in this course. Apart from this, a vast amount of high quality code is nowadays developed following this model, so it is a useful skill for you to know how the fork-change-pull-request model works.
If you don't know what Git is, please look at the prerequisites first.
If you're using GitHub Desktop, these instructions will help explain the Git/GitHub concepts. Here are the overall steps:
- Fork the repository for homework x (found under github.com/ScPo-CompEcon). You do that by clicking on fork on github.
- Clone the repository to your computer: use command
git clone https://github.com/your-username/homework-x.git
or do in your GUI. - Create a new branch on your computer called
my-solution
.- you can use the command
git checkout -b my-solution
- you can use the command
- Modify the files to complete your solution.
- Make sure your code runs and produces all output.
- Write a test for your code if possible.
- Commit all of your code to your local repository.
- Push your branch
my-solution
up to your fork of my repo at GitHub.- you do
git push origin my-solution
- you do
- Create a pull request for
my-solution
on the original repository, i.e. the owned by github.com/ScPo-CompEcon. - You can continue to push fixes and improvements until the close date (24 hours before the next class).
- I will push my solutions to Exercise repository once you have handed in yours. You can then sync your master branch with those solutions. This way, you have both your solutions (on branch
my-solution
) as well as my solution (on themaster
branch).
- I invite you to do the homeworks in teams of 2.
- You have two weeks for each homework, and they are due 24 hours before the next class, so that I have time to look at them and provide some feedback.
- Please make clear who the contributors are in your comment on the pull request.
- There is clearly a tradeoff between you learning by trying hard, learning from seeing the work of your colleagues, and not learning at all by just copy and pasting the best solution 1 minute before the deadline. I can only remind you that you harm noone but yourself by not exerting effort on the homeworks.
- Each solution you submit must contain text file called
outline.md
where you describe briefly in words what you are doing in your implementation. It is good practice to write this before you even start. (you can always go back and edit this document if you find out that what you wanted to do does not work, but at least you know always what you are trying to do.) - Notice the file extension
.md
stands formarkdown
, probably one of the more amazing inventions of the web. You can super easily generate formated text by just using very intuitive markup symbols. This document is written in markdown.
You are expected to produce a term paper over the course of the semester. This could be:
- A replication of a paper that uses computational methods.
- Computing additional things that another (maybe theoretical) paper does not compute.
- Ideally, it would be your own research project.
- Due Date: May 9th 2016.
- You must do this on your own.
- The paper should be max 15 pages of double-spaced 12pt font text, excluding any graphs or tables.
- The paper should contain
- A motivation/introduction and formulation of the research question.
- A justification for why one needs computational methods to answer this question.
- A model.
- A clear outline describing the computational approach to compute the model.
- A presentation of the results.
- A discussion of the accuracy of the obtained results.
- Furthermore, the code you write needs to be on github, if you want in a private rather than public repository, to which you grant me access. (you get access to 5 private repos for free). There will be extra marks for code readability and code quality.
My weapon of choice for this course is the Julia Computing Language. I see this as an occasion to persuade you to overcome any switching costs that may have put you off from learning Julia up until now and to give it a try. That said, for most programmers (of Python, Matlab or R) these switching costs are small. [If you are a Fortran/C++ programmer, the switching costs are negative, i.e. you will enjoy the switch.]
I appreciate that people have strong opinions on which software is best. We will briefly touch upon that question in the first session and think about the pros and cons of different languages.
I said there are no prerequisites; That does not mean you should not get a head start, if you so desired. An excellent tutorial for Julia is available at the quant-econ.net website, and I highly recommend you go and have some fun with it. Some more references are listed right here:
- quant-econ.net website
- See at the bottom of the Julia Manual Introduction
- See the Learning Section of the Julia homepage.
- You can use pure Julia together with a text editor.
- sublime text is a good choice, https://atom.io looks great (never tried), http://www.vim.org if you are hard-core.
- You can use an IDE (like matlab or RStudio). Juno is great.
There are some excellent references for computational methods out there. This course will use material from
- Fackler and Miranda (2002), Applied Computational Economics and Finance, MIT Press
- Kenneth Judd (1998), Numerical Methods in Economics, MIT Press
- Nocedal, Jorge, and Stephen J. Wright (2006): Numerical Optimization, Springer-Verlag
(recommended ones in bold face)
Each subsection here stands for one session of 2 hours. There are 6 subsections.
- First things first
- Put name on sticky note on back of monitor
- Discuss what the class is going to cover
- Everyone introduce themselves
- Name
- What you "do"
- What are your goals for the class?
- What's something related to computation in Economics you worry that your peers understand but you don't?
- Setup
- How many people are comfortable with Git/GitHub?
- Install GitHub Desktop
- If you are comfortable with Git already, you can skip this.
- Sign up for GitHub
- GitHub workflow
- Walk through workflow
- Create pull request on students repository
- Explain how slides work
- Talk through homework requirements
- Talk through term paper requirements
- Talk through weapon of choice
- Basic Computing concepts
- The fundamental tradeoff: Speed vs Accuracy
- Some numerical gotchas
- Computer Basics
- Intro to
Julia
- Aruoba and Fernandez-Villaverde (2014) A Comparison of Programming Languages in Economics
- make sure you signed up on github (and put a picture there!)
- Join the chat room. You can ask any question you want there - will see them even if offline.
- [10 min read] Do this short online tutorial on an example github workflow
- [4 min read] Do this short online tutorial on forking on github
- download GitHub Desktop. [Someone said they are running MacOS < 10.9, and the latest release was 16 years ago. I can't believe that is the case, but please contact me if you cannot install this program.]
- Please go through the initial tutorial. It is helpful.
- do the fork-and-pull-request exercise on the students repository
- Please note: I added a comment (about a comment) to my
JSON
example file. Make sure your file has exactly that format, and is exactly saved in that location. (you have to look at my repo, not your fork)
- Numerical Integration and Derivation
- Monte-Carlo integration
- Gaussian Quadrature
- Multidimensional Quadrature
- Quadrature with correlated shocks
- Numerical Differentiation
- Finite Differences
- Automatic Differentiation
- JuliaOpt/JuMP.jl
- Function Approximation
- Polynomial Interpolation
- Basis functions and Coefficients
- Regression as Approximation
- Colocation Methods
- Multidimensional Approximation
- The Smolyak Grid
- Polynomial Interpolation
- Fork the homework at github.com/ScPo-CompEcon/HW-integration
- Follow steps detailed there.
- Create a new repository on github for your term paper.
- Choose a name, whether public of private and select the option to create a README.md file. clone.
- In the README.md file detail your project idea in a few words (more than 100 but less than 500). If you need math, include an IJulia notebook.
- If you decide to make this a private repository, you need to add me as a collaborator.
- push to github.
- email me the URL of the repo by the homework deadline (24h prior to next class.)
- Unconstrained Optimisation
- Comparison Methods
- Newton's Method
- Line Search, Trust Region, and other Methods
- Application: Maximum Likelihood
- Introduce http://www.juliaopt.org
- Constrained Optimization
- Theory
- Some Numerical Methods for Constrained Optimization
- MPEC on John Rust's Bus Engine Replacement
- The Berry-Levinsohn-Pakes (BLP) paper as constrainted optimization problems
- Review of DP theory
- Different Solution methods for different cases
- Discretization
- Parametric approximation methods basically Function Approximation
- The Endogenous Grid Method
- Finite time vs inifinite horizon models
- Brief intro to parallel computing concepts
- Parallel computing with julia
- (Free) Cloud computing via the Github Student Developer Pack
- Three people is possible, but two works best
- Agree on an editor and environment that you're both comfortable with
- The person who's less experienced/comfortable should have more keyboard time
- Switch who's "driving" regularly
- Make sure to save the code and send it to both people
- Git and GitHub
- GitHub Pages
50% homeworks, 50% paper
We will try to honour Science Po's anti-plagiarism policy:
Plagiarism occurs when a student submits work that does not allow one to distinguish the student's own thoughts from those of other authors: it can be characterised by the absence of citation of a group of consecutive words (five or more), by reformulation or translation, or by copying directly." (article on intellectual honesty)
Reuse and building upon ideas or code are major parts of modern software development. As an economist writing code, you will (hopefully) never write anything from scratch. This class is structured such that all solutions are public. You are encouraged to learn from the work of your peers. As I said above, I won't hunt down people who are simply copying-and-pasting solutions, because without challenging themselves, they are simply wasting their time and money taking this class.
Please respect the terms of use and/or license of any code you find, and if you reimplement or duplicate an algorithm or code from elsewhere, credit the original source with an inline comment.
In setting up this course I was heavily influenced - and shamelessly copied entire parts of - https://github.com/advanced-js taught by Aidan Feldman and team at NYU, and I would like to thankfully acknowledge making the materials useable to other teachers. The same license applies (below). The license allows you to copy and use everything here, under the condition that you attribute the work (details in the license). The copyright notice to be included in any such copies and other derivative work is:
Copyright 2015 Florian Oswald, Sciences Po Paris, florian.oswald@gmail.com
Thank you.
This work and all other materials under https://github.com/ScPo-CompEcon are licensed under a Creative Commons Attribution 4.0 International License.