Dengue risk model: logistic regression with a quadratic age term
A binomial GLM (logit link) for whether an individual became a dengue case, built step by step on a
course dataset of 196 individuals (57 cases) with age, socioeconomic level and city sector.
This is a statistical model, not a neural network: the "weights" are the coefficients in coefficients.json.
Write-up with charts: https://igor-millis.github.io/work/dengue-logistic-regression/ (PT: /pt/work/dengue-logistic-regression/)
Two candidate models (final choice left open on purpose)
| A: linear age | B: quadratic age | |
|---|---|---|
| formula | caso ~ idade + setor |
caso ~ idade + I(idade^2) + setor |
| AIC | 217.64 | 211.58 |
| BIC | 227.47 | 224.69 |
| AUC (same data) | 0.725 | 0.745 |
| McFadden R² | 0.104 | 0.139 |
Model B fits better (likelihood-ratio test for the age² term: p = 0.00451); model A has a single odds ratio
for age. Level (nivel) and the age × sector interactions did not improve the fit and were dropped.
The odds ratio for sector 2 vs 1 is 3.5916 (95% CI 1.8322 to 7.2264) in model B.
Using the coefficients (model B)
import math
def p_case(age, sector2): # sector2 = 1 for sector 2, 0 for sector 1
z = -3.28198140 + 0.11342479 * age + (-0.00119401) * age**2 + 1.27860171 * sector2
return 1 / (1 + math.exp(-z))
Files
coefficients.json: coefficients, odds ratios, metrics and test results for both modelsreport.html: full R Markdown report (all tests, diagnostics and figures)analysis.Rmd: source of the report;export_site_data.R: script that exports the numbers
Limitations
- Observational data: odds ratios describe associations, not causal effects.
- The model was selected and evaluated on the same sample; the AUC is apparent (no external validation).
- Only 36 individuals are 40 or older, so the right end of the age curve is poorly estimated.
- Residual diagnostics and the link test have little power with a binary outcome and n = 196.
- The raw dataset comes from a course and is not included;
analysis.Rmdexpects a localdengue.txt. - Not for clinical or public-health decisions.
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support