about CMCE10002
0 · Exam Mapcourse.json · brief
| Assessment | Weight |
|---|---|
| In-class quizzes, held during workshops | 10% |
| Mid Semester Test | 20% |
| Group Assignment | 20% |
| 2-hour end of semester examination | 50% |
Permitted materials: not confirmed for this offering in the course materials we hold — check the exam instructions on the LMS.
Paper structure: hand written; 20 multiple-choice questions = 40% and roughly four short-answer questions with subparts = 60%. Draws on lectures, workshops and assigned readings. The subject guide states that a pass in the final exam is required to complete the subject.
Exam use For every code item, predict rows · columns · grain before the values. For every judgement item, write claim · limit · next check.
1 · Name the Question FirstCh 1 · W1
| Type | Asks | Evidence bar |
|---|---|---|
| Descriptive | What happened? | clean, complete record; correct calculation |
| Predictive | What next? | performance on unseen rows |
| Causal | What produced it? | fair comparison with no-treatment outcome |
short-answer stem“This is [type] because ___. It requires ___. The available data support ___, but not ___ because ___.”
1b · Predictive EvidenceCh 12 · W9–11
honest sequenceearlier rows: fit → later held-back rows: score → same later rows: score trivial baseline
2 · Read R as SentencesCh 3 · W2–3
| Form | Read it as / returns |
|---|---|
| x <- value | store right under name left |
| c(a,b) | combine same-type values → vector |
| data$col | take one column → vector |
| data[rows, cols] | subset; blank means keep all there |
| == | ask equality → TRUE/FALSE per value |
| library() | load package for this session |
| read_csv() | read file → tibble |
| nrow(), ncol() | one number each |
| names() | column-name vector |
One = stores or names; two == ask. A filter needs the question form. Always ask what shape comes back: scalar, one value per row, or whole table.
3 · Grain Before ArithmeticCh 3
four-question opening1 How many rows? · 2 What are the columns? · 3 What does ONE row represent? · 4 What type is each column?
A row count counts records. If one customer has several orders, nrow() is not a customer count; count distinct customer identifiers. A row or column count of one after import can signal a misread separator. Confirm numeric types before adding or averaging; dates and identifiers often arrive as text.
4 · Reproducible WorkflowCh 2 · W2
| Place | What survives |
|---|---|
| Console | nothing; for trying |
| Script | instructions |
| Quarto | instructions + explanation + output |
testclean session + this file + this data → this output; no manual step
If chunks work by hand but render fails, memory is hiding a dependency. Restart → run from top → read the first error. Usual causes: package loaded only in console or object created in an earlier experiment.
5 · Build a Plot in Four PartsCh 4 · W3
| Question | Geometry / pre-step |
|---|---|
| count across categories | bar; height is tallied |
| one numeric distribution | histogram |
| two numeric variables | points |
| mean by week | summarise first, then plot |
Mapping vs setting: put a column inside the aesthetic mapping to vary colour and create a legend; put a fixed constant outside to colour every mark the same. Labels and units are evidence, not decoration.
Check Read the mapping back against the business question. A plot can be syntactically valid and answer the wrong quantity—especially count instead of mean.
6 · Plot Before You SummariseCh 5 · W3
three-clause answerSUPPORTED: what the table does show.
HIDDEN: spread, shape, extreme rows or rival explanation.
NEXT: plot raw data or build the fairer comparison.
A mean locates a distribution; SD reports spread around its centre. Neither establishes shape or causality. Always carry n beside a grouped mean: an average over 2 rows prints like one over 400.
Exam response: do not stop at “correlation is not causation”. Name the specific rival driver—price, category, brand strength or promotion in the guide’s product example—and distinguish it from the separate problem of hidden within-band spread. Rival explanation needs a fairer comparison; hidden spread needs the underlying distribution.
Manager test: a useful answer finishes with the action that would settle the issue. “Supported, hidden, next step” is complete; a description alone is not.
7 · Six Verbs, Three JobsCh 6 · W4
| Job | Verb | Effect |
|---|---|---|
| rows | filter() | keep rows meeting condition |
| arrange() | reorder; descending is not default | |
| columns | mutate() | add derived column |
| select() | keep named/pattern/type columns | |
| groups | group_by() | attach labels; visible shape unchanged |
| summarise() | collapse to one row per group |
Filter before ranking. Impossible or missing denominators otherwise rise to the top. Compute before narrowing. A dropped input cannot be used later. For comparable performance use a rate, not a size-driven dollar total.
derived measurereturn on invested capital = operating profit ÷ invested capital
guard: denominator > 0 before division
Read the verb by effect: filtering changes row count, selecting changes column count, arranging changes order only, mutating normally preserves rows and adds a column, grouping preserves the visible table, and summarising changes the grain. That effect is usually what a code-tracing question is really asking.
8 · Pipe + Grouped SummariesCh 7 · W4
Pipe = “then”: pass the result on the left into the first slot on the right. It changes readability, not computation. Trace one line at a time.
Wrong-level trap: if the question is average per customer but rows are orders, first collapse orders within customer, then customers within store. Skipping the first collapse answers an order-weighted question. Shares add a column to a summary; summarising again collapses to one row.
Pipe translation: read each connector as “then”, not as a mathematical operator. Rewrite a confusing chain line by line and annotate the returned shape after every verb; nested calls and piped calls compute the same result.
9 · Tidy Data + PivotsCh 8 · W5
tidy contracteach column = one variable · each row = one observation · each cell = one value
| If… | Do… | Why |
|---|---|---|
| variable trapped in headings | lengthen | period becomes values code can map/group/filter |
| variable names stored in cells | widen | each measure gets a column |
Pre-check: write the result’s grain and predicted row count. Three firms across four quarters → 12 rows after lengthening. Gather only columns carrying the same kind of value; sweeping in an identifier mixes types.
10 · Joins: Decide the UnmatchedCh 9 · W5
| Join | Keeps | Order? |
|---|---|---|
| inner | matched keys only | no |
| left | every left row + matches | yes |
| anti | unmatched left rows only | yes |
| full | everything from either side | no |
Match grain before key. Product-level data joined to product-week data repeat the product row once per week; totals then double-count. If output is larger than either input, key values are repeated and the join fanned out. Count rows per key on both sides first.
coverage reportunmatched count + unmatched fraction + which base was retained
Order test: inner and full joins retain the same key set whichever table is first. Left and anti joins are defined relative to the first table, so swapping inputs asks a different business question. Empty attached cells are evidence of no match, not a zero.
11 · Cross Section / Time / PanelCh 10 · W6
| Shape | One row | Average means |
|---|---|---|
| cross section | one unit | typical unit now |
| time series | one period | typical period for unit |
| panel | one unit-period | depends on collapse |
Question compares stores → group by store, average time away. Question compares quarters → group by quarter, average stores away. Question asks which store bucks the trend → keep both dimensions. A period trapped in headings must be lengthened before it can be grouped.
12 · Causal EvidenceCh 11 · W8
Potential outcomes: each unit has an outcome with treatment and without; the causal effect is their difference, but only one is observed. Model adjustment balances measured factors only. Random assignment makes arms alike on average, including on unmeasured differences.
| Assumption | Breaks when… |
|---|---|
| comparability | unequal odds; arms differ beyond intervention; allocated condition not received |
| stability | spillovers; dropout; intervention varies |
Effect forms: absolute percentage-point difference = practical count; relative change = difference ÷ control rate. Never call relative per cent “percentage points”.
Predictive failure test: if an elaborate rule does not beat “next period equals the previous period” on the same held-back rows, that is a finding. Re-fitting until a nicer score appears turns the held-back rows into training information.