Title: | Incidence Estimation Tools |
---|---|
Description: | Tools for estimating incidence from biomarker data in cross- sectional surveys, and for calibrating tests for recent infection. Implements and extends the method of Kassanjee et al. (2012) <doi:10.1097/EDE.0b013e3182576c07>. |
Authors: | Eduard Grebe [cre, aut], Alex Welte [aut], Avery McIntosh [aut], Petra Bäumler [aut], Reshma Kassanjee [ctb], Hilmarie Brand [ctb], Cari Van Schalkwyk [ctb], Yuruo Li [ctb], Simon Daniel [ctb], Stefano Ongarello [aut], Yusuke Asai [ctb], Jeffrey Eaton [ctb] |
Maintainer: | Eduard Grebe <[email protected]> |
License: | GPL-3 |
Version: | 1.0.9006 |
Built: | 2024-11-17 05:11:39 UTC |
Source: | https://github.com/SACEMA/inctools |
The dataset 'excalibdata.Rdata' contains example data from an evaluation of an assay measuring recency of infection. At an assay result of <10, the specimen is considered to be recently infected. It further contains viral load data, which is commonly used to reduce false recency. For example, when recency is defined as assay result <10 and viral load > 1000, the FRR is substantially lower (but the MDRI is also reduced).
excalibdata
excalibdata
An object of class data.frame
with 1460 rows and 7 columns.
Estimates subject-level false-recent rate (FRR) for a given time cutoff. Each subject with any observations after the time cutoff is assigned a recency status according to the majority of observations for that subject after the cutoff. In the event of exactly half of the observations being classified as recent, the subject contributes a count of 0.5. The function performs an exact binomial test and reports the estimated probability of testing recent after the cutoff, a confidence interval for the proportion, the number of recent results ('successes'), number of subjects ('trials') and the number of data points contributing to the subject-level estimate.
frrcal( data = NULL, subid_var = NULL, time_var = NULL, recency_cutoff_time = 730.5, recency_rule = "binary_data", recency_vars = NULL, recency_params = NULL, alpha = 0.05, method = "exact", debug = FALSE )
frrcal( data = NULL, subid_var = NULL, time_var = NULL, recency_cutoff_time = 730.5, recency_rule = "binary_data", recency_vars = NULL, recency_params = NULL, alpha = 0.05, method = "exact", debug = FALSE )
data |
A data frame containing variables for subject identifier, time (since detectable infection), and variables with biomarker readings or recency status (to be specified in recency_vars) |
subid_var |
The variable in the dataframe identifying subjects |
time_var |
The variable in the dataframe indicating time between 'time zero' (usually detectable infection) and biomarker measurement |
recency_cutoff_time |
Recency time cut-off ('Big T'). Default=730.5. |
recency_rule |
Specified rule for defining recent/non-recent outcomes from biomarker data (see Details) |
recency_vars |
Variables to be used in determining recency outcomes |
recency_params |
Vector of numeric parameters (e.g. thresholds) for determining recency according to the relevant rule |
alpha |
Confidence level, default=0.05. |
method |
Method for computing confidence interval on binomial probability (passed to binom::binom.confint). Default is Clopper-Pearson 'exact' method. Accepted values: 'c("exact", "ac", "asymptotic", "wilson", "prop.test", "bayes", "logit", "cloglog", "probit")'. |
debug |
Enable debugging mode (browser) |
The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
recency_rule: binary_data - supply a binary variable with 1=recent and 0=non-recent in recency_vars.
recency_rule: independent_thresholds: supply one threshold variable per biomarker in recency_vars and the relevant thresholds, as well as whether a value below or above each threshold indicates recency in recency_params.
recency_params expects a list of pairs of thresholds and thresholdtypes, with zero indicating a reading below the threshold implies recency and 1 that a reading above the threshold implies recency. (Note: two values, a threshold and a thresholdtype per variable must be specified in recency_params. For example, if you specify recency_vars = c('ODn','ViralLoad') you may specify recency_params = c(1.5,0,500,1), meaning that an ODn reading below 1.5 AND a viral load reasing above 500 indicates a recent result. Objects with missing values in its biomarker readings will be excluded from caculation.
frrcal(data=excalibdata, subid_var = "SubjectID", time_var = "DaysSinceEDDI", recency_cutoff_time = 730.5, recency_rule = "independent_thresholds", recency_vars = c("Result","VL"), recency_params = c(10,0,1000,1), method = "exact", alpha = 0.05)
frrcal(data=excalibdata, subid_var = "SubjectID", time_var = "DaysSinceEDDI", recency_cutoff_time = 730.5, recency_rule = "independent_thresholds", recency_vars = c("Result","VL"), recency_params = c(10,0,1000,1), method = "exact", alpha = 0.05)
Incidence and incidence difference statistics from trinomial counts of HIV and recency
inccounts( N, N_H, N_testR, N_R, DE_H = 1, DE_R = 1, BS_Count = 10000, Boot = FALSE, alpha = 0.05, BMest = "same.test", MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, Covar_HR = 0, debug = FALSE )
inccounts( N, N_H, N_testR, N_R, DE_H = 1, DE_R = 1, BS_Count = 10000, Boot = FALSE, alpha = 0.05, BMest = "same.test", MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, Covar_HR = 0, debug = FALSE )
N |
Counts of total survey sample size(s) (vector/integer). |
N_H |
Number of HIV positive found in survey(s) (vector/integer). |
N_testR |
Number tested for recency in survey(s) (vector/integer). |
N_R |
Number of recent cases in survey(s) (vector/integer). |
DE_H |
Design effect of HIV prevalence test (vector/numeric), greater than or equal to 1. If multiple surveys are entered but only one design effect is specified, function assumes entered design effect is identical for both surveys. |
DE_R |
Design effect of recency test (vector/numeric), greater than or equal to 1. If multiple surveys are entered but only one design effect is specified, function assumes entered design effect is identical for both surveys. |
BS_Count |
Specifies number of bootstrap samples for bootstrapped confidence intervals of incidence. |
Boot |
True/False variable indicating whether variance of point estimates is to be calculated by Empirical Bootstrapping (TRUE) or Delta Method (FALSE), the default setting. |
alpha |
test rejection threshold. |
BMest |
Biomarker estimation by one the 3 options 'same.test'(=default), 'FRR.indep', 'MDRI.FRR.indep' (string). |
MDRI |
mean duration of recent infection [days] (vector/integer). |
RSE_MDRI |
Relative standard error of MDRI [days] (vector/integer). |
FRR |
False recent rate (vector/integer). |
RSE_FRR |
Relative standard error of FRR (vector/integer). |
BigT |
Cut point in days of recency used in biomarker assay to test recency in a given prevalence survey. |
Covar_HR |
Covariance of probability of being postive and being categorized recent from survey (or as a vector for multiple surveys). |
debug |
Enable debugging mode (browser) |
Implements assay-based incidence estimation through cross-sectional prevalence and recency of infection tests as described by Kassanjee, et al. 'A new general biomarker-based incidence estimator,' Epidemiology (2012). Function parameters must be specified to include assay test characteristics and survey results as proportions. Confidence intervals are computed via Delta method approximation, except when Boot=TRUE is specified, in which case confidence intervals are generated by empirical bootstrap resampling. Inputs must be in appropriate ranges for appropriate units. Extreme input values may make calculation impossible, and if entered will elicit error notices. The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
Incidence estimate, annual risk of infection, confidence interval, relative standard error of estimate and of assay characteristics MDRI and FRR. If multiple surveys are entered, function returns said results, as well as estimates of incidence differences, confidence intervals of differences, difference relative standard errors, and p-values testing the hypothesis that the difference in incidence measures are zero. Theoretical relative standard error of incidence and incidence difference at infinite sample size is returned only if Boot = FALSE, as that calculation relies on the asymptotic behavior of components of the Delta method approximation, and is not calculable from bootstrapped values.
inccounts(N = c(5000) ,N_H = 1000, N_testR = 1000, N_R = 70, Boot = FALSE, BMest = 'MDRI.FRR.indep', MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730) inccounts(N = c(4000,4000,4050) ,N_H = c(1010,1000,900), N_testR = c(1000,1000,880), N_R = c(60,70,50), Boot = TRUE, BMest = 'same.test', MDRI = 210, RSE_MDRI = 0.05, FRR = 0.005, RSE_FRR = 0.19, BigT = 700) inccounts(N = c(4000,4000) ,N_H = c(1050,1090), N_testR = c(1000,1000), N_R = c(60,67), Boot = FALSE, BMest = 'FRR.indep', MDRI = 220, RSE_MDRI = 0.05, FRR = c(0.005,0.005), RSE_FRR = 0.19, BigT = 610)
inccounts(N = c(5000) ,N_H = 1000, N_testR = 1000, N_R = 70, Boot = FALSE, BMest = 'MDRI.FRR.indep', MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730) inccounts(N = c(4000,4000,4050) ,N_H = c(1010,1000,900), N_testR = c(1000,1000,880), N_R = c(60,70,50), Boot = TRUE, BMest = 'same.test', MDRI = 210, RSE_MDRI = 0.05, FRR = 0.005, RSE_FRR = 0.19, BigT = 700) inccounts(N = c(4000,4000) ,N_H = c(1050,1090), N_testR = c(1000,1000), N_R = c(60,67), Boot = FALSE, BMest = 'FRR.indep', MDRI = 220, RSE_MDRI = 0.05, FRR = c(0.005,0.005), RSE_FRR = 0.19, BigT = 610)
Calculate power and required sample size for a given power to detect incidence change.
incpower( I1, I2, PrevH1, PrevH2, n1 = "both", n2 = "both", alpha = 0.05, Power = 0.8, SS = "out", CR = 1, DE_H = 1, DE_R = 1, BMest = "same.test", MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, Boot = FALSE, BS_Count = 1e+05, Cov.PrevH.I = c(0, 0), debug = FALSE )
incpower( I1, I2, PrevH1, PrevH2, n1 = "both", n2 = "both", alpha = 0.05, Power = 0.8, SS = "out", CR = 1, DE_H = 1, DE_R = 1, BMest = "same.test", MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, Boot = FALSE, BS_Count = 1e+05, Cov.PrevH.I = c(0, 0), debug = FALSE )
I1 |
Predicted incidence of HIV in survey 1. |
I2 |
Predicted incidence of HIV in survey 2. |
PrevH1 |
Predicted prevalence of HIV in survey 1. |
PrevH2 |
Predicted prevalence of HIV in survey 2. |
n1 |
Sample size for survey 1. If equal sample sizes for both surveys are desired at a given power level, both n1 and n2 must have value 'both', which is the default. |
n2 |
Sample size for survey 2. If equal sample sizes for both surveys are desired at a given power level, both n1 and n2 must have value 'both', which is the default. |
alpha |
Significance level for test (default alpha=0.05). |
Power |
Desired power used to calculate a sample size for the surveys. Default is 0.80, meaning the function outputs the necessary sample size to achieve stated power for a test of differences in incidence. If Power is set to 'out', function will return power of detecting a difference in incidences for given sample size inputs. |
SS |
Sample size. Default is 'out', meaning the function takes a power argument and outputs a common sample size needed to achieve power level for test of differences for incidence. If power is desired for a given sample size, parameter value is irrelevant; however, values for n1 and n2 must be specified. |
CR |
Coverage rate (0-1). |
DE_H |
Design effect of HIV prevalence test (vector/integer). If a single value is specified, that value is assumed to be the value for both surveys. |
DE_R |
Design effect of recency test (vector/integer). If a single value is specified, that value is assumed to be the value for both surveys. |
BMest |
Biomarker test parameter (MDRI, FRR, and RSE) estimation by one the 3 options 'same.test'(default), 'FRR.indep', 'MDRI.FRR.indep' (string). |
MDRI |
mean duration of recent infection [days] (vector/integer). If a single value is specified, that value is assumed to be the value for both surveys. |
RSE_MDRI |
Relative standard error of MDRI [days] (vector/integer). If a single value is specified, that value is assumed to be the value for both surveys. |
FRR |
False recent rate (vector/integer). If a single value is specified, that value is assumed to be the value for both surveys. |
RSE_FRR |
Relative standard error of FRR (vector/integer). If a single value is specified, that value is assumed to be the value for both surveys. |
BigT |
Post-infection time cut-off (days). Default 730. If a single value is specified, that value is assumed to be the value for both surveys. |
Boot |
True/False variable indicating whether variance of point estimates is to be calculated by Empirical Bootstrapping (TRUE) or Delta Method (FALSE), the default setting. |
BS_Count |
Specifies number of bootstrap samples for bootstrapped confidence intervals of incidence. |
Cov.PrevH.I |
Covariance of prevalence and incidence for bootstrap resampling. |
debug |
Enable debugging mode (browser) |
The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
Common sample size of two surveys–or the sample size of one survey given the other has already been completed–necessary to achieve a given power level for testing a null hypothesis that the incidence rates are identical between populations; alternatively, the power of said test under a particular sample size scenario. Function also returns implied statistics from input values on paramters, confidence limits, and population counts.
incpower(I1 = 0.05, I2 = 0.03, PrevH1 = 0.20, PrevH2 = 0.20, n1 = 5000, n2 = 5000, alpha = 0.05, Power = "out", SS = NULL, DE_H = c(1,1.1), DE_R = 1, BMest = 'same.test', MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.20, BigT = 730) incpower(I1 = 0.05, I2 = 0.03, PrevH1 = 0.20, PrevH2 = 0.20, alpha = 0.05, Power = 0.80, SS = "out", DE_H = 1, DE_R = 1, BMest = 'FRR.indep', MDRI = 200, RSE_MDRI = 0.05, FRR = c(0.01,0.009), RSE_FRR = c(0.20,0.21), BigT = 730)
incpower(I1 = 0.05, I2 = 0.03, PrevH1 = 0.20, PrevH2 = 0.20, n1 = 5000, n2 = 5000, alpha = 0.05, Power = "out", SS = NULL, DE_H = c(1,1.1), DE_R = 1, BMest = 'same.test', MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.20, BigT = 730) incpower(I1 = 0.05, I2 = 0.03, PrevH1 = 0.20, PrevH2 = 0.20, alpha = 0.05, Power = 0.80, SS = "out", DE_H = 1, DE_R = 1, BMest = 'FRR.indep', MDRI = 200, RSE_MDRI = 0.05, FRR = c(0.01,0.009), RSE_FRR = c(0.20,0.21), BigT = 730)
Calculate precision of incidence estimate and required sample size for a given precision of the incidence estimate.
incprecision( I, RSE_I, PrevH, CR, MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, DE_H = 1, DE_R = 1, n = "out", step = 5 )
incprecision( I, RSE_I, PrevH, CR, MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, DE_H = 1, DE_R = 1, n = "out", step = 5 )
I |
Expected Incidence. |
RSE_I |
Relative Standard Error of Incidence Estimate. If this is the desired output, set to "out". |
PrevH |
Prevalence of HIV. |
CR |
Coverage rate: probability (0-1) of being tested for recency when positive for HIV. |
MDRI |
mean duration of recent infection in days (vector/integer). |
RSE_MDRI |
Relative standard error of MDRI (vector/integer). |
FRR |
False recent rate (vector/integer). |
RSE_FRR |
Relative standard error of FRR (vector/integer). |
BigT |
post-infection time cut-off for true vs. false recency. Default is 730 days. |
DE_H |
Design effect of HIV prevalence test (vector/integer). |
DE_R |
Design effect of recency test (vector/integer). |
n |
Sample Size: Set to a hypothetical value if the desired output is RSE_I, othewise set to "out" to obtain required sample size. |
step |
number of steps between minimum I and maximum I in the calculation of a range of output. |
The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
This function summarizes performance of a recent infection test into a standard error of the incidence estimate, given the estimated test properties and hypothetical survey context or the sample size necessary for a given level of precision.
Up to two arguments can be specified as ranges, with the input parameter 'step' specifying the number of increments between the endpoints of the two ranges supplied under the argument name. This yields output for each step. See the second and third example below for an illustration of this output.
Either the argument RSE_I or the argument n must be set to "out".
Either sample size necessary for a given precision under a given set of testing characteristics and a hypothetical prevalence/incidence scenario, or precision under a particular sample size scenario, with a given hypothetical prevalence/incidence scenario.
incprecision(I = 0.015, RSE_I = 0.25, PrevH = 0.2, CR = 1, MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730, DE_H = 1.1, DE_R = 1, n = 'out') incprecision(I = c(0.015,0.02), RSE_I = 0.25, PrevH = c(0.10,0.20), CR = 1, MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 700, DE_H = 1, DE_R = 1, n = 'out', step = 5) incprecision(I = 0.017, RSE_I = 'out', PrevH = c(0.10,0.20), CR = 1, MDRI = 211, RSE_MDRI = 0.05, FRR = 0.009, RSE_FRR = 0.2, BigT = 720, n = 5000, step = 5)
incprecision(I = 0.015, RSE_I = 0.25, PrevH = 0.2, CR = 1, MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730, DE_H = 1.1, DE_R = 1, n = 'out') incprecision(I = c(0.015,0.02), RSE_I = 0.25, PrevH = c(0.10,0.20), CR = 1, MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 700, DE_H = 1, DE_R = 1, n = 'out', step = 5) incprecision(I = 0.017, RSE_I = 'out', PrevH = c(0.10,0.20), CR = 1, MDRI = 211, RSE_MDRI = 0.05, FRR = 0.009, RSE_FRR = 0.2, BigT = 720, n = 5000, step = 5)
Incidence and incidence difference statistics from trinomial prevalences of HIV and recency
incprops( PrevH, RSE_PrevH, PrevR, RSE_PrevR, Boot = FALSE, BS_Count = 10000, alpha = 0.05, BMest = "same.test", MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, Covar_HR = 0, debug = FALSE )
incprops( PrevH, RSE_PrevH, PrevR, RSE_PrevR, Boot = FALSE, BS_Count = 10000, alpha = 0.05, BMest = "same.test", MDRI, RSE_MDRI, FRR, RSE_FRR, BigT = 730, Covar_HR = 0, debug = FALSE )
PrevH |
Prevalence of HIV (vector/integer). |
RSE_PrevH |
Relative Standard Error (RSE) of estimate for population prevalence of HIV (vector/integer). |
PrevR |
Proportion of persons found to be 'recent' by biomarker assay among total persons found positive for HIV (vector/integer). |
RSE_PrevR |
Relative Standard Error (RSE) of estimate for population proportion of those testing positive for HIV who have been infected recently (vector/integer). |
Boot |
True/False variable indicating whether variance of point estimates is to be calculated by Empirical Bootstrapping (TRUE) or Delta Method (FALSE), the default setting. |
BS_Count |
Specifies number of bootstrap samples for bootstrapped confidence intervals of incidence. |
alpha |
test rejection threshold. |
BMest |
Biomarker estimation by one the 3 options 'same.test'(=default), 'FRR.indep', 'MDRI.FRR.indep' (string). |
MDRI |
mean duration of recent infection [days] (vector/integer). |
RSE_MDRI |
Relative standard error of MDRI [days] (vector/integer). |
FRR |
False recent rate (vector/integer). |
RSE_FRR |
Relative standard error of FRR (vector/integer). |
BigT |
post-infection time cut-off true vs false recent [days] default 730 days (integer). |
Covar_HR |
Covariance of probability of being positive and being categorized recent from survey (vector/integer). Note that as the variances of PrevH and PrevR are often quite small, only a suitably commensurate covariance will enable the inversion of the bootstrap covariance matrix for random number generation to proceed without error. |
debug |
Enable debugging mode (browser) |
Implements assay-based incidence estimation through cross-sectional prevalence and recency of infection tests as described by Kassanjee, et al. 'A new general biomarker-based incidence estimator,' Epidemiology (2012). Function parameters must be specified to include assay test characteristics and survey results as proportions. Confidence intervals are computed via Delta method approximation, except when Boot=TRUE is specified, in which case confidence intervals are generated by empirical bootstrap resampling. Inputs must be in appropriate ranges for appropriate units. Extreme input values may make calculation impossible, and if entered will elicit error notices.
The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
Returns incidence and incidence difference statistics, annualised risk and implied CIs on test characteristics.
incprops(PrevH = 0.20, RSE_PrevH = 0.028, PrevR = 0.10, RSE_PrevR = 0.09, BS_Count = 10000, Boot = TRUE, MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730) incprops(PrevH = c(0.20,0.21,0.18), RSE_PrevH = c(0.028,0.03,0.022), PrevR = c(0.10,0.13,0.12), RSE_PrevR = c(0.094,0.095,0.05), BS_Count = 10000, Boot = FALSE, BMest = 'MDRI.FRR.indep', MDRI = c(200,180,180), RSE_MDRI = c(0.05,0.07,0.06), FRR = c(0.01,0.009,0.02), RSE_FRR = c(0.2,0.2,0.1), BigT = 730)
incprops(PrevH = 0.20, RSE_PrevH = 0.028, PrevR = 0.10, RSE_PrevR = 0.09, BS_Count = 10000, Boot = TRUE, MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730) incprops(PrevH = c(0.20,0.21,0.18), RSE_PrevH = c(0.028,0.03,0.022), PrevR = c(0.10,0.13,0.12), RSE_PrevR = c(0.094,0.095,0.05), BS_Count = 10000, Boot = FALSE, BMest = 'MDRI.FRR.indep', MDRI = c(200,180,180), RSE_MDRI = c(0.05,0.07,0.06), FRR = c(0.01,0.009,0.02), RSE_FRR = c(0.2,0.2,0.1), BigT = 730)
The inctools package uses methods described by Kassanjee, et al. 'A new general biomarker-based incidence estimator,' Epidemiology (2012), to implement functions to calculate incidence and tests of incidence difference between two populations, as well as power and sample size constraints for different study scenarios. inctools also provides functions for calculation of mean duration of recent infection and false recency rates from assays for recent infection.
inctools has functions frrcal to estimate false recency rate; mdrical to estimate mean duration of recent infection; incprops and inccounts to calculate estimates and confidence intervals for incidence and incidence difference, as well as other summary and inferential statistics related to the survey; incpower to calculate sample size needed for a given power in a test of incidence difference, or vice versa; and incprecision, which gives sample size needed for a given precision in the incidence estimate or vice versa.
For a longer introduction, see the introductory vignette for this package. Use browseVignettes(package = "inctools") to access the vignettes.
Estimates MDRI (point estimate and confidence interval) using binomial regression and a maximum likelihood approach
mdrical( data = NULL, subid_var = NULL, time_var = NULL, functional_forms = c("cloglog_linear", "logit_cubic"), recency_cutoff_time = 730.5, inclusion_time_threshold = 800, recency_rule = "binary_data", recency_vars = NULL, recency_params = NULL, n_bootstraps = 10000, random_seed = NULL, alpha = 0.05, plot = TRUE, parallel = ifelse(n_bootstraps == 0, FALSE, TRUE), cores = parallel::detectCores(), output_bs_parms = FALSE, debug = FALSE )
mdrical( data = NULL, subid_var = NULL, time_var = NULL, functional_forms = c("cloglog_linear", "logit_cubic"), recency_cutoff_time = 730.5, inclusion_time_threshold = 800, recency_rule = "binary_data", recency_vars = NULL, recency_params = NULL, n_bootstraps = 10000, random_seed = NULL, alpha = 0.05, plot = TRUE, parallel = ifelse(n_bootstraps == 0, FALSE, TRUE), cores = parallel::detectCores(), output_bs_parms = FALSE, debug = FALSE )
data |
A data frame containing variables for subject identifier, time (since detectable infection), and variables with biomarker readings or recency status (to be specified in recency_vars) |
subid_var |
The variable in the dataframe identifying subjects |
time_var |
The variable in the dataframe indicating time between 'time zero' (usually detectable infection) and biomarker measurement |
functional_forms |
Select functional form/link function combinations for fitting probability of testing recent as a function of time to data using binomial regression (see Details). Default=all supported functional forms. |
recency_cutoff_time |
Recency time cut-off ('Big T'). Default = 730.5. |
inclusion_time_threshold |
Data points beyond this time are excluded from the calculation (in same unit as recency_cutoff_time, default = 800). |
recency_rule |
Specified rule for defining recent/non-recent outcomes from biomarker data (see Details) |
recency_vars |
Variables to be used in determining recency outcomes |
recency_params |
Vector of numeric parameters (e.g. thresholds) for determining recency according to the relevant rule |
n_bootstraps |
Number of subject-level bootstrap resampling operations for estimating confidence intervals, default = 10000. |
random_seed |
Pass a random seed for reproducible bootstrapping. Default is NULL. |
alpha |
Confidence level, default=0.05. |
plot |
Specifies whether a plot of the probability of testing recent over time should be produced |
parallel |
Set to TRUE in order to perform bootstrapping in parallel on a multicore or multiprocessor system. |
cores |
Set number of cores for parallel processing when parallel=TRUE. This defaults to four. |
output_bs_parms |
Return a matrix of the fitting parameters for each bootstrap iteration. |
debug |
Enable debugging mode (browser) |
The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
Expected data frame format: Before calling the function, please import your dataset into R environment.
time_var: Time since infection; Note: this package does not assume any specific time unit. It is important to specify the recency time cut-off 'T' and the time-based data exclusion rule (inclusion_time_threshold) in the same unit as the input times. The estimated MDRI will be in this unit.
Method: This function fits a function for probability of testing recent as a function of time to the supplied data using binomial regression. This requires binary outcomes (recent/non-recent) coded as 1 for recent and 0 for non-recent test resutls. Either a recency status variable must be specified, or a recency rule for determinging recency status from a biomarker or set of biomarkers must be specified. Currently only independent biomarker thresholds are supported (i.e. all biomarker criteria must be met in order for a specimen to be classified as recent).
Functional forms currently supported for the binomial regression fitting procedure: cloglog_linear, logit_cubic
To be implemented in the near future: logit_spline
logit_cubic: Fits a binomial regression to probability of testing recent with a logit link on a polynomial in t of the third degree, where t is time since (detectable) infection.
cloglog_linear: Fits a binomial regression to probability of testing recent with a log log link on log(t), where t is time since (detectable) infection.
recency_rule: binary_data - supply a binary variable with 1=recent and 0=non-recent in recency_vars.
recency_rule:independent_thresholds: supply one threshold variable per biomarker in recency_vars and the relevant thresholds, as well as whether a value below or above each threshold indicates recency in recency_params.
recency_params expects a list of pairs of thresholds and thresholdtypes, with zero indicating a reading below the threshold implies recency and 1 that a reading above the threshold implies recency. (Note: two values, a threshold and a thresholdtype per variable must be specified in recency_params. For example, if you specify recency_vars = c('ODn','ViralLoad') you may specify recency_params = c(1.5,0,500,1), meaning that an ODn reading below 1.5 AND a viral load reasing above 500 indicates a recent result. Objects with missing values in its biomarker readings will be excluded from caculation.
MDRI Dataframe containing MDRI point estimates, CI lower and upper bounds and standard deviation of point estimates produced during bootstrapping. One row per functional form.
Plots A plot of Probability of testing recent over time for each functional form.
Models The fitted GLM models for each functional form.
mdrical(data=excalibdata, subid_var = "SubjectID", time_var = "DaysSinceEDDI", recency_cutoff_time = 730.5, inclusion_time_threshold = 800, functional_forms = c("cloglog_linear"), recency_rule = "binary_data", recency_vars = "Recent", n_bootstraps = 10, parallel = FALSE, alpha = 0.05, plot = TRUE)
mdrical(data=excalibdata, subid_var = "SubjectID", time_var = "DaysSinceEDDI", recency_cutoff_time = 730.5, inclusion_time_threshold = 800, functional_forms = c("cloglog_linear"), recency_rule = "binary_data", recency_vars = "Recent", n_bootstraps = 10, parallel = FALSE, alpha = 0.05, plot = TRUE)
Prevalence and Relative Standard Errors by Counts
prevcounts(N, N_H, N_testR, N_R, DE_H = 1, DE_R = 1)
prevcounts(N, N_H, N_testR, N_R, DE_H = 1, DE_R = 1)
N |
Counts of total survey sample size(s) (vector/integer). |
N_H |
Number of HIV positive found in survey(s) (vector/integer). |
N_testR |
Number tested for recency in survey(s) (vector/integer). |
N_R |
Number of recent cases in survey(s) (vector/integer). |
DE_H |
Design effect of HIV prevalence test (vector/numeric), greater than or equal to 1. If multiple surveys are entered but only one design effect is specified, function assumes entered design effect is identical for both surveys. |
DE_R |
Design effect of recency test (vector/numeric), greater than or equal to 1. If multiple surveys are entered but only one design effect is specified, function assumes entered design effect is identical for both surveys. |
The package contains long form documentation in the form of vignettes that cover the use of the main fucntions. Use browseVignettes(package="inctools") to access them.
Prevalences and relative standard errors. Design effects are assumed negligible unless user specifies otherwise.
prevcounts(N = 5000, N_H = 1000, N_testR = 1000, N_R = 70, DE_R = 1.1) prevcounts (N = c(5000,5000), N_H = c(1000,1000), N_testR = c(1000,1000), N_R = c(100,70), DE_H = c(1,1.1), DE_R = c(1,1.1))
prevcounts(N = 5000, N_H = 1000, N_testR = 1000, N_R = 70, DE_R = 1.1) prevcounts (N = c(5000,5000), N_H = c(1000,1000), N_testR = c(1000,1000), N_R = c(100,70), DE_H = c(1,1.1), DE_R = c(1,1.1))