Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# primer.tutorials (development version)

* Fixed render failures in `dgm-logistic` caused by `plot_predictions()` on a parsnip `logistic_reg()` fit under `marginaleffects` 0.32.0 (`condition = <continuous>` exhausts memory; `by =` crashes; the same calls on an `lm` fit or via `extract_fit_engine()` are fine). Exercises 10 and 11 now build an explicit grid of hypothetical employees (`tibble()` / `expand_grid()`) and pass it to `predictions()`; Exercise 12 uses `avg_predictions(by = "OverTime")` piped into `ggplot()`. All are equivalent, version-robust, and keep the columns named as the `ggplot()` code expects. The section now builds every plot directly from `predictions()` / `avg_predictions()` output rather than from `plot_predictions()`.

* **Split `05-recruits` into four per-virtue tutorials** --- `05-recruits-wisdom`, `05-recruits-justice`, `05-recruits-courage`, and `05-recruits-temperance` --- each with its own Introduction and Summary and its own YAML `id:`. Students carry one `analysis.qmd` in one `recruits` repo across the sequence. The `05-recruits-courage` tutorial absorbs the tidymodels content (Structure → Method → Fitting) from the retired `dgm-linear` tutorial, and `05-recruits-temperance` absorbs its marginaleffects content (Question → Units → Answer, the marginal/conditional distinction, `avg_predictions()`); `dgm-linear` is removed (its siblings `dgm-logistic`, `dgm-multinomial`, and `dgm-ordered` each re-teach the same framing and are unaffected). Knowledge drops in the Courage and Temperance tutorials are sourced from the DGM essays in `PPBDS/primer` (`guide/dgm.md`) or from the data. **Breaking change for student progress records:** completion data keyed on `05-recruits` or `dgm-linear` does not carry forward.

