├── CompEcon-Syllabus.pdf ├── Makefile ├── README.md ├── ScPo.png ├── challenge-sol.md ├── challenge.md └── homeworks.md /CompEcon-Syllabus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScPo-CompEcon/Syllabus/d54d24ae6cebfa6a642b9d2f811d9bfe8ab20d23/CompEcon-Syllabus.pdf -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | pdf: 2 | pandoc README.md --pdf-engine=pdflatex --bibliography=../references/references.bib -o CompEcon-Syllabus.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | **Caution**: this document is out of date. please consult the up to date version at [https://floswald.github.io/NumericalMethods/](https://floswald.github.io/NumericalMethods/) 3 | 4 | 5 | # ScPo-CompEcon Syllabus ![](ScPo.png) 6 | 7 | 8 | 9 | **Caution**: this document is out of date. please consult the up to date version at [https://floswald.github.io/NumericalMethods/](https://floswald.github.io/NumericalMethods/) 10 | 11 | 12 | * **Course:** Computational Economics for PhDs 13 | * **Teacher:** Florian Oswald, [florian.oswald@sciencespo.fr](mailto:florian.oswald@sciencespo.fr) 14 | * **Class Times:** Fridays 10:15-12:15 starting 29 Jan 2021 15 | * **Class Location:** Zoom 16 | * **Slack**: There will be a slack channel for all communication 17 | 18 | **Caution**: this document is out of date. please consult the up to date version at [https://floswald.github.io/NumericalMethods/](https://floswald.github.io/NumericalMethods/) 19 | 20 | ## Course Description 21 | 22 | This is a course for PhD students at the [Department of Economics at Sciences Po](http://econ.sciences-po.fr) in Computational Economics. 23 | 24 | ## Course Overview 25 | 26 | 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](https://bfi.uchicago.edu/people/che-lin-su): 27 | 28 | > 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. 29 | 30 | True to that motto, there will be homeworks for you to try out what you learned in class. There will also be a term paper. It will be helpful to bring a laptop to the sessions if you have one. 31 | 32 | Topics will be demonstrated through live-code examples/slides, available at [https://scpo-compecon.github.io/CoursePack/](https://scpo-compecon.github.io/CoursePack/). 33 | 34 | 35 | ## Prerequisites 36 | 37 | 1. You need a laptop. 38 | 1. You should be familiar with the material from *Introduction to Programming* taught by Clement Mazet in M1. Check out the materials [here](https://cms27.github.io/teaching/) 39 | 1. You must sign up for a free account at github.com. Choose a reasonable user name and upload a profile picture. 40 | 1. **Before** you come the first class, please do this: 41 | 1. Download the latest [stable `julia` release](https://julialang.org/downloads/) for your OS. 42 | 1. Download the [`VSCode Editor`](https://code.visualstudio.com) 43 | 44 | ### Getting Programming Skills 45 | 46 | 1. Check out [Clement Mazet's materials](https://cms27.github.io/teaching/). You must know this level. 47 | 1. We will be using [Julia](http://julialang.org/) for this course. 48 | - [Noteworthy Differences from Other Languages](https://docs.julialang.org/en/stable/manual/noteworthy-differences/) 49 | - [MATLAB, Python, Julia Syntax Comparison](http://cheatsheets.quantecon.org/) 50 | 1. Clement in his course will introduce you to things like the [Unix Shell](https://en.wikipedia.org/wiki/Unix_shell) and the verion control system Git. Both of those are very useful - for this course, and for the rest of your life as a scientist. 51 | 1. [What is Version Control? watch this 5 minute video.](http://git-scm.com/video/what-is-version-control) and go back to Clement's stuff if unclear. 52 | 53 | 54 | ## Homeworks 55 | 56 | There will be homeworks. They will be listed within the [Course Outline](#course-outline). 57 | 58 | 59 | ## Term Project 60 | 61 | This year your term project will be to replicate a paper published in an economics journal. Ideally this would be related to your field of interest. The requirements for choice of paper to replicate are: 62 | 63 | 1. Published version and replication kit is available online. 64 | 2. The paper to replicate must not use julia. 65 | 3. You must use julia for your replication. 66 | * Ideally your choice will involve at least some level of computational interest (i.e. more than an IV regression) 67 | * However, you can replicate a paper with an IV regression, but you have to go all the way to get the exact same results as in the paper. I.e. if the author typed the stata command `ivreg2 lw s expr tenure rns smsa _I* (iq=med kww age), cluster(year)` you will have to write (or find) julia code which will match all output from this, including standard errors. I do not recommend to do this. 68 | 4. You need to set up a public github repository where you will build a documentation website of your implementation. You'll learn how to do this in the course. 69 | 5. I encourage you to let the world know about your replication effort via social media and/or email to the authors directly. This is independent of whether you were able or not to replicate the results. Replication is not about finding errors in other peoples' work. If you are able to replicate some result in julia, this may be very interesting for others. 70 | 71 | ## Grade 72 | 73 | Your grade will be 60% homeworks, 40% term project. 74 | 75 | 76 | 77 | ## Textbooks 78 | 79 | There are some excellent references for computational methods out there. This course will use material from 80 | 81 | * **Fackler and Miranda** (2002), Applied Computational Economics and Finance, MIT Press 82 | * **Kenneth Judd** (1998), Numerical Methods in Economics, MIT Press 83 | * **Nocedal, Jorge, and Stephen J. Wright** (2006): Numerical Optimization, Springer-Verlag 84 | * [**Kochenderfer and Wheeler**](https://mitpress.mit.edu/books/algorithms-optimization) (2019), Algorithms for Optimization, MIT Press 85 | * [**A Gentle Introduction to Effective Computing in Quantitative Research**](https://mitpress.mit.edu/books/gentle-introduction-effective-computing-quantitative-research) - What Every Research Assistant Should Know, Harry J. Paarsch and Konstantin Golyaev 86 | 87 | 88 | ## Course Schedule 89 | 90 | ### 1. Programming languages and why `julia` 91 | 92 | 1. Talk through homework requirements 93 | 1. Talk through term project requirements 94 | 1. Show where material is and do first set of slides. 95 | 96 | #### Homework 97 | 98 | * Sign up to github.com. 99 | * Sign up for [introduction to github](https://lab.github.com/githubtraining/introduction-to-github) and send me a screenshot of all completed issues. 100 | * [Make a pull request.](https://github.com/ScPo-CompEcon/Students) 101 | 102 | #### Optional Julia Workouts 103 | 104 | * [https://exercism.io/](https://exercism.io/) offers some simple coding exercises. I highly recommend those if you want to get some extra practice - particularly in the beginning! 105 | 106 | ___ 107 | 108 | ### 2. `julia` setup and Getting Started 109 | 110 | * Setup environment 111 | * Tools and Editors 112 | * Examples 113 | * Types 114 | * Essentials 115 | * Speed 116 | * Data and Statistical Packages 117 | 118 | ___ 119 | 120 | 121 | ### 3. Integration and Function Approximation 122 | 123 | 1. Numerical Integration 124 | * Monte-Carlo integration 125 | * Gaussian Quadrature 126 | * Multidimensional Quadrature 127 | * Quadrature with correlated shocks 128 | 2. Function Approximation 129 | * Polynomial Interpolation 130 | * Basis functions and Coefficients 131 | * Regression as Approximation 132 | * Colocation Methods 133 | * Multidimensional Approximation 134 | * The Smolyak Grid 135 | 136 | ___ 137 | 138 | ### 4. Optimisation 1 139 | 140 | 1. Intro 141 | 2. Conditions for Optima 142 | 3. Derivatives and Gradients 143 | 4. Numerical Differentiation 144 | 5. JuliaOpt 145 | 146 | ___ 147 | 148 | ### 5. Optimisation 2 149 | 150 | 1. Bracketing 151 | 2. Local Descent 152 | 3. First/Second Order and Direct Methods 153 | 4. Constraints 154 | 155 | ___ 156 | 157 | 158 | ### 6. Numerical Dynamic Programming 159 | 160 | * Review of DP theory 161 | * Different Solution methods for different cases 162 | * Discretization 163 | * Parametric approximation methods [basically Function Approximation](#Function-Approximation) 164 | * The Endogenous Grid Method 165 | * Finite time vs inifinite horizon models 166 | + Solving the Growth Model in 7 Different ways 167 | 168 | ___ 169 | 170 | 171 | ### 7. Constrained Optimisation Applications as MPECs 172 | 173 | * What is an MPEC? 174 | * How can we cast constrained problems as MPECs? 175 | 176 | Applications: 177 | 178 | 1. MPEC on John Rust's Bus Engine Replacement 179 | 1. The Berry-Levinsohn-Pakes (BLP) paper as constrainted optimization problems 180 | 181 | ___ 182 | 183 | 184 | ### 8. HPC `julia` 185 | 186 | * Brief intro to parallel computing concepts 187 | * Parallel computing with julia 188 | * GPU computing with julia 189 | 190 | 191 | ____ 192 | 193 | ### 9. Rust Bus Model 194 | 195 | 196 | ____ 197 | 198 | ### 10. Intro to Machine Learning with julia 199 | 200 | 201 | ___ 202 | 203 | ### 11. The julia ML stack 204 | 205 | 206 | ___ 207 | 208 | ### 12. julia ML applications 209 | 210 | 211 | ___ 212 | 213 | 214 | 215 | ## Statements on Plagiarism 216 | 217 | We will try to honour [Science Po's anti-plagiarism policy](http://www.sciencespo.fr/welcome/en/content/plagiarism): 218 | 219 | >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) 220 | 221 | 222 | ### Related to Plagiarism 223 | 224 | 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. 225 | 226 | 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. 227 | 228 | ## License 229 | 230 | I took the setup for the structure of this course from [https://github.com/advanced-js](https://github.com/advanced-js) taught by [Aidan Feldman](https://github.com/afeld) and team at NYU, and I would like to thankfully acknowledge making the materials useable to other teachers. The same license applies (below). The coursepack material is based on [Chris Rackauckas' excellent Julia Intro](http://ucidatascienceinitiative.github.io/IntroToJulia/). 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: 231 | 232 | ``` 233 | Copyright 2020 Florian Oswald, Sciences Po Paris, florian.oswald@gmail.com 234 | ``` 235 | 236 | Thank you. 237 | 238 | Creative Commons License
This work and all other materials under https://github.com/ScPo-CompEcon are licensed under a Creative Commons Attribution 4.0 International License. 239 | -------------------------------------------------------------------------------- /ScPo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScPo-CompEcon/Syllabus/d54d24ae6cebfa6a642b9d2f811d9bfe8ab20d23/ScPo.png -------------------------------------------------------------------------------- /challenge-sol.md: -------------------------------------------------------------------------------- 1 | # Github Challenge 2 | 3 | ## Instructions 4 | 5 | You should spend 15 minutes on https://try.github.io/ and then answer the following quiz. You may also find [https://learngitbranching.js.org](https://learngitbranching.js.org) to be fun and helpful to play around with before taking the quiz. 6 | 7 | Your answer should be contained in a text file (not .doc) and look something like: 8 | 9 | ```bash 10 | true 11 | false 12 | false 13 | true 14 | ... 15 | ``` 16 | 17 | i.e. there should be one column, and either `true` or `false` for each question. Have fun! 18 | 19 | ## Questions 20 | 21 | 1. `git` is a version control system. `true` 22 | 1. You can create a git repository anywhere on your computer where you have write access. `true` 23 | 1. You create an empty git repo by writing `git initiate` in a terminal `false` 24 | 1. The new file **octocat.txt** being *untracked* means that git sees a new file in this repo. `true` 25 | 1. If you tell git to `git add octocat.txt`, the file will be saved to an online server. `false` 26 | 1. If you tell git to `git commit -m 'cool message'`, it will save all files that you staged for commit with `git add` to an online server with the message *cool message* attached. `false` 27 | 1. If you tell git to `git commit -m 'cool message'`, it will save all files that you staged for commit with `git add` to the repository on your computer with the message *cool message* attached. `true` 28 | 1. The command `git remote add origin url` associates to your repo an online server called `origin`, that can be reached at the url `url` `true` 29 | 1. If you type `git push -u origin master` you get the code from the online server called `origin` onto your computer. `false` 30 | 1. If you type `git push -u origin master` you send the changes `add`ed to the previous `commit`s to the online server called `origin`. `true` 31 | 1. saying `git pull origin master` fetches the repo from `origin` and merges it into your local repo. `true` 32 | 1. After `git pull`ing my collaborators' code from `origin`, `git diff HEAD` shows the difference between my last commit and the latest version on `origin` `true` 33 | 1. Octocat gets depressed when ocotodog becomes part of the octofamily. `true` 34 | 1. you can *unstage* a file, i.e. avoid it being included in your next commit by using the `git reset` command. `true` 35 | 1. In step 1.16 of https://try.github.io/, `git reset` deletes `octofamily/octodog.txt` from your `octofamily` directory. `false` 36 | 1. creating `branch`es allows you to work on *several verions of your code* before deciding which one to use eventually. `true` 37 | 1. You create a new branch called `newbranch` with the command `git create branch newbranch` `false` 38 | 1. You switch to a different branch with `git switch branch` `false` 39 | 1. Suppose you have file `octocat.txt` on the `master branch` and you go through the following sequence of commands: 40 | * `git branch newbranch` 41 | * `git checkout newbranch` 42 | * `git rm octocat.txt` 43 | * `git commit -m 'removed octocat.txt'` 44 | then the file `octocat.txt` has been removed from the `master` branch. `false` 45 | 1. Suppose you have file `octocat.txt` on the `master branch` and you go through the following sequence of commands: 46 | * `git branch newbranch` 47 | * `git checkout newbranch` 48 | * `git rm octocat.txt` 49 | * `git commit -m 'removed octocat.txt'` 50 | * `git checkout master` 51 | then the file `octocat.txt` has been removed from the `master` branch. `false` 52 | 1. Suppose you have file `octocat.txt` on the `master branch` and you go through the following sequence of commands: 53 | * `git branch newbranch` 54 | * `git checkout newbranch` 55 | * `git rm octocat.txt` 56 | * `git commit -m 'removed octocat.txt'` 57 | * `git checkout master` 58 | * `git merge newbranch` 59 | then the file `octocat.txt` has been removed from the `master` branch. `true` -------------------------------------------------------------------------------- /challenge.md: -------------------------------------------------------------------------------- 1 | # Github Challenge 2 | 3 | ## Instructions 4 | 5 | You should spend 15 minutes on https://try.github.io/ and then answer the following quiz. You may also find [https://learngitbranching.js.org](https://learngitbranching.js.org) to be fun and helpful to play around with before taking the quiz. 6 | 7 | Your answer should be contained in a text file (not .doc) and look something like: 8 | 9 | ```bash 10 | true 11 | false 12 | false 13 | true 14 | ... 15 | ``` 16 | 17 | i.e. there should be one column, and either true or false for each question. Have fun! 18 | 19 | ## Questions 20 | 21 | 1. `git` is a version control system. 22 | 1. You can create a git repository anywhere on your computer where you have write access. 23 | 1. You create an empty git repo by writing `git initiate` in a terminal 24 | 1. The new file **octocat.txt** being *untracked* means that git sees a new file in this repo. 25 | 1. If you tell git to `git add octocat.txt`, the file will be saved to an online server. 26 | 1. If you tell git to `git commit -m 'cool message'`, it will save all files that you staged for commit with `git add` to an online server with the message *cool message* attached. 27 | 1. If you tell git to `git commit -m 'cool message'`, it will save all files that you staged for commit with `git add` to the repository on your computer with the message *cool message* attached. 28 | 1. The command `git remote add origin url` associates to your repo an online server called `origin`, that can be reached at the url `url` 29 | 1. If you type `git push -u origin master` you get the code from the online server called `origin` onto your computer. 30 | 1. If you type `git push -u origin master` you send the changes `add`ed to the previous `commit`s to the online server called `origin`. 31 | 1. saying `git pull origin master` fetches the repo from `origin` and merges it into your local repo. 32 | 1. After `git pull`ing my collaborators' code from `origin`, `git diff HEAD` shows the difference between my last commit and the latest version on `origin` 33 | 1. Octocat gets depressed when ocotodog becomes part of the octofamily. 34 | 1. you can *unstage* a file, i.e. avoid it being included in your next commit by using the `git reset` command. 35 | 1. In step 1.17, `git reset` delets `octofamily/octodog.txt` from your `octofamily` directory. 36 | 1. creating `branch`es allows you to work on *several verions of your code* before deciding which one to use eventually. 37 | 1. You create a new branch called `newbranch` with the command `git create branch newbranch` 38 | 1. You switch to a different branch with `git switch branch` 39 | 1. Suppose you have file `octocat.txt` on the `master branch` and you go through the following sequence of commands: 40 | * `git branch newbranch` 41 | * `git checkout newbranch` 42 | * `git rm octocat.txt` 43 | * `git commit -m 'removed octocat.txt'` 44 | then the file `octocat.txt` has been removed from the `master` branch. 45 | 1. Suppose you have file `octocat.txt` on the `master branch` and you go through the following sequence of commands: 46 | * `git branch newbranch` 47 | * `git checkout newbranch` 48 | * `git rm octocat.txt` 49 | * `git commit -m 'removed octocat.txt'` 50 | * `git checkout master` 51 | then the file `octocat.txt` has been removed from the `master` branch. 52 | 1. Suppose you have file `octocat.txt` on the `master branch` and you go through the following sequence of commands: 53 | * `git branch newbranch` 54 | * `git checkout newbranch` 55 | * `git rm octocat.txt` 56 | * `git commit -m 'removed octocat.txt'` 57 | * `git checkout master` 58 | * `git merge newbranch` 59 | then the file `octocat.txt` has been removed from the `master` branch. -------------------------------------------------------------------------------- /homeworks.md: -------------------------------------------------------------------------------- 1 | ### Workflow of Homeworks 2 | 3 | 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. 4 | 5 | If you don't know what Git is, please look at the [prerequisites](#Prerequisites) first. 6 | 7 | Here are the overall steps: 8 | 9 | 1. Fork the repository for homework x (found under [github.com/ScPo-CompEcon](https://github.com/ScPo-CompEcon)). You do that by clicking on *fork* on github. 10 | 1. Clone the repository to your computer: use command `git clone https://github.com/your-username/homework-x.git` 11 | 1. Create a new branch on your computer called `my-solution`. 12 | * you can use the command `git checkout -b my-solution` 13 | 1. Modify the files to complete your solution. 14 | 1. Make sure your code runs and produces all output. 15 | 1. Write some tests for your code if possible. 16 | 1. Commit all of your code to your local repository. 17 | 1. Push your branch `my-solution` up to your fork of my repo at GitHub. 18 | * you do `git push origin my-solution` 19 | 1. [Create a pull request for `my-solution`](https://help.github.com/articles/creating-a-pull-request) on the original repository, i.e. the owned by [github.com/ScPo-CompEcon](https://github.com/ScPo-CompEcon). 20 | 1. You can continue to push fixes and improvements until the close date (24 hours before the next class). 21 | 1. I will push my solutions to the 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 the `master` branch). 22 | 23 | ### Requirements for Homeworks 24 | 25 | * I invite you to do the homeworks in teams of 2. 26 | * 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. 27 | * Please make clear who the contributors are in your comment on the pull request. 28 | * 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. 29 | * 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.) 30 | * Notice the file extension `.md` stands for [`markdown`](https://daringfireball.net/projects/markdown/syntax), 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. 31 | --------------------------------------------------------------------------------