Skip to content
GLM Playground home

Assignment 2 · Question 1 · Binomial GLM

Beetle mortality and insecticide dose

Eight batches of about sixty beetles were exposed to different concentrations of an insecticide and the deaths counted. The assignment asked for a logistic dose–response model: estimates, intervals, the dose that kills half the beetles, goodness-of-fit checks and whether a curved model does better.

The model

With yiy_i beetles killed out of nin_i at log-dosage xix_i, the straight-line model (model.0) and its quadratic extension (model.1) are

Response

yi∼Bin⁡(ni,θi)y_i \sim \operatorname{Bin}(n_i, \theta_i)

Straight line · model.0

logit⁡θi=β0+β1xi\operatorname{logit}\theta_i = \beta_0 + \beta_1 x_i

Quadratic · model.1

logit⁡θi=β0+β1xi+β2xi2\operatorname{logit}\theta_i = \beta_0 + \beta_1 x_i + \beta_2 x_i^2

Explore the fit

Everything below is refitted in your browser by iteratively reweighted least squares, the same algorithm R's glm() uses.

Linear predictor

Dosage (log₁₀ CS₂ mg/l)
Probability of death against dosageDrag on the chart to move the dose
LD50 1.7712
  • Observed proportion killed (95% Wilson CI)
  • Fitted probability
  • 95% pointwise interval
  • LD50 with delta-method 95% CI

P(killed) at dosage 1.800

72.7%

95% CI 66.7% to 77.9% · η = 0.978

LD50 — dose that kills half

1.7712

95% CI (1.7636, 1.7788) (delta method)

Odds multiplier for +0.1 dose

× 29.77

95% CI (16.85, 52.58)

Residual deviance

13.633

on 6 df · AIC 43.83 · 4 IRLS iterations

Empirical logits (Q1a)

Dots: empirical logits with the ½ correction. Line: fitted linear predictor η with its 95% band.

Deviance residuals (Q1h)

Straight line: residuals swing negative in the middle doses and positive at the ends — systematic curvature.

Coefficients (model.0)

TermEstimateStd. errorzp-value
(Intercept)−60.10335.1642−11.642.6 × 10⁻³¹ ***
Dosage33.93422.902911.691.4 × 10⁻³¹ ***

Goodness of fit (Q1g) and the quadratic test (Q1i)

ModelDeviancepPearson X²p
Straight line (6 df)13.6330.034012.1130.0595
Quadratic (5 df)5.1070.40304.9860.4176
Term addedDfDevianceResid. DfResid. DevPr(>Chi)
NULL7284.202
Dosage1270.569613.6338.5 × 10⁻⁶¹ ***
I(Dosage^2)18.52655.1070.0035 **

Adding Dosage² lowers the deviance by 8.526 on 1 df (p = 0.0035), so the quadratic logistic model fits significantly better than the straight line.

Edit the data and refit

Change any count and press Refit; the interactive panels above are refitted by IRLS in your browser. The 2023 findings further down this page always describe the original data.

Dosage1.691.721.761.781.811.841.861.88
Beetles
Killed

Whole numbers only: 1 to 999 beetles per batch, and 0 up to the batch size killed. Nothing is changed until you press Refit.

What the 2023 analysis found

  1. (a) Linearity. Empirical logits rise almost linearly with dose, so a logistic model is a reasonable start.
  2. (b–c) Estimates. β^0=−60.103\hat\beta_0 = -60.103, β^1=33.934\hat\beta_1 = 33.934 (SE 2.903); 95% Wald interval for the slope (28.245, 39.624).
  3. (d) LD50. Solving β^0+β^1x=0\hat\beta_0 + \hat\beta_1 x = 0 gives a lethal dose of 1.7712. The delta-method interval (1.7636, 1.7788) is an addition for this site.
  4. (e) Odds ratio. Each +0.1 in dosage multiplies the odds of death by 29.77, 95% CI (16.85, 52.58).
  5. (f) Dosage 1.8. η^=0.9782\hat\eta = 0.9782, so θ^=0.7268\hat\theta = 0.7268; transforming the interval for η gives (0.6671, 0.7793).
  6. (g) Fit. Residual deviance 13.633 on 6 df (p = 0.0340) rejects adequacy at 5%, while Pearson's X² = 12.113 (p = 0.0595) does not — a borderline fit.
  7. (h–i) Curvature. Deviance residuals show a systematic pattern; adding a quadratic term reduces the deviance by 8.526 on 1 df (p = 0.0035), a significant improvement.

Added in 2026

Model checks and an optional AI explanation

