Skip to content

Add chapters 19–23 (Part III) and standardize LaTeX macros across all chapters#69

Open
Copilot wants to merge 9 commits into
mainfrom
copilot/transcribe-lecture-notes
Open

Add chapters 19–23 (Part III) and standardize LaTeX macros across all chapters#69
Copilot wants to merge 9 commits into
mainfrom
copilot/transcribe-lecture-notes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

  • Create chapters/19-time-varying-treatments.qmd (pp. 255-265)
  • Create chapters/20-treatment-confounder-feedback.qmd (pp. 267-275)
  • Create chapters/21-g-methods-time-varying.qmd (pp. 277-302)
  • Create chapters/22-target-trial-emulation.qmd (pp. 305-320)
  • Create chapters/23-causal-mediation.qmd (pp. 323-330)
  • Update _quarto-website.yml navigation to include chapters 19-23
  • Apply \ind macro (replaces \perp\!\!\!\perp) across all chapters
  • Apply \E{...} macro (replaces E[...]) across all chapters
  • Add new technical terms to inst/WORDLIST; remove duplicate ggdag entry
  • Add qmd to inst/WORDLIST to fix spell check CI failure
  • Restore immunosuppression to inst/WORDLIST (was accidentally removed)
  • Fix nested E[\hat{\theta}]\E{\hat{\theta}} in chapters/11-why-model.qmd
  • Fix nested E[Y^a|L] / E[Y|A=a,L]\E{\E{...}} with \mid in chapters/02-randomized-experiments.qmd
  • Run spelling::spell_check_package() locally — no errors

Copilot AI requested review from Copilot and removed request for Copilot May 4, 2026 06:21
Copilot AI linked an issue May 4, 2026 that may be closed by this pull request
Copilot AI and others added 3 commits May 4, 2026 06:34
…ents

Chapter 19: Time-varying treatments
- Treatment history notation, counterfactuals under strategies
- Static vs. dynamic treatment strategies
- Sequentially randomized experiments
- Sequential exchangeability and positivity
- Time-varying confounding and feedback

Chapter 20: Treatment-confounder feedback
- Elements of feedback: L_k affected by A_{k-1} and confounds A_k
- Why standard regression (stratification, multivariable) fails
- Structural nature of the bias — not fixable by model flexibility
- Adjusting for past treatment produces controlled direct effects

Chapter 21: G-methods for time-varying treatments
- G-formula for time-varying treatments (big g-formula)
- IP weighting with stabilized weights SW^A and SW^C
- Doubly robust AIPW estimator
- G-estimation of structural nested mean models (SNMMs)
- Censoring as a time-varying treatment

Chapter 22: Target trial emulation
- ITT vs. per-protocol effects
- Specifying the target trial components
- Immortal time bias and new user/active comparator design
- Sequential trials design for time zero alignment
- Unified framework for observational causal inference

Chapter 23: Causal mediation
- Limitations of classical Baron-Kenny mediation analysis
- Natural direct and indirect effects (NDE, NIE)
- Controlled direct effect (CDE)
- Interventionist/stochastic mediation approach
- Time-varying mediators as a special case of g-methods

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 4, 2026 06:42
Agent-Logs-Url: https://github.com/ucdavis/win/sessions/a538ac1b-2966-4beb-8ded-682aaf0e2482

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 4, 2026 06:52
Copilot AI changed the title [WIP] Transcribe lecture notes to match textbook content Add chapters 19–23 (Part III) and standardize LaTeX macros across all chapters May 4, 2026
Copilot AI requested a review from d-morrison May 4, 2026 06:53
@d-morrison d-morrison marked this pull request as ready for review May 4, 2026 08:06
Copilot AI review requested due to automatic review settings May 4, 2026 08:06
@d-morrison
Copy link
Copy Markdown
Collaborator

@copilot fix spellcheck

