Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict contraceptive uptake to sexually active agents #157

Merged
merged 10 commits into from May 26, 2023

Conversation

avictorious
Copy link
Contributor

@avictorious avictorious commented May 13, 2023

This PR is the algorithm changes necessary to track sexual inactivity in agents and then select agents as eligible to start contraceptive methods based on whether they've gotten to age of sexual debut and have been sexually active within the last 12 months. It adds a testing script under a new folder "analyses" to query the model for these characteristics.

The sexual activity tracker is ingrained in the model and the restriction can be turned on and off with a new boolean "restrict_method_use" in the location.py parameters files. It is set to be off. It should be turned on when matrices are substituted to be contraceptive method uptake only among women who have ever had sex and have had sex in the last 12 months.

Closes issue #145. Note that as requested by @MObrien-IDM, there is a very small non-zero chance that someone may take up a method before they debut (they are eligible at fated debut age, not just when they debut), but as the algorithm is written there is a zero chance they will take up a method if they have not had sex in >= 12 months.

CPR and other calibration targets for Senegal and Kenya will need to be queried again once matrices are swapped out.

Type(s) of change

  • Bugfix
  • Refactor
  • New feature
  • Other

Checklist

  • My code follows the style guide
    • Yes
    • N/A
  • I've commented my code
    • Yes
    • N/A
  • I've incremented the version number
    • Yes
    • N/A
  • I've updated the changelog
    • Yes
    • N/A
  • I've added tests and checked code coverage
    • Yes
    • N/A

A script to analyze how many agents are inactive for < 1 year and dynamics around use pre and post debut
Agents must have passed the eligible age for debut (debut follows behind in 1-2 months) and must be sexually active in the last 11 months
checks on users predebut and while sexually inactive.  Reports overall CPR too
@avictorious
Copy link
Contributor Author

@cliffckerr I'm getting the same pytest errors that Michelle was getting previously. I think there's some backend infrastructure work unrelated to my code changes here that needs to be addressed for this to be able to pass....

FAILED test_analyzers.py::test_timeseries_recorder - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (100,) + inhomogeneous part.

@cliffckerr
Copy link
Member

@avictorious This was caused by hard-coding keys in timeseries_recorder(), @emilykclaps were able to fix it this afternoon though!

Copy link
Member

@cliffckerr cliffckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Contributor

@MObrien-IDM MObrien-IDM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @avictorious for this! Thank you @emilykclaps and @cliffckerr for fixing the bug! Appreciate you all.

@MObrien-IDM MObrien-IDM merged commit 0e9343e into main May 26, 2023
1 check passed
@MObrien-IDM MObrien-IDM deleted the restrict-contraceptive-uptake-to-active-agents branch May 26, 2023 15:17
@avictorious
Copy link
Contributor Author

@emilykclaps @cliffckerr thanks for addressing the bug! @MObrien-IDM Glad this request got to completion, it's a nice addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants