Study Guide: Week 2#
Open-ended questions on the material from week 2. The exam asks multiple-choice versions of questions like these. No answers are given: each question can be answered in a few sentences from the pages listed under its heading. The exam’s format is described in Exam Preparation.
Fama and French (1993)#
Read: From the CAPM to Multifactor Models, HW 1 Guide D: Constructing the Fama-French Factors, and HW 1 Guide E: Testing the CAPM and the Three-Factor Model.
Fama and French compute size and book-to-market breakpoints from NYSE stocks only but assign NYSE, AMEX, and NASDAQ stocks to the portfolios. Why? What would change if the breakpoints used all three exchanges?
Describe how Fama and French build book equity from Compustat, and explain why the sort in June of year \(t\) pairs book equity from fiscal year \(t-1\) with market equity from December of \(t-1\).
A regression of a portfolio’s excess return on the market’s excess return has an intercept, called alpha, and the CAPM says it should be zero. Fama and French find alphas that are not zero on portfolios sorted by size and book-to-market, and smaller alphas once SMB and HML are added to the regression. What does each finding mean?
CRSP identifies a security by PERMNO and Compustat identifies a company by GVKEY. Why can you not merge the two on ticker, and what does the CRSP-Compustat link table provide?
SQL#
Read: Basics of SQL.
What does each of these SQL keywords do:
SELECT,FROM,WHERE,GROUP BY,ORDER BY,LIMIT?Describe in words what this query returns. What is one row of the result?
SELECT date, AVG(ret) AS avg_return FROM crspm.msf WHERE date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY date;
This query attaches a company name to each monthly return. Why
LEFT JOINand not a plainJOIN? What happens under each to a row ofmsfthat has no matching name?SELECT msf.date, msf.permno, msf.ret, msenames.comnam FROM crspm.msf AS msf LEFT JOIN crspm.msenames AS msenames ON msf.permno = msenames.permno AND msenames.namedt <= msf.date AND msf.date <= msenames.nameendt;
In the query in question 7, the
ONclause has two conditions on dates. What are they for? What would go wrong for a company that changed its name if you joined onpermnoalone?
Task Runners and PyDoit#
Read: What is a build system or task runner? and the PyDoit Examples Walkthrough.
What problem does a task runner solve? Name two things that go wrong when you run a multi-step project by hand.
What is a DAG, and why is a data pipeline one?
Questions 11 to 15 use this dodo.py. It defines three tasks, each of which
runs one Python script.
def task_create_data():
return {
'actions': ['python create_data.py'],
'file_dep': ['create_data.py'],
'targets': ['_output/data.txt'],
}
def task_process_data():
return {
'actions': ['python process_data.py'],
'file_dep': ['process_data.py', '_output/data.txt'],
'targets': ['_output/processed.txt'],
}
def task_create_report():
return {
'actions': ['python create_report.py'],
'file_dep': ['create_report.py', '_output/processed.txt'],
'targets': ['_output/report.txt'],
}
What do
actions,file_dep, andtargetseach mean?You run
doitin a fresh clone, then rundoitagain without changing anything. What happens each time?You edit
process_data.pyand rundoit. Which tasks run and which do not? Why?You delete
_output/report.txtand rundoit. Which tasks run?Suppose
task_process_dataleft'_output/data.txt'out of itsfile_dep. What goes wrong the next time the data changes?How is a
dodo.pylike a Makefile? Give one reason the course uses PyDoit instead of Make.