Chapter 17 worked answers: Independent Data Analysis Capstone
On this page
Compare your reasoning after an attempt. Different valid implementations are welcome when they preserve the observation set and the stated meaning.
B2-17-E01 · Check common endpoint coverage
Identify the country lacking the baseline before reporting common-period changes.
A common latest year does not imply a common baseline.
df=pd.DataFrame({"country":["A","A","B"],"year":[2018,2023,2023],"value":[10,12,8]})
wide=df.pivot(index="country",columns="year",values="value")
missing=wide.index[wide[2018].isna()].tolist()
assert missing==["B"]
print(missing)['B']
B2-17-E02 · Compare absolute and relative change
Compute both change measures and explain the different rankings.
The first unit grows more in count, while the smaller baseline gives the second unit greater relative growth.
start=np.array([100.,10.]);end=np.array([110.,15.])
absolute=end-start;relative=100*(end/start-1)
assert absolute.tolist()==[10,5] and np.allclose(relative,[10,50])
print(absolute,relative)[10. 5.] [10. 50.]
B2-17-E03 · Reject an unsupported causal claim
Compute the descriptive change and state why these two totals cannot identify a policy effect.
Two totals show a change of ten under their measurement definition. They do not identify a counterfactual policy outcome or separate mechanisms.
findings={"population_2018":100,"population_2023":110}
change=findings["population_2023"]-findings["population_2018"]
assert change==10
print(change)10
Return to practice
Change one supplied input, predict the effect and rerun your own implementation. Return to the exercise prompts to identify a task you can now explain independently.