* Renamed `08-sps` to `08-seguro-popular` so the tutorial slug matches the program name students are studying (the dataset in `primer.data` is still named `sps`, but that internal tibble name was not a useful identifier for the tutorial). Tutorial directory, chapter file, YAML `id:`, and student repo name all change from `sps` to `seguro-popular`; the fitted-model variable changes from `fit_sps` to `fit_sp` (matching the program's "SP" abbreviation). **Breaking change for student progress records:** completion data keyed on `08-sps` does not carry forward.

* **Renumbered all tutorials so that each tutorial's number matches its matching book chapter.** Specifically: discarded the `04-mechanics` tutorial (no longer in the curriculum); renamed `05-cardinal-virtues` → `04-cardinal-virtues`; and renumbered every example tutorial down by one (`06-recruits` → `05-recruits`, `07-trains` → `06-trains`, `08-colleges` → `07-colleges`, `09-sps` → `08-sps`, `10-smokes` → `09-smokes`, `11-shaming` → `10-shaming`). The matching book chapters in `book/` were renamed correspondingly. YAML `id:` fields and the `description:` "Tutorial #NN" lines were updated to match the new numbers. **Breaking change for student progress records:** completion data keyed on any of the old IDs (`04-mechanics`, `05-cardinal-virtues`, `06-recruits`, `07-trains`, `08-colleges`, `09-sps`, `10-smokes`, `11-shaming`) does not carry forward. The total curriculum is now 4 misc + 12 example = 16 tutorials, with the EMH split at `05–08` Easy, `09–12` Medium, `13–16` Hard.
Expand Down
9 changes: 5 additions & 4 deletions R/recruits.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#' Teaching cut of NHANES young-adult heights
#'
#' A 50-row sample drawn from the National Health and Nutrition Examination
#' Survey (NHANES, via [primer.data::nhanes]) for the `05-recruits`
#' tutorial. Restricted to ages 18--27 and to the columns relevant for the
#' tutorial's question. The split between sexes (40 male, 10 female) is
#' Survey (NHANES, via [primer.data::nhanes]) for the `05-recruits-*`
#' tutorials (`05-recruits-wisdom`, `-justice`, `-courage`, `-temperance`).
#' Restricted to ages 18--27 and to the columns relevant for the
#' tutorials' question. The split between sexes (40 male, 10 female) is
#' deliberately uneven so the two group means have visibly different
#' standard errors --- a feature the tutorial's Temperance section asks
#' standard errors --- a feature the `05-recruits-temperance` tutorial asks
#' students to notice and explain.
#'
#' @format A tibble with 50 rows and 3 variables:
Expand Down
9 changes: 5 additions & 4 deletions data-raw/recruits.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Build the `recruits` dataset shipped with the primer.tutorials package.
#
# The 05-recruits tutorial uses this 50-row sample as a teaching cut of the
# NHANES height data. The deliberate mix --- 40 men and 10 women --- gives
# the two group means visibly different standard errors, which is one of the
# things the tutorial is meant to make students notice and explain.
# The 05-recruits-* tutorials (wisdom / justice / courage / temperance) use
# this 50-row sample as a teaching cut of the NHANES height data. The
# deliberate mix --- 40 men and 10 women --- gives the two group means
# visibly different standard errors, which is one of the things the
# 05-recruits-temperance tutorial is meant to make students notice and explain.
#
# Re-run this script (Rscript data-raw/recruits.R from the package root)
# whenever you want to regenerate data/recruits.rda. usethis::use_data()
Expand Down
2 changes: 1 addition & 1 deletion inst/tutorials/03-rubin-causal-model/tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ This tutorial walked through the Rubin Causal Model framework by applying the fo
* **The fundamental problem of causal inference is that we only ever observe one potential outcome.** The other is the counterfactual, and we can never see it.
* **The predictive/causal distinction is an analyst's commitment**, not a property of the data or the model. The same fit serves both questions; what changes is the language and the assumptions you are willing to defend.

The example tutorials that follow (`05-recruits`, `06-trains`, `07-colleges`, ...) walk through the same arc using real data and `tidymodels` code. The conceptual moves rehearsed here --- writing down the Preceptor Table, distinguishing potential outcomes from observable outcomes, defending unconfoundedness or acknowledging where it fails --- are exactly the moves you will use there.
The example tutorials that follow (`05-recruits-wisdom`, `06-trains`, `07-colleges`, ...) walk through the same arc using real data and `tidymodels` code. The conceptual moves rehearsed here --- writing down the Preceptor Table, distinguishing potential outcomes from observable outcomes, defending unconfoundedness or acknowledging where it fails --- are exactly the moves you will use there.

The world is always more uncertain than our models would have us believe.

Expand Down
2 changes: 1 addition & 1 deletion inst/tutorials/04-cardinal-virtues/tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ question_text(NULL,

This tutorial walked through the four Cardinal Virtues --- *Wisdom*, *Justice*, *Courage*, and *Temperance* --- by applying them to two paired questions about high-school SAT scores: a predictive question (next year's average) and a causal one (the effect of a school-wide tutoring class). The exercises were conceptual, not coded. The takeaway is the framework itself: every data science problem proceeds through the same four-step arc, and the predictive/causal distinction is something the analyst commits to in Wisdom and defends in Justice --- not something the data dictates.

The example tutorials that follow (`05-recruits`, `06-trains`, `07-colleges`, ...) walk through the same arc using real data and `tidymodels` code. The hardest concepts in those tutorials --- writing down the Preceptor Table, defending the four assumptions, choosing the probability family --- are exactly the conceptual moves rehearsed here.
The example tutorials that follow (`05-recruits-wisdom`, `06-trains`, `07-colleges`, ...) walk through the same arc using real data and `tidymodels` code. The hardest concepts in those tutorials --- writing down the Preceptor Table, defending the four assumptions, choosing the probability family --- are exactly the conceptual moves rehearsed here.

The world is always more uncertain than our models would have us believe.

Expand Down
Loading
Loading