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

Art absolute adjustment #47

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: eppasm
Title: Age-structured EPP Model for HIV Epidemic Estimates
Version: 0.8.2
Version: 0.8.3
Authors@R: person("Jeff", "Eaton", email = "[email protected]", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends: R (>= 3.1.0),
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## eppasm 0.8.3

* Implement Spectrum adult ART adjustment by absolute count. This is a user
input that adjust the number on ART count by an absolute value. It is
intended to be used to account for clients receiving services in or
from another region; typically with subnational Spectrum files.

If both absolute count and ratio adjustments are specified in the same
year, the absolute count is applied first and then ratio is applied.
If ART is specified as a percentage, then adjustments do not have any
influence.

Previously entered ART adjustments were applied or not via a checkbox in
Spectrum. The checkbox has been removed in Spectrum 6.38 beta 18. For
backward compatability with previously simulated Spectrum outputs, if the
checkbox flag exists in the .DP file, it is still used to determine
application of the ratios; if the .DP file does not contain the checkbox
flag, then the ratio is applied.

## eppasm 0.8.2

Implement new excess non-AIDS mortality among PLHIV implemented in
Expand Down
44 changes: 37 additions & 7 deletions R/read-spectrum-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -653,20 +653,50 @@ read_hivproj_param <- function(pjnz, use_ep5=FALSE){
## * Enabled / disabled by checkbox flag ("<AdultARTAdjFactorFlag>")
## * Scaling factor only applies to number inputs, not percentages (John Stover email, 20 Feb 2023)
## -> Even if scaling factor specified in a year with percentage input, ignore it.
##
##

if (exists_dptag("<AdultARTAdjFactorFlag>") &&
dpsub("<AdultARTAdjFactorFlag>", 2, 4) == 1) {

## ** UPDATE Spectrum 6.37 beta 18 **
##
## Two changes to the adult ART adjustment were implemented in Spectrum 6.37 beta 18:
##
## * ART adjustments were moved the main Spectrum editor and the flag variable
## "<AdultARTAdjFactorFlag>" was removed from the .DP file.
## * New tag "<AdultPatsAllocToFromOtherRegion>" was added allowing for input
## of absolute count adjustment
##
## New logic to account for these changes:
## * Initialise values to defaults 1.0 for relative adjustment and 0.0
## for absolute adjustment.
## * Only check flag variable if it exists. If adjustment variable exists
## but flag variable does not exist, use the adjustment.
##

## Initialise
adult_artadj_factor <- array(1.0, dim(art15plus_num))
adult_artadj_absolute <- array(0.0, dim(art15plus_num))

## Flag to use adjustment
use_artadj <- exists_dptag("<AdultARTAdjFactor>") &&
(!exists_dptag("<AdultARTAdjFactorFlag>") ||
(exists_dptag("<AdultARTAdjFactorFlag>") &&
dpsub("<AdultARTAdjFactorFlag>", 2, 4) == 1))

if (use_artadj) {

adult_artadj_factor <- sapply(dpsub("<AdultARTAdjFactor>", 3:4, timedat.idx), as.numeric)

if(exists_dptag("<AdultPatsAllocToFromOtherRegion>")) {
adult_artadj_absolute <- sapply(dpsub("<AdultPatsAllocToFromOtherRegion>", 3:4, timedat.idx), as.numeric)
}

## Only apply if is number (! is percentage)
adult_artadj_factor <- adult_artadj_factor ^ as.numeric(!art15plus_numperc)
adult_artadj_absolute <- adult_artadj_absolute * as.numeric(!art15plus_numperc)

## First add absolute adjustment, then apply scalar adjustment (Spectrum procedure)
art15plus_num <- art15plus_num + adult_artadj_absolute
art15plus_num <- art15plus_num * adult_artadj_factor
} else {
adult_artadj_factor <- array(1.0, dim(art15plus_num))
}
}


if(exists_dptag("<NewARTPatAllocationMethod MV2>"))
Expand Down
Loading