How well does the straight line fit?Three of eight residuals fall outside a simulated envelope, the apparent over-dispersion disappears once curvature is modelled, and the LD50 has Wald, profile-likelihood and bootstrap intervals side by side, with its estimate under two other mean models.See the checks

Explain this output with AI

Optional · your own key

Sends only the numeric summary below to the AI provider you choose, from your browser. The figures on this page are the reference; the AI only paraphrases them and can be wrong. How AI is used

The summary describes the original 2023 counts. If you edit the counts in the lab above, the explanation still describes the original data, not your edited fit.

What would be sent (12 numbers, no data rows)
Intercept b0
-60.1 · SE 5.164
Slope b1 (per unit log-dosage)
33.93 · SE 2.903
Slope 95% Wald CI
(28.24, 39.62)
Slope 95% profile-likelihood CI
(28.54, 39.96)
LD50 (dosage killing half)
1.7712 · delta-method 95% CI (1.7636, 1.7788)
LD50 95% profile-likelihood CI
(1.7634, 1.7787)
Odds ratio for +0.1 dosage
29.77 · 95% CI (16.85, 52.58)
Residual deviance
13.63 · on 6 df, p = 0.034
Pearson X2
12.11 · on 6 df, p = 0.0595
Pearson dispersion estimate (X2/df)
2.02
Quadratic term: deviance drop
8.526 · on 1 df, LR test p = 0.0035
Quadratic term: quasi-binomial F test p-value
0.0329

Plus the model description, data source and: Dose was set by the experimenter (a designed experiment). Batches are treated as independent binomial samples. Original analysis: 2023 coursework, refitted in 2026.

Exact request text (system prompt and message)

Sent verbatim with the model id, a response schema and your key (in a request header, never in the text).

System prompt

You explain the output of a statistical model to a reader who knows basic statistics. The output comes from a student's 2023 coursework, refitted for a portfolio site.

Rules:
- Use only the numbers and facts in the JSON summary you are given. Do not invent numbers, studies, data or context.
- Quote numbers exactly as they appear in the summary (you may round them, but never compute new quantities).
- Report uncertainty where the summary gives it (confidence intervals, standard errors, p-values) and do not treat p > 0.05 as proof of no effect.
- Do not make causal claims unless the summary's context says the design supports them.
- If something a reader would want is not in the summary, say so in "caveats" instead of guessing.
- Plain English, Australian spelling, no marketing tone. Keep it short: a summary of two or three sentences and two to five points.
- List every number you quote in "numbers_used", written exactly as in your text.

Return only the JSON object described by the schema.

Message

Explain this model output.

Summary (JSON):
{
  "title": "Beetle mortality and insecticide dose",
  "model": "Binomial GLM with logit link: logit(P(killed)) = b0 + b1 * dosage (straight line)",
  "data": "Bliss (1935): 8 batches of beetles exposed to carbon disulphide at log-dosages 1.69 to 1.88",
  "sample_size": "481 beetles in 8 dose groups",
  "quantities": [
    {
      "label": "Intercept b0",
      "value": -60.1,
      "note": "SE 5.164"
    },
    {
      "label": "Slope b1 (per unit log-dosage)",
      "value": 33.93,
      "note": "SE 2.903"
    },
    {
      "label": "Slope 95% Wald CI",
      "value": "(28.24, 39.62)"
    },
    {
      "label": "Slope 95% profile-likelihood CI",
      "value": "(28.54, 39.96)"
    },
    {
      "label": "LD50 (dosage killing half)",
      "value": 1.7712,
      "note": "delta-method 95% CI (1.7636, 1.7788)"
    },
    {
      "label": "LD50 95% profile-likelihood CI",
      "value": "(1.7634, 1.7787)"
    },
    {
      "label": "Odds ratio for +0.1 dosage",
      "value": 29.77,
      "note": "95% CI (16.85, 52.58)"
    },
    {
      "label": "Residual deviance",
      "value": 13.63,
      "note": "on 6 df, p = 0.034"
    },
    {
      "label": "Pearson X2",
      "value": 12.11,
      "note": "on 6 df, p = 0.0595"
    },
    {
      "label": "Pearson dispersion estimate (X2/df)",
      "value": 2.02
    },
    {
      "label": "Quadratic term: deviance drop",
      "value": 8.526,
      "note": "on 1 df, LR test p = 0.0035"
    },
    {
      "label": "Quadratic term: quasi-binomial F test p-value",
      "value": 0.0329
    }
  ],
  "context": [
    "Dose was set by the experimenter (a designed experiment).",
    "Batches are treated as independent binomial samples.",
    "Original analysis: 2023 coursework, refitted in 2026."
  ]
}