diff --git a/DESCRIPTION b/DESCRIPTION index 0a9e674..08c6359 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "jeffrey.eaton@imperial.ac.uk", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: R (>= 3.1.0), diff --git a/NEWS.md b/NEWS.md index 0474e13..a8eb899 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/read-spectrum-files.R b/R/read-spectrum-files.R index 6662dc4..2070064 100644 --- a/R/read-spectrum-files.R +++ b/R/read-spectrum-files.R @@ -653,20 +653,50 @@ read_hivproj_param <- function(pjnz, use_ep5=FALSE){ ## * Enabled / disabled by checkbox flag ("") ## * 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("") && - dpsub("", 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 + ## "" was removed from the .DP file. + ## * New tag "" 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("") && + (!exists_dptag("") || + (exists_dptag("") && + dpsub("", 2, 4) == 1)) + + if (use_artadj) { + adult_artadj_factor <- sapply(dpsub("", 3:4, timedat.idx), as.numeric) + if(exists_dptag("")) { + adult_artadj_absolute <- sapply(dpsub("", 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(""))