Harden joint g-computation target_pop path for forward-projection use#85
Merged
Conversation
Fixes found while reviewing the ARTnet to ARTnetPredict bridge. All changes are additive to the joint path; method = "existing" output is byte-identical to pre-refactor (backward-compat snapshot 3/3, R CMD check 0/0/0). - build_netstats(method = "joint", duration.method = "joint_lm") no longer crashes when a target_pop has an empty age stratum. The synth-duration aggregator now falls back to the within-ARTnet byage durations per empty stratum instead of passing NA into dissolution_coefs. A restricted-age population (common in forward-projected MSM data) previously aborted the build. - target_pop data.frame degree/role/risk columns outside the fitted support are clamped with a warning, preserving the sum(nodefactor) == 2 * edges invariant. Out-of-support values previously broke it silently. - nodefactor tabulations span the full level set via factor(), so an unobserved level (e.g. an absent risk quintile in a target_pop) no longer recycles a per-level vector. Byte-identical when all levels are present. - New optional seed argument to build_netstats for reproducibility of the stochastic sampling path. - Document the joint target_pop semantics: supplied deg.main/deg.casl are covariates (degrees are re-predicted by g-computation), and diag.status affects predicted degree, not just nodefactor_diag.status. - Regression tests in tests/testthat/test-target-pop-robustness.R. - Fix the stale scenario table in method_comparison.R / .md (it listed scenarios the harness no longer runs). - Add inst/validation/forward_projection_bridge_decision.md: memo on the Option A vs B estimand decision for the ARTnetPredict bridge. Docs regenerated with roxygen2 8.0.0 (DESCRIPTION roxygen key + package Rd).
Patch release for the joint g-computation target_pop robustness fixes, so downstream consumers (ARTnetPredict) can pin ARTnet >= 2.9.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Robustness fixes for the joint g-computation
target_poppath, found while reviewing the ARTnet to ARTnetPredict forward-projection bridge. All changes are additive to the joint path. The legacymethod = "existing"output is byte-identical to pre-refactor (backward-compat snapshot 3/3, R CMD check 0/0/0).What changed
build_netstats(method = "joint", duration.method = "joint_lm")no longer crashes when atarget_pophas an empty age stratum. The synth-duration aggregator now falls back to the within-ARTnet byage durations per empty stratum instead of passingNAintodissolution_coefs. A restricted-age population (common in forward-projected MSM data, e.g. dropping the 55-64 group) previously aborted the build.target_popdata.frame degree/role/risk columns outside the fitted support are clamped with a warning, preserving thesum(nodefactor) = 2 * edgesinvariant. Out-of-support values (e.g.deg.casl = 4) previously broke it silently.factor(), so an unobserved level (e.g. an absent risk quintile in atarget_pop) no longer recycles a per-level vector. Byte-identical when all levels are present.seedargument tobuild_netstatsfor reproducibility of the stochastic sampling path. Defaults toNULL(no change in behavior).target_popsemantics: supplieddeg.main/deg.caslare covariates (degrees are re-predicted by g-computation, not transported as counts), anddiag.statusaffects predicted degree, not justnodefactor_diag.status.method_comparison.R/.md(it listed scenarios the harness no longer runs) and regenerated the report.inst/validation/forward_projection_bridge_decision.md: a memo on the Option A vs B estimand decision for the ARTnetPredict bridge.Validation
method = "existing"(tolerance 0).tests/testthat/test-target-pop-robustness.R(crash, clamping, no-recycle, seed reproducibility).R CMD check: 0 errors / 0 warnings / 0 notes.Notes
ARTnet >= 2.9.1. Drop that commit if you prefer a different versioning scheme.