Four papers, one toolkit — the step-by-step plan
HEC Montréal
Everything you need to type is on one sheet — how to start Python in VS Codium on your platform, how to make a file and run it, the DataFrame basics, and every name from sessions 1 to 7, each with a line showing it in use.
Python Cheatsheet · Session 07 (PDF) · in the repository at
07-…/PYTHON-CHEATSHEET.pdf
One sheet per package, functions explained with pictures: pandas · NumPy · matplotlib · statsmodels · scikit-learn
Print it, or keep it open beside the editor. Nothing on it is examinable; all of it is assumed.
The scripts run in a folder of your own; the guides stay in 07-replication-workshop/02-practice/:
README.md |
this plan, with every command to copy |
check_setup.py |
Part 0: is everything in place? — in the scripts’ zip |
r1_…py to r4_…py |
one script per paper, cut into numbered steps — each step a code cell from sessions 3 to 5; each reads its data from the course site |
replications/R1-…md to replications/R4-…md |
one guide per paper: the same steps, and what you should see |
Keep the guide open on one side of the screen and the script on the other.
| When | Part | Guide | Script |
|---|---|---|---|
| 0:00 – 0:15 | 0 · Set up — a folder of your own | README.md, Part 0 |
check_setup.py |
| 0:15 – 0:55 | Paper 1 · news sentiment · OLS, the three logits | R1-fraiberger-2021.md |
r1_fraiberger_2021.py |
| 0:55 – 1:35 | Paper 2 · social groups · binary, ordinal, multinomial logits | R2-saganowski-2019.md |
r2_saganowski_2019.py |
| 1:35 – 1:45 | Break | ||
| 1:45 – 2:15 | Paper 3 · FDI · OLS, ridge, lasso, elastic net | R3-blonigen-piger-2014.md |
r3_blonigen_piger_2014.py |
| 2:15 – 3:00 | Paper 4 · tariffs · OLS, the three logits, ridge, lasso, elastic net | R4-topalova-khandelwal-2011.md |
r4_topalova_khandelwal_2011.py |
Behind? Move on at the planned time. Three papers read well beat four rushed.
Not the course repository: make an empty folder — Desktop/session-07 — and open it in VS Codium (File → Open Folder…). Then, in its terminal:
open /Applications/Python\ 3*/Install\ Certificates.command # python.org Python only, once
python3 -m venv .venv
source .venv/bin/activate
pip install pandas statsmodels scikit-learn matplotlib
curl -LO https://warint.github.io/quantitative-methods/session-07-scripts.zip
unzip session-07-scripts.zip
python check_setup.pypy -m venv .venv
.venv\Scripts\Activate.ps1
pip install pandas statsmodels scikit-learn matplotlib
$zip = "https://warint.github.io/quantitative-methods/session-07-scripts.zip"
Invoke-WebRequest $zip -OutFile session-07-scripts.zip
Expand-Archive session-07-scripts.zip -DestinationPath .
python check_setup.pyEvery line of check_setup.py says OK? Choose this folder’s .venv as the interpreter (Ctrl/Cmd + Shift + P → Python: Select Interpreter), then open r1_fraiberger_2021.py.
| Minutes | Do | In the guide |
|---|---|---|
| 0 – 3 | Know the data: what one row is, which variables | The data |
| 3 – 5 | See which session’s code each step copies | The models, and where the code comes from |
| 5 – 25 | Run the steps, one at a time, checking each against You should see | Steps |
| 25 – 30 | Read each result as a sentence, with units | Interpretation |
| 26 – 30 | Say what it does not license | What this does not license |
A number that differs from You should see is not a failure — it is a finding. Stop, and find out whether it is your data, your code, or the version of a package.
Every member runs at least one script on their own machine.
MATH60033A · Session 07 workshop · Thierry Warin, PhD · HEC Montréal