Session 5: Before the session

When is a deliberately biased estimator the better one?

Thierry Warin, PhD

HEC Montréal

Outline · Before class

  1. What to do, and how long it takes
  2. Read the paper
  3. What the paper found
  4. Get both datasets
  5. Your own angle
  6. Self-check, and what the session will ask of you
  7. Before you run anything

What session 5 is for

The mathematics

  • Say how stepwise (AIC), ridge, the lasso and the elastic net each automate model selection
  • Say in plain words what ridge, the lasso and the elastic net each do to the coefficients
  • Say what the elastic net adds when predictors are correlated
  • Apply soft-thresholding by hand to a small example

The Python

  • Standardise before penalising, with StandardScaler inside a pipeline
  • Fit Ridge, Lasso, ElasticNet, knowing that scikit-learn calls \(\lambda\) alpha
  • Choose \(\lambda\) with RidgeCV, LassoCV, ElasticNetCV
  • Read a coefficient path and a cross-validation curve

The international business

  • Choose among 56 candidate determinants of bilateral FDI
  • Say why a variable the lasso dropped is not thereby irrelevant
  • Report a penalised model honestly, including what selection did

Before the session

When is a deliberately biased estimator the better one?

What to do, and how long it takes

1 Read the paper 45–60 min
2 Load both datasets — the paper’s, and your own angle 10 min
3 Attempt the self-check 15 min

The lecture assumes all three are done. The practice assumes the data is already cached on your machine.

1 · Read the paper

Blonigen & Piger (2014), Determinants of foreign direct investment, Canadian Journal of Economics 47(3), 775–812

Read the article · free preprint: NBER w16704

Empirical studies of FDI disagree about which variables belong in the regression. Blonigen and Piger collect 56 candidate determinants, run every model, and ask which variables survive. About sixteen do.

Read for the argument, not for coverage. Annotate four things:

1 The research question, in one sentence
2 The method or design, and why they chose it
3 The strongest single piece of evidence
4 One limitation you would raise as a referee

Two tables carry the paper. Table 1 shows eight prior studies disagreeing about what to include — that is the problem. Table 3 is the answer: 56 variables, an inclusion probability for each. Read those two before anything else.

What the paper found

Of 56 candidates, the ones that survive (log-levels, inclusion probability ≥ 85%):

  • Gravity — parent GDP, host GDP, distance
  • Cultural distance — common official language, colonial relationship
  • Trade agreements — regional trade agreement, customs union
  • Income and endowments — parent GDP per capita, host skill level

And the ones that do not:

  • host business costs, host communications infrastructure, host financial depth, host institutions — the variables a great many published FDI papers lean on

“Many covariates found significant by previous studies are not robust.” That sentence is the paper, and it is also the reason this session exists.

2 · Get both datasets

The practice uses two: the paper’s data, to test its result, and your own angle, to apply the method. Have both before you arrive.

a) The paper’s data, rebuilt

The authors published no replication package — the paper says only that a list of sources is available on request. So the course rebuilt their design from the three sources they name (CEPII’s gravity database, the World Development Indicators, the Penn World Tables) plus the OECD for the dependent variable, for 2019 instead of their 2000.

import qmib

fdi = qmib.load("fdi")
print(fdi.shape)          # 7,051 directed country pairs, 56 candidates

Everything in it is real. scripts/build_fdi_determinants.py is the script that built it, and the data dictionary names every source and every place the rebuild departs from the paper.

Because the year is different, the practice is a question, not an arithmetic check: do the determinants that held in 2000 still hold two decades on?

2b · Your own angle

core = qmib.load("core")                # the spine, shared by every group
mine = qmib.load("angle_c_country")     # REPLACE with your own angle

print(core.shape, mine.shape)

Run this before you arrive. It reads from the repository and caches as parquet, so the practice works whatever the room’s wifi is doing.

angle_c_country is an example, not your angle. Yours is named in RESEARCH-MANDATES.md.

Everything available: qmib.catalog()

3 · Self-check, and what the session will ask of you

Answer these on paper. If you cannot, that is what the lecture is for.

  1. The paper runs every one of \(2^{56}\) models. Why can you not simply run the regression with all 56 variables in it and read the t-statistics?
  2. Two candidate determinants are correlated at 0.97 and both matter. What will the lasso do?
  3. The paper reports that host institutions have a low inclusion probability. Does that mean institutions do not affect FDI?

By the end of the session you should be able to:

  • Say why a greedy stepwise search is unstable, and what that instability argues for
  • State the ridge and lasso objectives and say what each penalty buys
  • Explain why ridge shrinkage is targeted rather than blunt
  • Derive soft-thresholding and use it to explain the lasso’s exact zeros
  • Choose between lasso and elastic net from the correlation structure
  • Report \(\lambda\) by cross-validation, and know why post-selection inference is invalid

Arrive with: the paper read and annotated · qmib.load("fdi") run at least once · your own angle loaded · your self-check answers on paper.

Before you run anything

Everything runs in the VS Codium terminal, from the repository root, with the project environment active. Activate it in every new terminal, not only the first:

source .venv/bin/activate        # macOS and Linux
.venv\Scripts\activate           # Windows (PowerShell)

Your prompt must begin with (.venv). Without it python and pip are your system’s, and nothing the course installed is visible to them.

ModuleNotFoundError means the packages went somewhere else, or were never installed. Check the prompt first, then pip install -r requirements.txt — from the repository root, with the environment active. Building the environment from scratch is Session 01, step 1.4.

Session 05: README.md · the lecture: 01-lecture/