variation = TRUE inflates the mean intervention delta
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- R
- Estrellas
- 8
- Forks
- 4
- Merge medio
- 3 d 18 h
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de petal-code/helios
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
petal-code/helios#174 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
petal-code/helios#173 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
petal-code/helios#166 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
petal-code/helios#161 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
petal-code/helios#179 ·
Todos los issues de petal-code/helios
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
tidymodels/censored#414 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
waldronlab/bugphyzz#256 ·
-
dbRemoveTable() fails on SQLite with 'near "TRUNCATE": syntax error' and leaves the table in placePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OHDSI/DatabaseConnector#348 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100