Fix active.sex and young.prop in the sexual-cessation configuration - #88
Merged
Conversation
Two defects in build_netstats() when age.limits[2] sits above age.sexual.cessation, so the population keeps aging past the point where it stops forming partnerships. active.sex was zeroed on max(attr_age.grp) as realized rather than on the age group the breaks declare. Whenever the post-cessation group came out empty that marked the oldest sexually active group inactive and zeroed its degree on all three layers, silently. It hit the sampling path and the target_pop data frame path alike, so a projected population whose oldest member sits below the cessation age had the same problem. young.prop = 1 empties the post-cessation group by construction, which triggered the first defect and then failed much later in netest() on a target.stats length mismatch, since an age group with no members carries no ergm term. Both endpoints are now rejected with a message pointing at a usable value, and a band that comes out empty for other reasons warns instead. Neither change touches the default configuration, where the population upper limit and the cessation age coincide and there is no post-cessation band.
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.
Two fixes to the sexual-cessation configuration, where
age.limits[2]sits aboveage.sexual.cessationso the population keeps aging past the point where it stops forming partnerships. Both surfaced while building the CEA-variant model for the CABARET cost-effectiveness paper.active.sexwas keyed on the realized maximum age group.build_netstats()zeroed it onmax(attr_age.grp)rather than on the age group the breaks declare. Whenever the post-cessation group came out empty that marked the oldest sexually active group inactive and zeroed its degree on all three layers, with no error and no warning. On a 15-to-100 population with cessation at 65 andyoung.prop = 1, every 55-to-64 year old was retired instead:The same applied to the
target_popdata frame path, so a projected population whose oldest member happens to sit below the cessation age hit it too, which is the more likely route in ARTnetPredict. The band is now read offage.breaks, whichbuild_epistats()guarantees containsage.sexual.cessation.young.prop = 1is now rejected rather than silently degenerate. It empties the post-cessation group by construction, which triggered the defect above and then failed much later innetest()on atarget.statslength mismatch, because an age group with no members carries noergmterm. Both endpoints now error with a message pointing at a usable value (0.999 seeds about 0.1% ofnetwork.sizeabove the cessation age, enough for the level to exist while the group fills over the burn-in). A band that comes out empty for other reasons, anetwork.sizetoo small for the seeded share or atarget_popwith no post-cessation members, warns for the same reason.Neither change touches the default configuration, where the population upper limit and the cessation age coincide and there is no post-cessation band.
young.propthere is still inert and still accepted at any value. Checked directly: on the Atlanta 15-to-65 configuration at 25,000 nodes with a fixed seed,epistats,netparams, the attribute vectors, every numeric target statistic on all three layers, anddemogare byte-identical between 2.9.0 and this branch.tests/testthat/test-sex-cessation.Ris new: 37 assertions covering the configuration, the mortality cut moving from 65 to the upper age limit,active.sexagreeing exactly withage >= age.sexual.cessationon both paths, the empty-band regression on the data frame path, and the two endpoint errors. Full suite is 623 passing,R CMD checkis clean.