Agent-Logs-Url: https://github.com/ucdavis/win/sessions/649063ba-d668-42f8-8808-dc446b1d6867

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 4, 2026

@copilot fix spellcheck

Added qmd to inst/WORDLIST in fb2e992. The spell checker was flagging the file extension from the {{< include latex-macros/macros.qmd >}} shortcode in index.qmd. Verified locally with spelling::spell_check_package() — no errors.

@d-morrison d-morrison removed their request for review May 4, 2026 08:10
Copilot AI requested a review from d-morrison May 4, 2026 08:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Part III content (Chapters 19–23) to the Quarto lecture notes and standardizes common LaTeX operator notation across the existing chapters using the shared latex-macros submodule.

Changes:

  • Added new Quarto chapters 19–23 (time-varying treatments through mediation), each rendering to HTML/RevealJS/PDF (and DOCX, consistent with existing chapters).
  • Standardized expectation and independence notation across chapters (e.g., E[...]\E{...}, \perp\!\!\!\perp\ind).
  • Updated _quarto-website.yml navigation and expanded inst/WORDLIST for new technical terms.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
inst/WORDLIST Added causal-inference terms for spellcheck; removed duplicate entry.
_quarto-website.yml Added sidebar navigation entries for new Chapters 19–23.
chapters/01-introduction.qmd Macro standardization updates in math notation.
chapters/02-randomized-experiments.qmd Macro standardization updates in math notation.
chapters/03-observational-studies.qmd Macro standardization updates in math notation.
chapters/04-effect-modification.qmd Macro standardization updates in math notation.
chapters/05-interaction.qmd Macro standardization updates in math notation.
chapters/06-graphical-representation.qmd Macro standardization updates in math notation.
chapters/07-confounding.qmd Macro standardization updates in math notation.
chapters/09-measurement-bias.qmd Macro standardization updates in math notation.
chapters/10-random-variability.qmd Macro standardization updates in math notation.
chapters/11-why-model.qmd Macro standardization updates in math notation.
chapters/12-ip-weighting-marginal-structural-models.qmd Macro standardization updates in math notation.
chapters/13-standardization-parametric-g-formula.qmd Macro standardization updates in math notation.
chapters/14-g-estimation-structural-nested-models.qmd Macro standardization updates in math notation.
chapters/15-outcome-regression-propensity-scores.qmd Macro standardization updates in math notation.
chapters/16-instrumental-variable-estimation.qmd Macro standardization updates in math notation.
chapters/18-variable-selection-causal-inference.qmd Macro standardization updates in math notation.
chapters/19-time-varying-treatments.qmd New Chapter 19 content (Part III).
chapters/20-treatment-confounder-feedback.qmd New Chapter 20 content (Part III).
chapters/21-g-methods-time-varying.qmd New Chapter 21 content (Part III).
chapters/22-target-trial-emulation.qmd New Chapter 22 content (Part III).
chapters/23-causal-mediation.qmd New Chapter 23 content (Part III).

Comment thread inst/WORDLIST
Comment thread chapters/11-why-model.qmd Outdated
Comment thread chapters/02-randomized-experiments.qmd Outdated
@d-morrison
Copy link
Copy Markdown
Collaborator

@copilot apply changes based on the comments in this thread

@d-morrison d-morrison removed their request for review May 4, 2026 08:12
…ize nested E[] macros in ch02 and ch11

Agent-Logs-Url: https://github.com/ucdavis/win/sessions/29247ca6-572c-4454-bb3b-38fc70b077c5

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 4, 2026

@copilot apply changes based on the comments in this thread

Applied all three reviewer changes in 42c47e0:

  • Restored immunosuppression to inst/WORDLIST (was accidentally dropped)
  • chapters/11-why-model.qmd: inner E[\hat{\theta}]\E{\hat{\theta}}
  • chapters/02-randomized-experiments.qmd (lines 483-486): all inner raw E[Y^a|L]/E[Y^a|A=a, L]/E[Y|A=a, L] converted to nested \E{\E{... \mid ...}} with \mid

