Skip to content

Add causal inference chapter#630

Merged
d-morrison merged 10 commits intomainfrom
copilot/add-causal-inference-chapter
Apr 28, 2026
Merged

Add causal inference chapter#630
d-morrison merged 10 commits intomainfrom
copilot/add-causal-inference-chapter

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

  • Create causal-inference.qmd chapter file
  • Create _subfiles/causal-inference/ directory with subfiles
  • Add chapter to _quarto-book.yml and _quarto-website.yml (positioned before predictor-selection)
  • Add references and update inst/WORDLIST
  • Render, lint, spellcheck — all pass
  • Address review comments:
    • Fix hat notation: \widehat{\E{Y(a)}} instead of \widehat{\E}{Y(a)} (regression adjustment and propensity score subfiles)
    • Fix citation locator syntax: [@vittinghoff2e, Chapter 9] instead of @vittinghoff2e [Chapter 9]
    • Remove unused smoking mutate from the HERS LDL regression adjustment example
    • Move causal-inference before predictor-selection in book and website navigation; move DAG definitions (_sec-pred-sel-dag.qmd) into the causal inference chapter so they are defined in the chapter that appears first; predictor-selection now links back to those definitions
    • Add hidden hers-data-setup chunk in predictor-selection.qmd so its analysis sections retain access to hers_ldl after the DAG include was removed
    • Merge the former "Causal Thinking and DAGs" and "Observational Studies" sections into a single Observational Studies section with straightforward narrative flow: observational studies intro → confounding (formal definition) → DAGs introduced as a tool to identify confounders and sufficient adjustment sets (including confounder, mediator, collider, and backdoor criterion definitions) → HERS DAG example → WCGS confounded observational study example
    • Add "Narrative Flow" guideline to .github/copilot-instructions.md instructing contributors to introduce concepts before use and avoid forward references

Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 06:06
Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 06:25
Agent-Logs-Url: https://github.com/d-morrison/rme/sessions/f13c8856-f8ef-4e81-bb1d-b3c9d69be8cf

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 06:28
Copilot AI changed the title [WIP] Add a chapter on causal inference Add causal inference chapter Apr 28, 2026
Copilot AI requested a review from d-morrison April 28, 2026 06:30
@d-morrison d-morrison marked this pull request as ready for review April 28, 2026 07:01
Copilot AI review requested due to automatic review settings April 28, 2026 07:01
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 a new self-contained causal inference chapter to the Quarto book/website, adapting and integrating material around potential outcomes, identification assumptions, and practical estimators using existing course datasets.

Changes:

  • Adds new chapter causal-inference.qmd plus supporting subfiles under _subfiles/causal-inference/.
  • Registers the new chapter in the book and website render/navigation YAMLs.
  • Extends references.bib and inst/WORDLIST for new citations and terminology.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
references.bib Adds causal inference references (Hernán & Robins; Rubin; Holland; Rosenbaum & Rubin).
inst/WORDLIST Adds causal-inference-related spellcheck terms (ATE/ATT/ATU, IPW, exchangeability, etc.).
causal-inference.qmd New chapter scaffold; includes subfiles and shared DAG section; adds learning objectives and summary.
_subfiles/causal-inference/_sec_potential_outcomes.qmd Introduces potential outcomes and core definitions.
_subfiles/causal-inference/_sec_causal_estimands.qmd Defines ATE/ATT/ATU with formal definitions.
_subfiles/causal-inference/_sec_assumptions.qmd Defines consistency, exchangeability, and positivity.
_subfiles/causal-inference/_sec_rct.qmd Explains why randomization identifies causal effects; HERS example.
_subfiles/causal-inference/_sec_observational.qmd Defines confounding/backdoor criterion; WCGS observational framing.
_subfiles/causal-inference/_sec_regression_adjustment.qmd Introduces G-computation/regression adjustment; HERS LDL example with code/table.
_subfiles/causal-inference/_sec_propensity_scores.qmd Defines propensity score and IPW; WCGS example with code/diagnostic plot.
_quarto-website.yml Adds the chapter to website render list and navbar.
_quarto-book.yml Adds the chapter to the book chapter list.

Comment thread _subfiles/causal-inference/_sec_propensity_scores.qmd Outdated
Comment thread causal-inference.qmd Outdated
Comment thread _subfiles/causal-inference/_sec_regression_adjustment.qmd Outdated
Comment thread _subfiles/causal-inference/_sec_regression_adjustment.qmd Outdated
Comment thread _subfiles/causal-inference/_sec_regression_adjustment.qmd Outdated
Copy link
Copy Markdown
Owner

@d-morrison d-morrison left a comment

Choose a reason for hiding this comment

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

address open comments

…used mutate

Agent-Logs-Url: https://github.com/d-morrison/rme/sessions/349bc19d-9f76-4d78-8fc6-e0ab6869a72c

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

Copilot AI commented Apr 28, 2026

address open comments

Addressed all open review comments in 9e7f939:

  1. Hat notation — Changed \widehat{\E}{Y(a)}\widehat{\E{Y(a)}} and \hat{\E}{...}\widehat{\E{...}} throughout _sec_regression_adjustment.qmd and _sec_propensity_scores.qmd so the widehat covers the full expectation expression.
  2. Citation locator — Changed @vittinghoff2e [Chapter 9][@vittinghoff2e, Chapter 9] in causal-inference.qmd.
  3. Unused smoking mutate — Removed the smoking factor conversion from the HERS LDL setup chunk since smoking is not included in the model or table.

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 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread _subfiles/causal-inference/_sec_regression_adjustment.qmd Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot apply changes based on the comments in this thread

