Modeling and Uncertainty

Slides

Make slides full screen

More detailed notes accompanying this lecture can be found here.

Exercise 1: Quick Model Checks Before Coding

Mode assignment. Work in pairs. One person should work manually and one should work agentically. Manual means you may use the notes, slides, and discussion with colleagues, but you should not let an AI assistant write or revise your answer. Agentic means you may ask Pi to help reason through the problem, but you should still decide what answer you trust.

Answer these questions briefly. A phrase, formula, or one-sentence explanation is enough.

Part 1 - Match the model

For each data story, write the response type, model family, and a possible formula.

  1. Infection status depends on social contact.
  2. Infection counts depend on distance from an outbreak epicenter.
  3. Antibody titre depends on age and blood pressure.
  4. The age-antibody relationship differs between healthy and disease groups.

Part 2 - Interpret the coefficient scale

  1. In glm(infected ~ social_contact, family = binomial()), what scale is the social_contact estimate on? Which function converts fitted values to probabilities?
  2. In glm(infected ~ epicenter_distance, family = poisson()), what scale is the epicenter_distance estimate on? Which function converts it to a rate ratio?
  3. In lm(antibody ~ age + blood_pressure), how would you interpret the age estimate?
  4. In lm(antibody ~ age + age:group), what does the age:group term tell us?

Part 3 - Choose a revision

For each diagnostic clue, write one reasonable model revision.

  1. Infection probability differs strongly by county, even at the same level of social contact.
  2. Infection counts still differ by region after accounting for distance from the epicenter.
  3. Antibody titre varies with blood pressure as well as age.
  4. The age-antibody trend is not parallel across healthy and disease groups.

Discussion

After completing the exercise:

  • Which questions were easiest to answer manually?
  • Which questions were easier with agentic help?
  • Where did you need to check the assistant’s reasoning most carefully?
  • What would you check before trusting a fitted model?

Exercise 2: Gene Expresssion of Drought Response

Mode flip. If you were agentic in Exercise 1, you are manual now; if you were manual, you are agentic. Same definitions as before — manual means you may ask a chat LLM conceptual questions but it does not touch your notebook.

Open notebooks/05-modeling.qmd in your Codespace.

Part 1 — Predict (no code)

This exercise looks at gene expression of Sorghum bicolor when exposed to drought stress, originally published in “Transcriptomic analysis of field-droughted sorghum from seedling to maturity reveals biotic and metabolic responses”.

Before running any code:

  1. How would linear regression models created using the formulas below differ?

    • log_gene ~ Genotype
    • log_gene ~ Timepoint
    • log_gene ~ Timepoint + Genotype
  2. For any of these formulas,is it better to use a linear regression or Poisson model?

  3. Review the plot of gene expression over time. Sketch what the fitted model would look like compared to the real data.

Part 2 — Build

Fit and interpret a linear regression with the formula log_gene ~ Timepoint + Genotype:

  1. Use lm() to fit the model to the data
  2. Look at the output from summary(). How do you interpret the estimate for GenotypeRT430?
  3. Simulate new response values. Plot this like we plotted the real data above. Comment on the simulation quality.

Part 3 — Reach (optional)

Redo the analysis for another gene (Sobic.008G179900.v3.1). Judging from the plot, is there anything you would change in the formula passed to lm()?

Discussion

Once the room is back together:

  • What was easy in your mode? What was hard?
  • How would you explain your model result to a colleague unfamiliar with linear regression?
  • If the experiment included fertilizer treatments, how might we modify the analysis above? What questions would be answered by your revised analysis?