Copilot AI requested a review from d-morrison May 4, 2026 08:16
@d-morrison d-morrison requested review from Copilot and removed request for d-morrison May 4, 2026 08:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Comment thread inst/WORDLIST
Comment on lines 21 to 22
RStudio
RevealJS
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://ucdavis.github.io/win/pr-preview/pr-69/

Built to branch gh-pages at 2026-05-04 08:38 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@d-morrison
Copy link
Copy Markdown
Collaborator

@claude review

@claude
Copy link
Copy Markdown

claude Bot commented May 15, 2026

Claude finished @d-morrison's task in 4m 0s —— View job


PR Review

  • Gather context
  • Read CLAUDE.md / copilot-instructions.md for repo-specific guidelines
  • Review inst/WORDLIST (alphabetization, new terms)
  • Review new chapters 19–23
  • Review LaTeX macro standardization in existing chapters
  • Review _quarto-website.yml navigation changes
  • Post comprehensive review

Summary

This PR adds Part III chapters (19–23) covering time-varying treatments through causal mediation, and standardizes LaTeX macro notation across all chapters. The content is substantively strong and the previously-flagged reviewer issues have been addressed. One outstanding issue remains.


Outstanding Issue: inst/WORDLIST Is Out of Alphabetical Order

The copilot reviewer flagged this in their second review, and it has not yet been fixed. The repo's copilot-instructions.md explicitly requires the WORDLIST to be alphabetized. Current violations:

Uppercase section:

  • PP (line 19) appears before Positivity (line 20) — case-insensitively PP > Po, so PP should come after Positivity
  • RStudio (line 21) appears before RevealJS (line 22) — case-insensitively Rs > Re, so RStudio should come after RevealJS

Lowercase section:

  • neq and notin appear after nonresponse — alphabetically ne < no, so both should come before noncases

Fix this →


Previously Flagged Issues — Confirmed Fixed ✓

Issue Status
immunosuppression removed from WORDLIST (ch08 still uses it) Fixed in 42c47e0 — word is present at line 48
Raw E[\hat{\theta}] inside \E{...} in chapters/11-why-model.qmd:215 Fixed — now reads \E{(\hat{\theta} - \E{\hat{\theta}})^2}
Nested raw E[Y^a|L] / E[Y|A=a,L] in chapters/02-randomized-experiments.qmd Fixed — all four lines now use \E{\E{... \mid ...}}

New Chapters 19–23 — General Assessment

All five chapters follow the established patterns correctly:

  • Format headers match existing chapters exactly (html + revealjs + pdf + docx with correct output-file names)
  • Macro include {{< include ../latex-macros/macros.qmd >}} is present in every chapter
  • No raw E[...] or \perp\!\!\!\perp found — all expectations use \E{...} and all independence statements use \ind
  • Textbook citations follow the @hernan2020causal [Chapter N, pp. X–Y] convention

One minor inconsistency: the new chapters use \Pr[...] (the LaTeX operator command, which renders Pr in roman) while most existing chapters use plain Pr[...] (renders italic in math mode). The new approach is technically more correct, but it creates a cross-chapter inconsistency. This is a low-priority cosmetic issue.


Navigation (_quarto-website.yml)

Clean addition — chapters 19–23 are appended in correct numeric order after chapter 18, with filenames and display text consistent with the established Chapter N: Title pattern.


WORDLIST New Terms

The 16 new terms (adherence, blip, blipped, CDE, collider, emulation, estimand, estimands, immortal, ITT, NDE, NIE, PP, pseudo-population, qmd, semiparametric, SNMM) are all legitimate technical terms or acronyms used in the new chapters. The removal of the duplicate ggdag entry is correct.


Bottom line: The PR is ready to merge once the WORDLIST alphabetical order is corrected. All substantive reviewer comments have been addressed.
|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transcribe the whole book

3 participants