Done in 77e834d. Replaced the {{< include _sec-pred-sel-dag.qmd >}} with prose links to the existing sections in predictor-selection.qmd, so the DAG section/definition IDs are only emitted once across the book.

@d-morrison
Copy link
Copy Markdown
Owner

@copilot the causal inference section should come before predictor selection, like in RMB; adjust where definitions are placed accordingly

…s to causal-inference chapter

Agent-Logs-Url: https://github.com/d-morrison/rme/sessions/255b7b24-f38c-418b-973c-f255208848af

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 19:21
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot the causal inference section should come before predictor selection, like in RMB; adjust where definitions are placed accordingly

Done in c1159a8:

  • Swapped order in _quarto-book.yml and _quarto-website.yml so causal-inference now precedes predictor-selection
  • Moved the {{< include _sec-pred-sel-dag.qmd >}} from predictor-selection.qmd into causal-inference.qmd (so the definitions live in the chapter that appears first)
  • predictor-selection.qmd's "Causal Thinking and DAGs" section now links back to the definitions in the causal inference chapter
  • Added a hidden hers-data-setup chunk in predictor-selection.qmd so its analysis sections still have hers_ldl available without re-displaying the data loading code

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://www.stats.ox.ac.uk:80/pub/MASS4//pkgdown.yml
    • Triggering command: /opt/R/4.6.0/lib/R/bin/exec/R /opt/R/4.6.0/lib/R/bin/exec/R --no-echo --no-restore --file=/opt/quarto/share/rmd/rmd.R /tmp�� (http block)
  • z.umn.edu
    • Triggering command: /opt/R/4.6.0/lib/R/bin/exec/R /opt/R/4.6.0/lib/R/bin/exec/R --no-echo --no-restore --file=/opt/quarto/share/rmd/rmd.R /tmp�� (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI review requested due to automatic review settings April 28, 2026 19:40
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 13 out of 13 changed files in this pull request and generated no new comments.

@d-morrison
Copy link
Copy Markdown
Owner

@copilot consolidate #sec-causal-observational and #sec-causal-dags-chapter and make the narrative flow straightforward;

make a note in copilot-instructions to strive for straightforward narrative flow

…ive flow; add narrative flow guideline to copilot-instructions

Agent-Logs-Url: https://github.com/d-morrison/rme/sessions/9f8d55f1-b1f4-4aed-80bd-2e0c83e20642

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

Copilot AI commented Apr 28, 2026

@copilot consolidate #sec-causal-observational and #sec-causal-dags-chapter and make the narrative flow straightforward;

make a note in copilot-instructions to strive for straightforward narrative...

Done in 106d23c.

Consolidation (causal-inference.qmd): Moved # Causal Thinking and DAGs to precede # Observational Studies — foundational DAG concepts (confounder, mediator, collider) are now introduced before the observational studies section applies them to confounding. The forward reference in _sec_observational.qmd ("See @sec-causal-dags-chapter") is now a backward reference ("As introduced in @sec-causal-dags-chapter"), and the redundant inline re-explanation of confounder/mediator/collider is removed.

The chapter now flows: Potential Outcomes → Estimands → Assumptions → Randomized Experiments → Causal Thinking and DAGsObservational Studies (applying DAGs to confounding) → Regression Adjustment → Propensity Scores.

Copilot instructions: Added a "Narrative Flow" section under General Development Principles covering: introduce concepts before use, avoid forward references when the concept is needed to understand current content, and place foundational sections before applied sections.

@d-morrison
Copy link
Copy Markdown
Owner

@copilot merge #sec-causal-observational and #sec-causal-dags-chapter into a single Observational Studies section; introduce observational studies first, then confounding, then introduce DAGs as a tool to help to identify confounders and sufficient adjustment sets

@d-morrison d-morrison removed their request for review April 28, 2026 21:22
…onfounding→DAGs flow

Agent-Logs-Url: https://github.com/d-morrison/rme/sessions/71b7ba92-564e-4d4c-8a73-22909b338284

Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 21:25
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot merge #sec-causal-observational and #sec-causal-dags-chapter into a single Observational Studies section; introduce observational studies first, then confounding, then introduce DAGs as a too...

Done in a40a6d7.

The two sections are now merged into a single # Observational Studies {#sec-causal-observational} section with this narrative order:

  1. Intro — what an observational study is, and that confounding arises because treatment groups differ systematically
  2. ## Confounding — formal definition of confounding in the potential outcomes framework
  3. Bridge sentence — "DAGs provide a formal graphical tool for representing causal assumptions and identifying confounders, mediators, colliders, and sufficient adjustment sets"
  4. ## Directed Acyclic Graphs — what a DAG is and how to use it
  5. ## Key concepts — formal definitions of confounder, mediator, collider, and backdoor criterion (moved here from the old "DAGs for identifying confounding" subsection, so it precedes the examples that use it)
  6. ## HERS study DAG — applying DAGs in a randomized trial context
  7. ## An observational study example: WCGS — applying DAGs and the backdoor criterion to the confounded observational study

Copilot AI requested a review from d-morrison April 28, 2026 21:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.

2026-04-28 23:27 UTC

@d-morrison d-morrison merged commit 1b5a7a3 into main Apr 28, 2026
3 checks passed
@d-morrison d-morrison deleted the copilot/add-causal-inference-chapter branch April 28, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a chapter on causal inference

3 participants