Undergraduate Computational Macro
“Macroeconomics on a computer”
Focus: math + theory + computation
Goal: structural models for conducting counterfactuals
Complements “field” and applied courses
Required courses (choose one from each group)
Note that micro, not macro, is a requirement
Formal programming course in a general-purpose language
Math background: talk to me if unsure
Please see the syllabus for details on
Note the policy on accommodations
Econ/finance uses many languages
Trade-offs everywhere
My view: learn at least two general-purpose languages
Question: Given the trade-offs discussed in class (speed/verbosity), which do you prefer for this course?
| Preference | Percentage |
|---|---|
| Strongly prefer Julia | 44% |
| Weakly prefer Julia | 28% |
| Indifferent | 11% |
| Weakly prefer Python | 6% |
| Strongly prefer Python | 11% |
Question: Preference between computer-lab based coding exams vs. traditional paper-based exams.
| Preference | Percentage |
|---|---|
| Strongly prefer coding-based | 44% |
| Weakly prefer coding-based | 28% |
| Indifferent | 6% |
| Weakly prefer paper-based | 17% |
| Strongly prefer paper-based | 6% |
Question: Assessment of the amount and difficulty of writing code during the exams.
| Difficulty Level | Percentage |
|---|---|
| Very easy | 28% |
| Relatively easy | 39% |
| Medium | 22% |
| Fairly hard | 11% |
Economists asked this long before “big data”
Statistics works only if you already have the right model for the experiment
Historical data rarely has variation in crucial directions
Dynamics + expectations: choices today depend on forecasts about tomorrow
General equilibrium: policy shifts prices, constraints, and behavior together
People adapt when public policy or prices change
Canonical warnings
More data or fancier estimators can’t fix the wrong “model”
In stats/ML/econometrics we start with a Data Generating Process (DGP)
In macro the hard part is: which DGP lets us answer a particular question?
Think probabilistically: the economy is a joint distribution over
Different assumptions \(\Rightarrow\) different “experiments,” even with the same dataset
Joint distributions let you ask conditional questions
Most interesting problems in economics are counterfactuals
By definition these are not observable. If we had the data already we wouldn’t need to ponder these “What if?” questions
How can you answer a question with data that doesn’t exist?
To answer “what if?”, you need a disciplined way to “make something up”
Theory is what turns data into a model of the economy
A model is a structured joint distribution
This structure constrains counterfactuals
Counterfactuals are not in the data \(\Rightarrow\) you need assumptions
Three complementary approaches
This course: simulations + structural models
Macro counterfactuals are hard because
We can write the math down to “keep us honest”
In macro, we often can’t solve important problems analytically
See Syllabus for more details
The tools are interleaved with applications such as
winget install julia -s msstore in a terminalcurl -fsSL https://install.julialang.org | sh in a terminalOpen the command palette with <Ctrl+Shift+P> or <Cmd+Shift+P> on mac and type > Git: Clone and choose https://github.com/jlperla/undergrad_computational_macro_notebooks
Start a terminal with <Ctrl+Shift+P> or <Cmd+Shift+P> on mac and type > Julia: Start REPL
precompiling VSCodeServerInstantiate packages by running VS Code terminal
] instantiate, where ] enters package modeThen use VS Code to open any of the notebooks in that folder
First REPL should look like this:

Update juliaup release channel? Yes:

Install Revise? Your choice, but restart VS Code after installation:

] instantiate setup install a bunch of pacakges, you likely didn’t start the Julia REPL in the VS Code terminal
julia --project in the notebooks repo] instantiate stepFailed to precompile... then there is likely a problem. Send us the textjulia then restart your terminals, vscode, etc. to ensure environment variables are applied
juliaup instructions for adding something to an environment variable] instantiate againSYSTEM: caught exception of type :MethodError while trying to print a failed Task notice; giving up
MethodError: no method matching pipe_writer(::VSCodeServer.IJuliaCore.IJuliaStdio{Base.PipeEndpoint, typeof(VSCodeServer.io_send_callback)})
The applicable method may be too new: running in world age 38658, while current world is 38713.
Closest candidates are:
pipe_writer(::VSCodeServer.IJuliaCore.IJuliaStdio) (method too new to be called from this world context.)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.173.2/scripts/packages/IJuliaCore/src/stdio.jl:16
pipe_writer(!Matched::Base.Process)
@ Base process.jl:23
pipe_writer(!Matched::Base.AnnotatedIOBuffer)
@ Base strings/annotated_io.jl:21To open a terminal on MacOS
Cmd + Space to open Spotlight, then type Terminal<Cmd-Shift-P> then View: Toggle TerminalIf you get permissions problems try
sudo curl -fsSL https://install.julialang.org | shIf it still shows errors, then see here and do some combo of
sudo chown $(id -u):$(id -g) ~/.bashrc
sudo chown $(id -u):$(id -g) ~/.zshrc
sudo chown $(id -u):$(id -g) ~/.bash_profile
sudo curl -fsSL https://install.julialang.org | shUninstall the Julia extension in VS Code to be safe
Then close VS Code and any Julia terminals
Then delete the .julia folder in your home directory
.julia folder withrm -rf ~/.julia
C:\Users\YourUsername\.juliaOpen up VS Code and reinstall the Julia extension
Follow the instructions to open a Julia REPL in VS Code and install the packages
Manifest.toml changed, this is especially important] instantiate after pulling
Project.toml
] for managing packages] activate or ] activate path/to/projectjulia --project] instantiate to install all the packagesProject.toml file
Project.toml is a Manifest.toml file which establishes the exact versions for reproducibility
] instantiate will install the exact versions