variation = TRUE inflates the mean intervention delta
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start at calculate_efficacy_from_ach() in R/interventions.R, then reproduce the bias from section 5 of inst/ach_pipeline_walkthrough.R. Review the floor-related test in tests/testthat/test-ach-interventions.R and extend it to verify that the intervention delta remains mean-preserving while staying nonnegative. Document the chosen variation convention in variation_params.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Found while running through the ACH pipeline added in #142.
calculate_efficacy_from_ach() floors the per-location delta at zero after adding noise (R/interventions.R:475):
delta_i <- pmax(0, delta_i + noise)
That's a floor, not a redistribution. Mass that should fall below zero piles up at zero with nothing compensating above it, so the mean moves up. For noise e ~ N(0, sigma):
E[max(0, delta + e)] = delta * Phi(delta/sigma) + sigma * phi(delta/sigma) > delta for all sigma > 0
Measured with delta_function = function() 3 and variation_params = list(mean = 0, sd = 4) over 2000 locations: realised mean delta 3.51 (+17%), with 22% of covered locations getting exactly zero delta. So "add mean-zero unit-to-unit variation" in practice means "add ~17% more ventilation on average, and switch the device off in a fifth of the buildings".
The bias scales with sigma/delta, so it is worst exactly where variation is most wanted — representing heterogeneous real-world installations. At small sigma relative to delta it is negligible (at sd = 1 the realised mean is 2.99).
Reproducible from section 5 of inst/ach_pipeline_walkthrough.R (on branch claude/epidemic-model-pr-review-f9o3k4).
The existing test at tests/testthat/test-ach-interventions.R:395 ("never produces a negative delta even with downward variation noise") checks that the floor works, which it does — it does not check that the mean survives.
Suggested fix
Use a variation distribution that is positive by construction and mean-preserving, rather than clipping a symmetric one. Multiplicative lognormal with mean 1 is the natural choice:
delta_i <- delta_i * rlnorm(n, meanlog = -sdlog^2 / 2, sdlog = sdlog)
Alternatively keep the additive form but draw from a truncated normal on [0, Inf) re-centred so E[delta] is preserved (truncnorm is already a dependency).
Either way variation_params should document which convention it follows — list(mean = 0, sd = 4) currently reads as mean-preserving and is not.
- Lingua principale
- R
- Stelle
- 8
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di petal-code/helios
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
petal-code/helios#174 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
petal-code/helios#173 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
petal-code/helios#166 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
petal-code/helios#161 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
petal-code/helios#157 · 1 commento ·
Tutte le issue di petal-code/helios
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tidymodels/censored#414 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
waldronlab/bugphyzz#256 ·
-
dbRemoveTable() fails on SQLite with 'near "TRUNCATE": syntax error' and leaves the table in placeForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
OHDSI/DatabaseConnector#348 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100