View source: R/screen-survival.R
| apply_time_to_treatment | R Documentation |
Obtain Probability Curve for Treatment
apply_time_to_treatment(diag_surv, treat_surv)
diag_surv |
Time to diagnosis probability function vector. The probability an individual diagnosed i days ago is not diagnosed. |
treat_surv |
Time to treatment. The probability an individual diagnosed i days ago is not on treatment. |
If the RITA algorithm excludes individuals based on treatment rather than diagnosis, this function can be used to calculate the survival function for use in icidence estimation.
A vector where the ith element is the probability that an individual infected i days ago has either not been diagnosed or is not on treatment.
data("assay_data")
#Obtain the diagnosis survival function
diag_surv <- diagnosis_survival(
assay_data$undiagnosed,
assay_data$tslt,
assay_data$ever_hiv_test,
assay_data$hiv,
assay_data$weights,
n=365*2)
# Posit an average time to treatment of 150 days
treat_surv <- 1 - pexp(1:(365*2), 1/150)
# Calculate the treatment survival function
diag_treat_surv <- apply_time_to_treatment(diag_surv, treat_surv)
# Compare survival curve for time to diagnosis (red) vs time to treatment (black)
plot(diag_treat_surv, type="l")
points(diag_surv, type="l",col="red")
#Create a dummy variable for treatment
assay_data$treated <- !assay_data$undiagnosed
#Calculate incidence
rita_incidence(
recent=assay_data$recent,
undiagnosed=assay_data$treated, #used treated indicator in place of undiagnosed for screening
low_viral=assay_data$elite_cntr,
hiv=assay_data$hiv,
weights=assay_data$weights,
tslt=assay_data$tslt,
ever_hiv_test=assay_data$ever_hiv_test,
diag_surv = diag_treat_surv
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.