Module 02 Activity
Scenario
A dataset has arrived for a comparison. Establish what one row is and whether the table can support the test at all.
What you build
An analysis table with a stated grain, declared dtypes and a passing check dictionary.
Steps
- Write down the outcome, predictor, grouping, unit and time window before touching the data.
- Set the dtype of every column deliberately —
Categoricalfor groups,ordered=Truefor ordinal scales, nullable integers for counts. - Count missing values by group with
countin the aggregation, and report whether missingness is balanced. - Compare
len(df)withdf[unit].nunique(). If units repeat, aggregate before testing. - Set the reference level explicitly with
C(var, Treatment(reference=...)). - Run a dictionary of boolean checks and treat every failure as a question for the data owner.
Evidence to hand in
- The five decisions, written before the analysis.
- The dtype of every column, with the reason.
- The missingness table by group.
- Rows versus distinct units, and any aggregation.
- The reference level you chose.
- The check results, with what each failure led to.
Review checklist
- The unit of analysis is stated and the table's grain matches it.
- Missingness is counted by group and its balance reported.
- Repeated measurements are aggregated, or the dependence is addressed.
- Every grouping variable is
Categoricalwith a deliberately set reference. - No failed check was silently relaxed.
