ebook img

Quantitative Economics with Julia PDF

1186 Pages·2020·23.776 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Quantitative Economics with Julia

Quantitative Economics with Julia Jesse Perla, Thomas J. Sargent and John Stachurski December 4, 2020 2 Contents I Getting Started with Julia 1 1 Setting up Your Julia Environment 3 2 Interacting with Julia 9 3 Introductory Examples 17 4 Julia Essentials 45 5 Arrays, Tuples, Ranges, and Other Fundamental Types 75 6 Introduction to Types and Generic Programming 111 II Packages and Software Engineering in Julia 135 7 Generic Programming 137 8 General Purpose Packages 159 9 Data and Statistics Packages 167 10 Solvers, Optimizers, and Automatic Differentiation 177 11 Julia Tools and Editors 197 12 Git, GitHub, and Version Control 209 13 Packages, Testing, and Continuous Integration 227 14 The Need for Speed 249 III Tools and Techniques 271 15 Linear Algebra 273 3 4 CONTENTS 16 Orthogonal Projections and Their Applications 297 17 LLN and CLT 313 18 Linear State Space Models 331 19 Finite Markov Chains 355 20 Continuous State Markov Chains 379 21 A First Look at the Kalman Filter 401 22 Numerical Linear Algebra and Factorizations 417 23 Krylov Methods and Matrix Conditioning 447 IV Dynamic Programming 479 24 Shortest Paths 481 25 Job Search I: The McCall Search Model 489 26 Job Search II: Search and Separation 503 27 A Problem that Stumped Milton Friedman 515 28 Job Search III: Search with Learning 527 29 Job Search IV: Modeling Career Choice 543 30 Job Search V: On-the-Job Search 557 31 Optimal Growth I: The Stochastic Optimal Growth Model 569 32 Optimal Growth II: Time Iteration 585 33 Optimal Growth III: The Endogenous Grid Method 601 34 LQ Dynamic Programming Problems 609 35 Optimal Savings I: The Permanent Income Model 637 36 Optimal Savings II: LQ Techniques 653 CONTENTS 5 37 Consumption and Tax Smoothing with Complete and Incomplete Markets 671 38 Optimal Savings III: Occasionally Binding Constraints 689 39 Robustness 707 40 Discrete State Dynamic Programming 727 V Modeling in Continuous Time 751 41 Modeling COVID 19 with Differential Equations 753 42 Modeling Shocks in COVID 19 with Stochastic Differential Equations 769 VI Multiple Agent Models 789 43 Schelling’s Segregation Model 791 44 A Lake Model of Employment and Unemployment 801 45 Rational Expectations Equilibrium 825 46 Markov Perfect Equilibrium 839 47 Asset Pricing I: Finite State Models 857 48 Asset Pricing II: The Lucas Asset Pricing Model 877 49 Asset Pricing III: Incomplete Markets 887 50 Uncertainty Traps 899 51 The Aiyagari Model 911 52 Default Risk and Income Fluctuations 919 53 Globalization and Cycles 937 VII Time Series Models 951 54 Covariance Stationary Processes 953 6 CONTENTS 55 Estimation of Spectra 971 56 Additive Functionals 985 57 Multiplicative Functionals 1003 58 Classical Control with Linear Algebra 1023 59 Classical Filtering With Linear Algebra 1043 VIII Dynamic Programming Squared 1063 60 Dynamic Stackelberg Problems 1065 61 Optimal Taxation in an LQ Economy 1091 62 Optimal Taxation with State-Contingent Debt 1111 63 Optimal Taxation without State-Contingent Debt 1143 Part I Getting Started with Julia 1 Chapter 1 Setting up Your Julia Environment 1.1 Contents • Overview 1.2 • A Note on Jupyter 1.3 • Desktop Installation of Julia and Jupyter 1.4 • Using Julia on the Web 1.5 • Installing Packages 1.6 1.2 Overview In this lecture we will cover how to get up and running with Julia. There are a few different options for using Julia, including a local desktop installation and Jupyter hosted on the web. If you have access to a web-based Jupyter and Julia setup, it is typically the most straightfor- ward way to get started. 1.3 A Note on Jupyter Like Python and R, and unlike products such as Matlab and Stata, there is a looser connec- tion between Julia as a programming language and Julia as a specific development environ- ment. While you will eventually use other editors, there are some advantages to starting with the Jupyter environment while learning Julia. • The ability to mix formatted text (including mathematical expressions) and code in a single document. • Nicely formatted output including tables, figures, animation, video, etc. • Conversion tools to generate PDF slides, static HTML, etc. • Online Jupyter may be available, and requires no installation. We’ll discuss the workflow on these features in the next lecture. 3 4 CHAPTER 1. SETTING UP YOUR JULIA ENVIRONMENT 1.4 Desktop Installation of Julia and Jupyter If you want to install these tools locally on your machine • Download and install Julia, from download page , accepting all default options. – We do not recommend JuliaPro. • Open Julia, by either 1. Navigating to Julia through your menus or desktop icons (Windows, Mac), or 2. Opening a terminal and typing julia (Linux; to set this up on Mac, see end of section) You should now be looking at something like this This is called the JULIA REPL (Read-Evaluate-Print-Loop), which we discuss more later. • In the Julia REPL, hit ] to enter package mode and then enter. add IJulia InstantiateFromURL This adds packages for • The IJulia kernel which links Julia to Jupyter (i.e., allows your browser to run Julia code, manage Julia packages, etc.). • The InstantiateFromURL which is a tool written by the QE team to manage pack- age dependencies for the lectures. Note: To set up the Julia terminal command on Mac, open a terminal and run sudo ln - s <where_julia_app_is>/Contents/Resources/julia/bin/julia /usr/lo- cal/bin/julia. The full command might look like sudo ln -s /Applications/Julia- 1.4.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia, if you placed the app in your Applications folder. Note: To obtain the full set of packages we use, at this stage you can run the following (see the package setup section.) using InstantiateFromURL github_project("QuantEcon/quantecon-notebooks-julia", version = "0.8.0", instantiate = true, precompile = true) 1.4.1 Installing Jupyter If you have previously installed Jupyter (e.g., installing Anaconda Python by downloading the binary https://www.anaconda.com/download/) then the add IJulia installs everything you need into your existing environment.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.